Highcharts - redraw() vs. new Highcharts.chart Highcharts - redraw() vs. new Highcharts.chart javascript javascript

Highcharts - redraw() vs. new Highcharts.chart


chart.series[0].setData(data,true);

The setData method itself will call the redraw method


you have to call set and add functions on chart object before calling redraw.

chart.xAxis[0].setCategories([2,4,5,6,7], false);chart.addSeries({    name: "acx",    data: [4,5,6,7,8]}, false);chart.redraw();


var newData = [1,2,3,4,5,6,7];var chart = $('#chartjs').highcharts();chart.series[0].setData(newData, true);

Explanation:
Variable newData contains value that want to update in chart. Variable chart is an object of a chart. setData is a method provided by highchart to update data.

Method setData contains two parameters, in first parameter we need to pass new value as array and second param is Boolean value. If true then chart updates itself and if false then we have to use redraw() method to update chart (i.e chart.redraw();)

http://jsfiddle.net/NxEnH/8/