Introducing Grapher

I just found myself in the situation where i need to be able to create bargraphs.


The design is fairly limited: a row of stacked bars with optional labels under and inside each bar.


I also want to be able to color the bars.


I wrote a quick little PyQt-based Python program. It lets you write things like this:

bs = BarGraphStack()
bg = BarGraph()
bg.setTitle("Image Size")
bg.addBar(Bar(6349, Qt.Qt.darkGray, "6 349KiB", "kernel(bz)"))
bg.addBar(Bar(25240, Qt.Qt.lightGray, "25 240KiB", "rootfs"))
i = bs.render();
# i is a QImage

You can get the latest source code from the Grapher github repository. It is probably obvious that this is Python code written by a C++ guy, but I hope that it still might be useful.

Now I need to add some steps to feed it data automatically, but that is for another day.

2 thoughts on “Introducing Grapher”

  1. Thanks for the feedback, I’m glad that you like it. There are things that need to be done to the code:

    – Private variables
    – A full getter/setter interface for properties
    – No hardcoded fonts for headers, etc, introduce a style or settings class
    – Separation of size calculations and rendering (to allow for a UI)
    – Right now w = …; x+=w means that any calculation errors propagate. The input values need to be large to compensate…
    – More graph types through plugins
    – A UI

    Regarding the name – being allowed to trademark Grapher for a tool that does graphs is just silly. And I wont do kGrapher – I really dislike prefix names…

Comments are closed.