Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/drag-panes.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px"></div>
JavaScript
$.getJSON('https://www.highcharts.com/samples/data/aapl-ohlcv.json', function (data) {
// split the data set into ohlc and volume
var ohlc = [],
ohlc2 = [],
volume = [],
volume2 = [],
dataLength = data.length,
// set the allowed units for data grouping
groupingUnits = [[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]],
i = 0;
for (i; i < dataLength; i += 1) {
ohlc.push([
data[i][0], // the date
data[i][1], // open
data[i][2], // high
data[i][3], // low
data[i][4] // close
]);
ohlc2.push([
data[i][0], // the date
data[i][1] + Math.floor((Math.random() * 10) + 1), // open
data[i][2], // high
data[i][3], // low
data[i][4] // close
]);
volume.push([
data[i][0], // the date
data[i][5] // the volume
]);
volume2.push([
data[i][0], // the date
data[i][5] + Math.floor((Math.random() * 10) + 1) // the volume
]);
}
// create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 0
},
title: {
text: 'AAPL Historical'
},
yAxis: [{
labels: {
align: '',
x: 30
},
title: {
text: 'Series 1'
},
height: '65%',
lineWidth: 1,
resize: {
enabled: true
}
},{
labels: {
align: '',
x: 20
},
title: {
text: 'series 2'
},
height: '65%',
lineWidth: 1,
resize: {
...