highcharts - Updating basic column high chart -
i having problem updating basic column high chart.
my json array returned server is:
[{"name":"positive","data":[18,35,32,38]},{"name":"negative","data":[0,14,65,121]}]
i using "data"
arrays ^ i.e. jsonarr[0].data
, jsonarr[1].data
i have info set correctly, chart not depicting these values. ideas?
here javascript:
class="lang-javascript prettyprint-override"> $(document).ready(function() { var twitterchart; posarr = []; negarr = []; function rendergraph() { $.getjson("frontcontroller", function(jsonarr, statustxt, xhr){ console.log("data returned : " + data);*/ posarr = jsonarr[0].data; negarr = jsonarr[1].data; console.log("posarr: " + posarr); console.log("negarr: " + negarr); twitterchart.series[0].data = posarr; twitterchart.series[1].data = negarr; }); settimeout(rendergraph, 3000) } twitterchart = new highcharts.chart({ chart: { renderto: 'container1', type: 'column' }, title: { text: '' }, subtitle: { text: ':' }, xaxis: { categories: [ 'column 1', 'column 2', 'column 3', 'column 4' ] }, yaxis: { min: 0, title: { text: 'testing"' } }, legend: { layout: 'vertical', backgroundcolor: '#ffffff', align: 'left', verticalalign: 'top', x: 100, y: 70, floating: true, shadow: true }, tooltip: { formatter: function() { homecoming ''+ this.x +': '+ this.y +' tweets'; } }, plotoptions: { column: { pointpadding: 0.2, borderwidth: 0 } }, series: [{ name: 'positive', data: posarr }, { name: 'negative', data: negarr }] }); rendergraph(); }); </script>
to update series info utilize twitterchart.series[0].setdata(array); see: http://api.highcharts.com/highcharts#series.setdata()
highcharts
No comments:
Post a Comment