Multiple Line charts


« 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 Goldy on 6th June 2013
Hi,
I have 2 questions
  Q1) In using Line Graph why is there a need of prepadding the array with some values and then passing it to the RGraph.Line parameter. Cant I send 1 value at a time ?
    Q2 ) I want to plot 2 graphs. I am getting a Map of data from my ajax call.
         The data contains names which will decide the color of the line and the value will decide the number to be plotted on the graph. How do I achieve this?
Is there an example ?

Thanks
Posted by RGraph support on 6th June 2013
Hi there,

Q1: I don't know what you're referring to though sequential passing of data isn't a feature. You could have an array of, say, 12 values - 10 of which are null. Then as more data comes in you gradually fill up the array - redrawing the chart each time. A similar concept to this:

www.rgraph.net/demos/line-dynamic-updates.html

Q2: You can use the new RGraph.AJAX.getJSON() function to fetch a JSON object - there's a basic example of it here:

view-source:www.rgraph.net/docs/basic-ajax-json.html




Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Goldy on 6th June 2013
Ok I understood your reply. Thanks
But I want to plot n lines dynamically on Graph.
How do I make multiple arrays that need to be given to the RGraph.Line method ?
There can be 1 line plotted or n lines. This will happen at runtime
How do I achieve that ?
Posted by RGraph support on 6th June 2013
Hi there,

You can give the line datasets as part of one big multi-dimensional array if you wish instead of as separate arguments - like in this example:

dev.rgraph.net/demos/line-spline-multiple-lines-array.html




Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Goldy on 6th June 2013
Ok that example is very helpful.
Now instead of sending values with predefined datasets, I want to sent values in the arrays dynamically.
There are values added 1 by 1 to those datsets.So should I take this approach
www.rgraph.net/docs/updating-charts-dynamically.html

Here you are initializing 250 blocks of the d1 array to null.
Then you draw Graph and later add the value in the d1 array.
As we get 250 values filled up in the array it start showing up on the graph ? Correct ?
How do I achieve this same behaviour with using multidimensional array ?

Posted by Goldy on 6th June 2013
In short I want to achieve this
dev.rgraph.net/demos/line-dynamic-updates-range.html

But with n lines. The number of lines to be plotted will be dependent on the number of values chosen by user on the GUI page.

So
1)I have to make n number of arrays dynamically
2) Initialize them dynamically
3) Add values to them dynamically one by 1
4) add all these arrays in a ContainerArray and pass that to RGRaph.Line

Is that how it needs to be done ?
Please advice

Thanks
Posted by RGraph support on 7th June 2013
Hi there,

>As we get 250 values filled up in the array it start showing up on the graph ?
> Correct ? How do I achieve this same behaviour with using multidimensional array ?

No the chart is drawn without waiting for the array to fill up. Initially there are 250 null values in the array - which are gradually replaced, starting at the right, with numerical values. As values are added - null values are removed from the start.

You could use a "master" array - update that and give it to the Line object. Or, like this example, you can manipulate the datasets directly:

view-source:dev.rgraph.net/demos/line-dynamic-updates-range.html


Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Goldy on 7th June 2013
Hi,
Thanks I used that reference and its working.
Just one problem im facing.
In my case , I made a master array which consists of arrays.
Then I initialized 100 values in each of those arrays to null
later I get values and put them in each of the arrays.
Then I am pushing values from the master array into the graph Object
  dynamicGraph.original_data[i].push(containerArray[i][0]);
  dynamicGraph.original_data[i] = RGraph.array_shift(dynamicGraph.original_data[i]);

Now I can see 'n' line graphs which is correct , but the values that they plot are wrong
the second graph always plots the SUM of 'n' values
It is even difficult to debug because the firebug paints the canvas very fast.

What can be done here? Please let me know if you want to see my code snippet
Posted by RGraph support on 8th June 2013
Hi there,

I get the impression that you are looking for the chart.filled.accumulative setting - that this page demonstrates:

www.rgraph.net/docs/line-filled.html



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Goldy on 10th June 2013
Thanks a ton.
I racked my brains this whole weekend to get this thing achieived and there it was.
This property is something that I wanted.

Now, I have chart.key.color to choose different colors for each of the lines getting displayed.But I cant see any colors for all those keys.
They all show up in black color.

So its all dynamic.If I am choosing 3 lines to be displayed then they all show up in different color ,BUT the keys of all of them dont show me those colors
I am using this for reference www.rgraph.net/docs/keys-in-charts.html

Why doesnt my keys show colors that shows, that each of the lines in graph they are symbolized by colors and each color is mapped to something that shows the purpose of that line

Did you get my question right ?
Posted by RGraph support on 10th June 2013
Hi there,

I don't know why the colors aren't showing up correctly. If, for instance, you're using gradients you may need to specifically set the colors with the chart.key.colors option:

obj.Set('chart.key.colors', ['red','blue','green']);




Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Goldy on 10th June 2013
Ok That works . But I have to explicity write the colors.
The please tell me, how are the multiple lines showing up with different colors.
I am not writing explicity the colors of each of them ?

What I want to do is, each line represents a color (the color is chosen automaticlly)
That color should be assigned to its appropriate key color that it shows

Why cant the key.colors take its colors automatically the way each line does

Thanks a lot in advance. You really helped me a lot
Posted by Goldy on 10th June 2013
Hey,
I got it working. I just defined an array of colors and giving that array in the char.colors and also chart.key.colors.
In this way I can achieve same colors for the lines with its respective key

Thanks

Add a reply

 




« Back to message list
RGraph on social media