Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating multiple series in a highcharts spline chart?
    primarykey
    data
    text
    <p>I made a spline chart using Highcharts library containing two series of data loaded from two different CSV files and it works fine. Now I need another spline chart, but with 54 data series.</p> <p>I used PHP to create the 54 CSV files, then my Javascript code generating the chart is:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { var chart; $(document).ready(function() { var options = { chart: { renderTo: 'chart_day', type: 'spline' }, title: { text: 'Andamento giornaliero temperatura.' }, xAxis: { type: 'datetime', second: '%H:%M:%S' }, yAxis: { title: { text: 'Temperatura (°C)' }, }, tooltip: { formatter: function() { return '&lt;b&gt;'+ this.series.name +'&lt;/b&gt;&lt;br/&gt;'+ Highcharts.dateFormat('%H:%M:%S', this.x) +': '+ this.y +' °C'; } }, series: [ &lt;?php for($i=0;$i&lt;52;$i++) echo "{ name: \"Sensor".($i+1)."\", data: []},"; echo "{ name: \"Sensor".($i+1)."\", data: []}"; ?&gt;] }; for( i=1; i&lt;=54; i++){ if(i!=5){ $.get('file/file'+i+'.txt', function(data) { // Split the lines var lines = data.split('\n'); // Iterate over the lines and add categories or series $.each(lines, function(lineNo,line) { if (line != "") { var items = line.split(','); var timeElements = items[0].split(':'); var date = Date.UTC(2004, 2, 1, timeElements[0], timeElements[1], timeElements[2], 0); options.series[i-1].data.push([date,parseFloat(items[1])]); } }); if(i==54) chart = new Highcharts.Chart(options); }); } } }); }); &lt;/script&gt; </code></pre> <p>There is an error in the JS consolle: </p> <blockquote> <p>"Uncaught TypeError: Cannot read property 'data' of undefined "</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload