I'm trying to create multiple charts using multiple canvas tags with the CSV reader but it's not working.

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 Sebastian on 31st July 2017
Helo
I 'm stack
I have code like this:


<!DOCTYPE html!>
<meta charset="utf-8">
<html>
<head>
<script src="RGraph.common.core.js"></script>
<script src="RGraph.svg.common.ajax.js"></script>
<script src="RGraph.common.csv.js"></script>
<script src="RGraph.line.js"></script>
</head>

<body>

<canvas id="cvs" width="1024" height="150"> </canvas>
<canvas id="cvs1" width="1024" height="150"> </canvas>

<script>
     window.onload = function ()
     {
         RGraph.CSV('Fujitsu_Extras_Application.csv', function (csv)
         {
             // Just fetch the third column of the CSV file
             var data = csv.getCol(1);
    var labels = csv.getCol(0);
   
             var line = new RGraph.Line({
                 id: 'cvs',
                 data: data,
                 options: {
                     labels: labels,
                     textAccessible: true
                 }
             }).draw();
         });
     };




     {
         RGraph.CSV('Fujitsu_Extras_Support.csv', function (csv)
         {
             // Just fetch the third column of the CSV file
             var data1 = csv.getCol(1);
    var labels1 = csv.getCol(0);
   
             var line = new RGraph.Line({
                 id: 'cvs1',
                 data: data1,
                 options: {
                     labels: labels1,
                     textAccessible: true
                 }
             }).draw();
         });
     };
</script>


And when i try run script i see 2 line on one chart ,
But i need 2 charts.
Please help , what im doing wrong ?
Regards
Sebastian
Posted by Richard on 31st July 2017
Hi there,

You need to use the 'new' keyword when calling the CSV object.

Looks like I have some demos that need updating - but the docs page is accurate:

www.rgraph.net/canvas/docs/csv-file-reader.html



Richard

Add a reply




« Back to message list