Highcharts example
Adding new series data to chart
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container1" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
JavaScript
var options1 = {
chart: {
renderTo: 'container1'
},
series: []
};
var drawChart = function (data, name) {
// 'series' is an array of objects with keys: 'name' (string) and 'data' (array)
var newSeriesData = {
name: name,
data: data
};
// Add the new data to the series array
options1.series.push(newSeriesData);
console.log(options1.series)
// If you want to remove old series data, you can do that here too
// Render the chart
var chart = new Highcharts.Chart(options1);
};
var data = [];
// we get new data
data = [1, 2, 3, 4, 5];
drawChart(data, 'Tokyo');
// we get new data
data = [10, 11, 12, 13, 14];
drawChart(data, 'Sydney');