With annotations
author(s): Torstein Hønsi
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/accessibility.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>
<div id="container"></div>
CSS
#container,
.highcharts-data-table table {
min-width: 350px;
max-width: 800px;
margin: 1em auto;
}
#container {
height: 450px;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
JavaScript
// 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
Highcharts.chart('container', {
chart: {
type: 'area',
zoomType: 'x',
panning: true,
panKey: 'shift'
},
title: {
text: 'Example of issue with PDF offline exporting',
},
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,
}]
});