Graphing, Gtk, and Clutter

A day or two ago, I was doing some calculations and plots in octave the other day, and took a break to check my blog stats. It occurred to me that the animated flash chart that appears on my blog was heads-and-shoulders prettier than the simplistic 2d plotting done with gnuplot. Gnuplot is not antialiased, not animated, and doesn’t support alpha blending, whereas my blog stats do.

Like any good open source coder, I decided that I could change that. I made a custom Gtk widget that uses clutter and cairo to produce animated 2d plots. The entire thing is an embeddable clutter scene with its actors rendered by cairo, which means that its antialiased, animated, and can do alpha-blending. It still needs to have its API polished up so its usable by developers, but I’m pretty happy with how the plot turned out. Check out the video

Planet Users:click here to see it in action, or, just check out this screenshot:

A coder can add this plot easily with code like this:
GtkWidget *grph;
grph = gltz_graph_new ();
gltz_graph_add_pts (grph, 10, 20, TRUE);
gltz_graph_add_pts (grph, 50, 110, TRUE);
gltz_graph_add_pts (grph, 100, 0, TRUE);

You’ll have to figure out how to pack and expose the widget into the window yourself, but if you’re a GUI programmer, you can probably see how easy it is to throw this in your app.

Its still a work-in-progress, and I need to work out a better coordinate designation scheme for the users. (right now, the points are just placed in x-y position, with the UR corner being 0,0) I also need to provide some mechanisms for user customization of the animation and of the appearance, but those are small issues. I’ll publish the code in a few days, once its not ugly anymore :D.

This entry was posted in Coding, Open Source, Ubuntu. Bookmark the permalink.

6 Responses to Graphing, Gtk, and Clutter

  1. Scott says:

    I’ve written some graphing code using goocanvas. The graphs are on oswatershed.org. The code is at http://github.com/tannewt/open-source-watershed/tree/master. Email if you want to know more.

  2. Nick HS says:

    What’s the difference between this and cairoplot? https://launchpad.net/cairoplot

  3. Vadim P. says:

    Dude! You’re awesome. Hope you get a release out soon, this was -definitely- needed and amazing that you “just did it”.

  4. Make a release soon 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *