2 Scatter chart lines

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Frans-Jan Wind on 19th September 2012
Hello,

I'd like to make two lines using scatter chart. I'm successful in setting all points in 2 colors. Here's my example of setting 4 points in two colors

var data = [[1339538400,9,"red"],
   [1339538400,9.5,"green"],
   [1340229600,10,"red"],
   [1340229600,13,"green"]];

But when I set these parameters:
scatter.Set('chart.line', true);
scatter.Set('chart.line.colors', ['red','green']);
All points get connected with a red line. My guess is the format of the data array, but changing the format all points just disappear.

Could someone shed a light on the way I could make two independent lines using two colors

Thank you.
Posted by on 19th September 2012
Hi,

Your data is set up for just one line - only a single dataset. So you'll need to alter it to something like this:

var data1 = [[1339538400,9,"red"],[1340229600,10,"red"]];
var data2 = [[1339538400,9.5,"green"],[1340229600,13,"green"]];

var myScatter = new RGraph.Scatter('cvs', data1, data2);

Or a variant on the above useful for when you're working with AJAX:

var myScatter = new RGraph.Scatter('cvs', [data1, data2]);
Posted by on 19th September 2012
Thank you, putting the data as two different arrays solves this problem
Your speed of giving the solution is impressive. Thank you again.

Add a reply




« Back to message list