XYChart from YAML

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rachel.mccormack
Posts: 1
Joined: Fri Aug 12, 2016 4:22 pm
antibot: No, of course not.

XYChart from YAML

Post by rachel.mccormack » Fri Aug 12, 2016 4:32 pm

Hi.
Very new to jfreechart. Need to make line charts 'dynamically'. I have a YAML input of datapoints, times and names. I have no way of knowing how many lines will be on each graph.
I have this working easily using the 'Line chart' example here http://www.tutorialspoint.com/jfreechar ... _chart.htm
Problem is, there's too much data for any labels to show up on the X axis. I would like to limit this so that I can get at least some to appear. Have looked around and seems the only way to do this is using an 'XY' chart like this one http://www.tutorialspoint.com/jfreechar ... _chart.htm
I'm struggling to see how I could make one with my YAML though, without any hard coding. I don't know how many lines there will be in the chart. Surely the:

Code: Select all

final XYSeries firefox = new XYSeries( "Firefox" );          
      firefox.add( 1.0 , 1.0 );          
      firefox.add( 2.0 , 4.0 );          
      firefox.add( 3.0 , 3.0 ); 
Area would be looped over something like :

Code: Select all

for (i in names) :
	final XYSeries i = new XYSeries( i );
	for x in values 
            i.add( x['time'] , x['data'] ) 
But how would I get 'i' ? here it would obviously complain that i is a mismatch/ variable that already exists. .. as far as I know it isn't possible to change a variable name each time you go through a loop? What I think will happen is all my data would end up on one line named whatever 'i' is.
Is this possible to do or is the only way to create an XY chart to hard code it?
thanks.

moore1
Posts: 1
Joined: Sun Apr 16, 2017 5:37 am
antibot: No, of course not.

Re: XYChart from YAML

Post by moore1 » Sun Apr 16, 2017 8:53 am

More info about YAML can be found on Everipedia

Locked