javascript - HighChart Line Graph not Showing -


i using data csv file generate line graph using highchart. here code:

            /* define initial , basic options */             var options = {                 chart: {                     type: 'line',                     renderto: 'graph_container'                 },                  title: {                     text: 'fanniemaeacquisition cash flow'                 },                  yaxis: {                     title: {                         text: 'amount($)'                     }                 },                 series: []            };              /* parse csv file */              $.get('{% static "data/fanniemaeacquisitions.csv" %}', function(csv) {                 var lines = csv.split('\n');                 var series = {                     name: '',                     data: []                 };                 $.each(lines, function (lineno, line) {                     var items = line.split(',');                  $.each(items, function (itemno, item) {                         if(itemno == 1){                             if (lineno == 0){                                 series.name = item;                             } else {                                 series.data.push(parsefloat(item));                             }                         }                     });                 });                 options.series.push(series);                 console.log(options.series);             });             // create chart             var chart = new highcharts.chart(options); 

however isn't working. tried testing manually inputting data so:

                 series: [{                      name: 'installation',                      data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]                  }, 

and works fine. took @ variables being passed series. 1 works(manual input):

enter image description here

the 1 doesn't work(from csv):

enter image description here

any ideas?

edit: okay. weird going on here. highchart isn't showing on webpage showing when download png. weirder part shows on webpage if manually add in number values when extract values form csv graph disappears... when download png shows graph...any ideas??

second edit: okay, when do: console.log(json.stringify(options.series[0].data)); nothing shows up. mean values parsed csv file appear after graph generated. how fix this? lol

the problem due javascript's asynchronous issues. wrapped function in $.when , worked!


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -