Pie,Line and Bar chart resources

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Pie,Line and Bar chart resources

Post by antrax13 » Thu Jul 23, 2015 1:59 pm

Hi,
could someone give me a link/resources where I can learn about this topic?

I want to construct pie chart with 3 sections 10,20 and 70% and each section would have different color and percentage label.

I want to construct line chart going from [0,0] to [10,10] to [20,15] to [70,30] also x,y label

I want to construct bar chart with 10,20 and 70%. Each bar would have different color and percentage label and also x,y label

I do not want to use another third party engine/tool to create these charts unless its open source.

Thanks

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Pie,Line and Bar chart resources

Post by MaxV » Thu Jul 23, 2015 3:56 pm

antrax13 wrote:
I want to construct pie chart with 3 sections 10,20 and 70% and each section would have different color and percentage label.
Draw a circle, set start and arc from the property inspector.
antrax13 wrote: I want to construct line chart going from [0,0] to [10,10] to [20,15] to [70,30] also x,y label
Draw a line, set the points to

Code: Select all

0,0
10,10
20,15
70,30
You'll need to change real point values, since the origin inside a window start from the top-left corner.
antrax13 wrote: I want to construct bar chart with 10,20 and 70%. Each bar would have different color and percentage label and also x,y label
Draw 3 different rectangles. Change their colors and rect property.
Otherwise you can crate just one rectangle and play with gradients. :mrgreen:
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Re: Pie,Line and Bar chart resources

Post by antrax13 » Thu Jul 23, 2015 4:25 pm

that was not helpful at all

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Pie,Line and Bar chart resources

Post by Simon » Thu Jul 23, 2015 7:14 pm

Wow antrax13,
that was not helpful at all
Are you trying not to be helped?
Everything MaxV said was correct. A more positive response would be "I don't understand what you mean, could you explain it a bit more?" or "Where do I find out about arc?".

99% of the posts in these forums are from volunteers, nobody has to help you here.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Pie,Line and Bar chart resources

Post by dunbarx » Thu Jul 23, 2015 7:23 pm

What Simon said.

I suspect, and hope, that the comment was not as abrasive as it seemed. Communication via text must be carefully crafted.

What I think was really meant was: Can I get a code example?

So antrax13, was that it?

Craig Newman

antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Re: Pie,Line and Bar chart resources

Post by antrax13 » Mon Jul 27, 2015 9:00 am

What I am looking for is just some sort of examples/code/resources where to read/see how its done for pie, line and bar chart.

To draw line chart it is not so simple as it looks like if you just join points. It will not work if your axis must be flexible you do not want to show for example bar charts with values of 20 and 30 where Y axis is max 100 then its easy what if your values will be 10,10000 in that case you want to have max value of Y axis set to 10000+ but your Y axis will be the same size as 100 so you need to calculate coordinates in that case point [10,10] will not be at the same location where Y is 100 than the same point where Y is 10000. That is something I am looking for.

I will attach image for better illustration.
Image

When I have to produce a bar charts with values 20,30 it will not be the same height on first chart compare to chart 2 where values will be 20,10000

Thats what I need to point me to good direction with good resources or examples

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Pie,Line and Bar chart resources

Post by dunbarx » Mon Jul 27, 2015 4:04 pm

Hi.

This is not as onerous as you would think. The trick is to adjust each graph according to the situation. So if you make a graph of fixed size, you know its height. Say it is 200 pixels, Now if you want to place a bar that shows, say, 5 out of 10, you would set your vertical scale from 1 to 10, and set the height of the bar to 100. But if you make a new scale that goes from 1 to 1000, the height of the bar does not change; it is still 100. What changes is the scale factor you use in your calculations.

So set up your graph, again perhaps 200 pixels high. Place the text field that will contain your vertical scale. Place your bar graphic. Now only the ratio of the bar value to the max value matters. So if you need 5 out of 10 (pseudo):

Code: Select all

get the ratio--5 / 10 = 0.5
set the height of graphic "barGraphic" to it * 200 -- height is 100
Now if you need 250 out of 1000 (pseudo):

Code: Select all

get the ratio --250 / 1000 = 0.25
set the height of graphic "barGraphic" to it * 200 -- height is 50
Does this do it for you?

Craig

antrax13
Posts: 39
Joined: Mon Jun 01, 2015 11:38 am

Re: Pie,Line and Bar chart resources

Post by antrax13 » Tue Jul 28, 2015 8:58 am

Thanks that helps me.

If anyone is interested check my stack
Attachments
graph.zip
(1.5 KiB) Downloaded 273 times

Post Reply