javascript - Can i use papa parse to increase the loading time of highcharts for large files? -
highcharts couldn't load large csv files can use papa parse increase loading , response time of chart?
$(function () { $.get('<%= @wire.attachment %>', function(csv) { $('#container').highcharts({ chart: { type: 'area', zoomtype: 'x', spacingbottom: 30 }, data: { csv: csv }, title: { text: '<%= @wire.name %>' }, subtitle: { text: '' }, credits: { enabled: false }, yaxis: { title: { text: '' } } }) });});
i'm using below code, no luck. please go through code see if i'm doing wrong.
<script> (function() { //initializing basic chart configuration object var chartconfigoptions = { title: { text: 'climate data chicago - july 2014' }, subtitle: { text: '<a href="http://www.ncdc.noaa.gov" target="_blank">ncdc</a>', usehtml: true }, chart: { type: 'column' }, tooltip: { valuesuffix: '°f', usehtml: true }, plotoptions: { line: { pointstart: date.utc(2014, 06, 01, 00, 00, 00), pointinterval: 3600 * 1000 * 24 } }, xaxis: { title: { text: 'date' }, type: 'datetime' }, yaxis: { title: { text: 'temperature in °f', usehtml: true } }, series: [] }; //initializing empty variable file dom object var file = ''; //beginning process file loads $( '#csv_file' ).on( 'change', function( e ) { //getting file dom object file = e.target.files[0]; //checking if highcharts has been initialized on same container if ( $( '#climate_data' ).highcharts() ) { $( '#climate_data' ).highcharts().destroy(); } //parsing csv file papa.parse( file, { header: true, complete: function( results ) { //looping through headers ( var in results.meta.fields ) { var name = results.meta.fields[i]; //initializing empty series object chartconfigoptions.series[i] = {}; //giving series name chartconfigoptions.series[i].name = name; //initializing empty array holding series data chartconfigoptions.series[i].data = []; //looping through records , pushing records similar header array ( var j in results.data ) { //the current data point var currentdatapoint = results.data[j][name]; //making sure data point integer, not string currentdatapoint = parseint( currentdatapoint ); //pushing data point 'data' array of current series chartconfigoptions.series[i].data.push( currentdatapoint ); } } //finally, nitializing chart $( '#climate_data' ).highcharts( chartconfigoptions ); } }); }); })();
Comments
Post a Comment