OHLC
author(s):
Torstein Hønsi
by Torstein Hønsi
HTML
<script src="https://code.highcharts.com/stock/13.1.1/highstock.js"></script>
<div id="container"></div>
CSS
body {
background: var(--highcharts-background-color);
color: var(--highcharts-neutral-color-100);
}
#container {
height: 400px;
width: 800px;
}
JavaScript
(async () => {
// Load the dataset
const data = await fetch(
'https://demo-live-data.highcharts.com/aapl-ohlc.json'
).then(response => response.json());
// create the chart
const chart = Highcharts.stockChart('container', {
rangeSelector: {
selected: 0
},
title: {
text: 'AAPL Stock Price'
},
series: [{
type: 'ohlc',
name: 'AAPL Stock Price',
data: data,
dataGrouping: {
units: [[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]]
}
}]
});
setTimeout(() => {
chart.xAxis[0].setExtremes(
'2026-08-27'
)
}, 1234)
})();