GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Oct 22, 2014 1:38 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Bar chart
PostPosted: Tue Feb 28, 2012 1:29 pm 
Offline
Familiar Face

Joined: Tue Feb 28, 2012 1:16 pm
Posts: 11
Location: Russia
hi!
First of all I'm from Russia, so don't beat me for my english)

Give me please a hint how to do the following:
Image

It is a bar chart(histogram). Letters "a", "d", "s" are supposed to be some text, but the direction of text should be
from bottom to up. It must be resized properly.

I'm programming in C.

Thanx!!


Top
 Profile  
 
 Post subject: Re: Bar chart
PostPosted: Tue Feb 28, 2012 8:32 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
Dear Troma,
Your English is excellent, you should not be apologising for it.
Drawing a graph is done in cairo. You will have to make a customised widget. There's a tutorial on this in the Gtk website. Text direction is done by applying a rotation matrix.
Drawing a gaph is actually quite an easy task, it just requires a lot of code. A year ago I wrote a package for plotting line graphs that you could disect and turn into a bar graph widget. There's lots of features that you probably don't need (multiple plotting, handling four quadrants, wiggles on the axes, zooming and autoscaling) and will cut out as well as the actual drawing will be different for the bar look, but it might provide a good framework to get started; though I have to apologise as the code is very long due to the many if then else scenarios (I like to optimise so I avoid putting 'if's in for loops) and lacking in inline commenting.
The code is in gtk2, but as it uses cairo there's not much work neeed to bring it into a gtk3 format.
https://github.com/pchilds/GtkPlot/tree/master/PlotLinear
Let me know if you need any further advice,
Paul.


Top
 Profile  
 
 Post subject: Re: Bar chart
PostPosted: Wed Mar 21, 2012 6:20 pm 
Offline
Familiar Face

Joined: Tue Feb 28, 2012 1:16 pm
Posts: 11
Location: Russia
Hi, Paul!
Almost a month have been passed since you post a reply and i didn't even thank you. Sorry.
I was quite busy.
Your example is perfect, i turned it into what i needed.

Thanks you very much, you saved me:)
If there is any way to donate you i would do it with a great pleasure!


Top
 Profile  
 
 Post subject: Re: Bar chart
PostPosted: Wed Mar 21, 2012 11:17 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
I understand that it would take a while. My code's not easy to understand and creating a good graphing program takes a lot of time.
Well GPL code is the gift that keeps on giving so if you're thinking of releasing your code then GPL it for others to do the same (depending on how much adaptation you have made, you might have to -- if you are releasing it, though I am considering putting it out there as LGPL).
Maybe in the future when I get a few other plots together it might do to assemble a plotting library together. It's something missing from GTK that'd really make it great.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group