javascript - HighCharts Loading from CSV File with Many Data Points -


after searching , wanting bang head against desk, i'm posting first question on stackoverflow.

i've got asp.net web application generating data on server side , creating csv file on server.

i'm using highcharts produce graph. working great, however, depending on kind of date range user runs there can few data points or many data points.

the problem comes in when there many data points. @ x-axis, , you'll see mean. there anyway "group" these doesn't show every single point on x-axis?

the dates @ random intervals.

i've created jsfiddle client side code , contents of csv file in javascript variable.

here code:

function parsedate(datestr) {     var matches = datestr.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/)     return date.utc(matches[3], matches[1]-1, matches[2]); }  var csv = 'chart,3/4/2007,3/24/2007,4/13/2007,4/25/2007,9/19/2007,9/28/2007,11/5/2007,1/7/2008,1/14/2008,1/21/2008,1/27/2008,2/3/2008,2/10/2008,2/17/2008,2/24/2008,3/2/2008,3/23/2008,3/30/2008,4/5/2008,4/21/2008,5/3/2008,5/10/2008,5/17/2008,5/24/2008,5/31/2008,6/8/2008,6/15/2008,6/29/2008,7/4/2008,7/18/2008,7/25/2008,8/1/2008,8/8/2008,9/17/2010,11/25/2010,8/16/2012,1/17/2013,1/27/2013\ndates,180.00,175.50,167.00,166.50,170.00,171.50,174.00,163.00,162.50,164.00,166.50,166.50,167.50,170.00,170.00,171.00,169.00,166.50,166.00,166.50,162.00,160.00,160.50,162.50,164.00,164.00,165.00,165.50,166.00,169.00,171.00,170.00,171.00,165.00,165.00,189.00,177.00,175.50';  var options = {         chart: {             renderto: 'chart',             defaultseriestype: 'line'         },         title: {             text: 'test chart'         },         xaxis: {            type: 'datetime',             categories: []         },         yaxis: {             title: {                 text: 'pounds'             }         },         series: []     };     // split lines         var lines = csv.split('\n');         $.each(lines, function(lineno, line) {             var items = line.split(',');             if (lineno == 0) {                 $.each(items, function(itemno, item) {                     if (itemno > 0) options.xaxis.categories.push(parsedate(item));                 });             }             else {                 var series = {                      data: []                 };                 $.each(items, function(itemno, item) {                     if (itemno == 0) {                         series.name = item;                     } else {                         series.data.push(parsefloat(item));                     }                 });                 options.series.push(series);             }         });          var chart = new highcharts.chart(options); 

here link jsfiddle:

http://jsfiddle.net/q2hyf/6/

thanks in advance,

robert

check out highstocks , datagrouping feature:

http://www.highcharts.com/stock/demo/data-grouping

it can handle larger datasets highcharts can. however, there drawbacks newest highcharts features not in highstocks. there minor changes needed syntax use highstocks, if want test it.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -