jquery - How to load CSV to highcharts? -
i have trouble loading csv highcharts. don't know this: http://jsfiddle.net/3bqne/885/ (my code based on: how select columns csv chart highchart?). sample csv:
1,24,38 3,26,62 4,16,42 5,17,36
and code should show me chart on webpage:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <div id="container" style="width:100%; height:400px;"></div> <script> var options = { chart: { renderto: 'container', defaultseriestype: 'line' }, title: { text: 'temperatura' }, xaxis: { categories: [] }, yaxis: { title: { text: 'temperatura' } }, series: [{ data: [] }] }; $.get('data.csv', function(data) { var lines = data.split('\n'); $.each(lines, function (lineno, line) { var items = lines.split(','); if(lineno !== 0) { var x = items[0]; temp = parsefloat(items[1]); if(!isnan(temp)){ options.series[0].data.push([x,temp]); } } }); }); new highcharts.chart(options); </script>
i have sit whole day trying make chart interests me , have this... thank help!
Comments
Post a Comment