Last active
February 5, 2018 09:42
-
-
Save samarthagarwal/971193cdf0d3f97e39759f769fc996d4 to your computer and use it in GitHub Desktop.
Dynamic Charts using HighCharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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