Data in RGraph Line chart

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 ruben on 25th March 2014
Good afternoon,

how can I make dynamic arrays for the chart data:


student_1 = [4,8,5];
student_2 = [3,3,3];
var line = new RGraph.Line ('cvs', student_1, student_2)



I need this or similar:

students[0] = [4,8,5];
students[1] = [3,3,3];
var line = new RGraph.Line ('cvs', students)


Because I don't know the limit from students and I have this information:
students[0] = [4,8,5];
students[1] = [3,3,3];
...
students[n] = [n,n,n];

I need to make RGrpah.Line with the last array.

I tried this:


var line = new RGraph.Line ('cvs', [])
line.original_data[0] = students[0];
line.original_data[1] = students[1];
line.Draw();


But draw the Y axis values ​​above the previous

You can see the example in this URL (is the picture):
www.casimages.es/i/140325050148527713.png.html


Thank you,

regards
Posted by Richard on 25th March 2014
Hi there,

Did you know you can do this:

student_1 = [4,8,5];
student_2 = [3,3,3];

var data = [student_1, student_2];

var line = new RGraph.Line ('cvs', data);




Richard
Posted by Ruben on 26th March 2014
Hello,

no, I don't know.

I am trying this:


string_student = "4,8,5_3,3,3"; //I have this data format

student = string_student.split("_");

for(i=0;i<student.length;i++){

     data[i] = student[i].split(",");

     alert(data[i]); //Result0 -> 4,8,5 Result1 -> 3,3,3

}

var line = new RGraph.Line ('cvs', data);


But not working.

Thanks

Regards
Posted by Richard on 26th March 2014
Hi there,

You'l need to:

1. Initialise the data array
2. Cast all the data to numbers (so they're not strings)



www.rgraph.net/fiddle/view/a-line-chart-using-csv-data




Richard
Posted by Ruben on 27th March 2014
Hello,

The problem is that "data" is an integer array and i make string array.

I solved.

Thanks

Regards

Add a reply




« Back to message list