With annotations
author(s): Torstein Hønsi
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/annotations.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.src.js"></script>
<div id="container"></div>
JavaScript
Highcharts.AST.allowedAttributes.push('filter');
Highcharts.AST.allowedAttributes.push('stroke-opacity');
// Data generated from http://www.bikeforums.net/professional-cycling-fans/1113087-2017-tour-de-france-gpx-tcx-files.html
const elevationData = [
[0.0, 225],
[4.0, 191],
[10.0, 192],
[14.0, 214],
[20.0, 224],
[24.0, 228],
[30.0, 287],
[34.0, 459],
[40.0, 563],
[44.0, 573],
[50.0, 564],
[54.0, 520],
[60.0, 579],
[64.0, 629],
[70.0, 618],
[74.0, 596],
[80.0, 737],
[84.0, 780],
[90.0, 679],
[94.0, 694],
[100.0, 976],
[104.0, 933],
[110.0, 939],
[114.0, 770],
[120.0, 602],
[124.0, 466],
[130.0, 348],
[134.0, 513],
[140.0, 755],
[144.0, 780],
[150.0, 630],
[154.0, 676],
[160.0, 417],
[164.0, 426],
[170.0, 821],
[174.0, 1098],
[180.0, 1153],
[184.0, 1135]
];
// Now create the chart
const chart = Highcharts.chart('container', {
annotations: [{
shapes: [{
type: 'path',
fill: 'red',
strokeWidth: 3,
stroke: 'green',
points: [{
x: 25,
xAxis: 0,
y: 500,
yAxis: 0
}, {
x: 50,
xAxis: 0,
y: 500,
yAxis: 0
}, {
x: 50,
xAxis: 0,
y: 1000,
yAxis: 0
}, {
x: 25,
xAxis: 0,
y: 1000,
yAxis: 0
}, {
x: 25,
xAxis: 0,
y: 500,
yAxis: 0
}]
}]
}],
series: [{
data: elevationData,
}]
});