Skip to content

Instantly share code, notes, and snippets.

@samarthagarwal
Last active February 5, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samarthagarwal/971193cdf0d3f97e39759f769fc996d4 to your computer and use it in GitHub Desktop.
Save samarthagarwal/971193cdf0d3f97e39759f769fc996d4 to your computer and use it in GitHub Desktop.
Dynamic Charts using HighCharts
var dataset1 = [];
var dataset2 = [];
for (var i = 0; i < 16; i++) {
dataset1.push(Math.floor(Math.random() * 10 + 1));
dataset2.push(Math.floor(Math.random() * 10 + 1));
}
var myChart = Highcharts.chart("container", {
chart: {
type: "spline"
},
title: {
text: "Crypto - Rates"
},
yAxis: {
title: {
text: "Currency Rates"
}
},
series: [
{
name: "Bitcoin",
data: dataset1
},
{
name: "Ether",
data: dataset2,
dashStyle: "dot"
}
]
});
var index = 0;
setInterval(() => {
myChart.series[0].addPoint(Math.floor(Math.random() * 10 + 1), false, true);
myChart.series[1].addPoint(Math.floor(Math.random() * 10 + 1), true, true);
index++;
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment