Highcharts.getJSON('https://www.highcharts.com/samples/data/aapl-ohlcv.json', function(data) {
// split the data set into ohlc and volume
var ohlc = [],
volume = [],
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;
var minValue = 0,
maxValue = 0,
high,
low;
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
]);
high = data[i][2];
low = data[i][3];
minValue = minValue == 0 ? low : minValue
//measuring high and low values of OHLC data!
if (high > maxValue) {
maxValue = high;
}
if (low < minValue) {
minValue = low;
}
volume.push([
data[i][0], // the date
data[i][5] // the volume
]);
}
// create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Historical'
},
yAxis: [{
plotBands: [{
from: minValue,
to: maxValue,
color: '#5cdbdb',
label: {
text: 'separate color for the price and volume'
}
}],
labels: {
align: 'right',
x: -3
},
title: {
text: 'OHLC'
},
height: '60%',
lineWidth: 2,
}, {
labels: {
align: 'right',
x: -3
},
title: {
text: 'Volume'
},
top: '65%',
height: '35%',
offset: 2,
lineWidth: 2
}],
tooltip: {
split: true
},
series: [{
type: 'candlestick',
name: 'AAPL',
data: ohlc,
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
dataGrouping: {
units: groupingUnits
}
}]
});
});
.highcharts-plot-border {
stroke-width: 2px;
stroke: #00b5ec;
}
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/data.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>