Area range and line

author(s): Torstein Hønsi

by Guillaume Seguin

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 = [
        [13.7, 25.6],
        [13.3, 21.8],
        [11.2, 19.9],
        [7.9, 17.3],
        [4.9, 20.6],
        [5.1, 16.8],
        [9.3, 21.1],
        [11.1, 20.5],
        [8.9, 18.4],
        [4.6, 23.2],
        [11.5, 26.0],
        [8.6, 23.4],
        [9.8, 22.2],
        [8.1, 18.2],
        [5.9, 20.2],
        [4.5, 20.2],
        [8.9, 19.8],
        [11.1, 22.1],
        [7.9, 26.7],
        [15.9, 28.6],
        [14.9, 27.5],
        [9.5, 26.0],
        [11.5, 22.4],
        [8.6, 21.1],
        [12.9, 21.7],
        [13.6, 20.9]

    ],
    ranges2 = [
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [null, null],
        [9.6, 23.9],
        [8.6, 22.7],
        [7.5, 25.7],
        [5.5, 24.3],
        [10.4, 21.2]

    ],
    averages = [
        [18.1],
        [17.1],
        [15.2],
        [12.7],
        [13.3],
        [10.6],
        [15.6],
        [16.1],
        [14.0],
        [15.3],
        [17.5],
        [17.5],
        [15.3],
        [13.9],
        [13.7],
        [13.8],
        [14.0],
        [15.8],
        [18.6],
        [21.5],
        [19.8],
        [17.6],
        [16.8],
        [15.6],
        [16.7],
        [16.3],
        [17.2],
        [16.0],
        [16.9],
        [16.1],
        [14.5]
    ];


Highcharts.chart('container', {

    title: {
        text: 'July temperatures in Nesbyen, 2022',
        align: 'left'
    },

    subtitle: {
        text: 'Source: ' +
            '<a...