Flags shapes and colors
author(s): Torstein Hønsi
by Umair Rafiq
HTML
<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/exporting.js"></script>
<div id="container" style="height: 400px"></div>
JavaScript
Highcharts.getJSON('https://cdn.jsdelivr.net/gh/highcharts/[email protected]/samples/data/usdeur.json', function (data) {
var year = new Date(data[data.length - 1][0]).getFullYear(); // Get year of last data point
// Create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 4
},
title: {
text: 'USD to EUR exchange rate'
},
yAxis: {
title: {
text: 'Exchange rate'
}
},
series: [{
name: 'USD to EUR',
data: data,
id: 'dataseries',
tooltip: {
valueDecimals: 4
}
}, {
type: 'flags',
data: [{
x: Date.UTC(year, 1, 22),
title: 'K',
}, {
x: Date.UTC(year, 3, 28),
title: 'Q',
text: 'Shape: "squarepin"'
}],
onSeries: 'dataseries',
shape: 'squarepin',
width: 16
}, {
type: 'flags',
data: [{
x: Date.UTC(year, 2, 1),
title: 'B',
text: 'Shape: "circlepin"'
}, {
x: Date.UTC(year, 3, 1),
title: '8K',
text: 'Shape: "circlepin"'
}],
shape: 'circlepin',
width: 16
}, {
type: 'flags',
data: [{
x: Date.UTC(year, 2, 10),
title: 'EC',
text: 'Shape: "flag"'
}, {
x: Date.UTC(year, 3, 11),
title: 'EC',
text: 'Shape: "flag"'
}],
color: Highcharts.getOptions().colors[0], // same as onSeries
fillColor: Highcharts.getOptions().colors[0],
onSeries: 'dataseries',
width: 16,
style: { // text style
...