Reputation: 569
i have made a chart using highcharts, and i want to redraw my high chart, but this line of code is confusing me and not allowing me to add existing data. this adds random data, but what i want is to add data from the javascript...
// Add the new series.
chart.addSeries({ data: Highcharts.map(Array(12), Math.random) }, false);
other code:
$(".test").change(function() {
var value = this.getAttribute("value");
while (chart.series.length > 0) {
chart.series[0].remove(true);
}
if (value == 'a') {
loadA(chart);
} else if (value == 'b') {
chart.xAxis[0].update({categories: ['Sun', 'Mon', 'Tue']});
chart.addSeries({
name: 'Rainfall4',
type: 'column',
color: '#FF00FF',
data:[100, 280, 300, 490, 670, 900]
});
chart.yAxis[0].setTitle({ text: "Raw" });
} else if (value == 'c') {
chart.xAxis[0].update({categories: ['Oranges', 'Pears', 'Pinneaples', 'other']});
this is the Jsfiddle:
want something like
chart.series[0].setData([129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4] );
});
Upvotes: 2
Views: 3295
Reputation: 646
this is what you need
function redraw(chart) {
// Delete all the series.
/*
while (chart.series.length > 0) {
chart.series[0].remove(false);
}
*/
// Add the new series.
chart.series[0].setData([129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4]);
chart.redraw();
Upvotes: 3