Area range and line
author(s): Torstein Hønsi
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Chart demonstrating using an arearange series in combination with a line
series. In this case, the arearange series is used to visualize the
temperature range per day, while the line series shows the average
temperature.
</p>
</figure>
CSS
#container {
height: 400px;
}
.highcharts-figure,
.highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
.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
const ranges = [
[Date.UTC(2023, 1, 1), 13.7, 25.6],
[Date.UTC(2023, 2, 1), 13.3, 21.8],
[Date.UTC(2023, 3, 1), 11.2, 19.9],
[Date.UTC(2023, 4, 1), 7.9, 17.3],
[Date.UTC(2023, 5, 1), 4.9, 20.6],
[Date.UTC(2023, 6, 1), 5.1, 16.8],
[Date.UTC(2023, 7, 1), 9.3, 21.1],
[Date.UTC(2023, 8, 1), 11.1, 20.5],
[Date.UTC(2023, 9, 1), 8.9, 18.4],
[Date.UTC(2023, 10, 1), 4.6, 23.2],
[Date.UTC(2023, 11, 1), 11.5, 26.0],
[Date.UTC(2023, 12, 1), 8.6, 23.4],
[Date.UTC(2024, 1, 1), 9.8, 22.2],
[Date.UTC(2024, 2, 1), 8.1, 18.2],
[Date.UTC(2024, 3, 1), 5.9, 20.2],
[Date.UTC(2024, 4, 1), 4.5, 20.2],
[Date.UTC(2024, 5, 1), 8.9, 19.8],
[Date.UTC(2024, 6, 1), 11.1, 22.1],
[Date.UTC(2024, 7, 1), 7.9, 26.7],
[Date.UTC(2024, 8, 1), 15.9, 28.6],
[Date.UTC(2024, 9, 1), 14.9, 27.5],
[Date.UTC(2024, 10, 1), 9.5, 26.0],
[Date.UTC(2024, 11, 1), 11.5, 22.4],
[Date.UTC(2024, 12, 1), 8.6, 21.1],
[Date.UTC(2025, 1, 1), 12.9, 21.7],
[Date.UTC(2025, 2, 1), 13.6, 20.9]
],
ranges2 = [
[Date.UTC(2025, 2, 1), 13.6, 20.9],
[Date.UTC(2025, 3, 1), 9.6, 23.9],
[Date.UTC(2025, 4, 1), 8.6, 22.7],
[Date.UTC(2025, 5, 1), 7.5, 25.7],
[Date.UTC(2025, 6, 1), 5.5, 24.3],
[Date.UTC(2025, 7, 1), 10.4, 21.2]
],
averages = [
[Date.UTC(2023, 1, 1), 18.1],
[Date.UTC(2023, 2, 1), 17.1],
[Date.UTC(2023, 3, 1), 15.2],
[Date.UTC(2023, 4, 1), 12.7],
[Date.UTC(2023, 5, 1), 13.3],
[Date.UTC(2023, 6, 1), 10.6],
[Date.UTC(2023, 7, 1), 15.6],
[Date.UTC(2023, 8, 1), 16.1],
[Date.UTC(2023, 9, 1), 14.0],
[Date.UTC(2023, 10, 1), 15.3],
[Date.UTC(2023, 11, 1), 17.5],
[Date.UTC(2023, 12, 1), 17.5],
[Date.UTC(2024, 1, 1), 15.3],
[Date.UTC(2024, 2, 1), 13.9],
...