Dual axes, line and column
author(s): Torstein Hønsi
by joshkrz
HTML
<script src="https://code.highcharts.com/highcharts.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 showing a combination of a column and a line chart, using multiple
y-axes. Using multiple axes allows for data within different ranges to
be visualized together.
</p>
</figure>
CSS
.highcharts-figure, .highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
#container {
height: 400px;
}
.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
Highcharts.chart('container', {
chart: {
backgroundColor: 'transparent',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
// type: 'spline',
// type: 'areaspline',
margin: 0,
},
title: null,
legend: {
enabled: false,
},
tooltip: {
enabled: false,
},
xAxis: {
type: 'datetime',
gridLineColor: 'transparent',
visible: false,
minPadding: 0,
maxPadding: 0,
},
yAxis: [{
gridLineColor: 'transparent',
visible: true,
},
{
gridLineColor: 'transparent',
visible: true,
opposite: true,
}],
credits: {
enabled: false,
},
plotOptions: {
spline: {
lineWidth: 2,
},
areaspline: {
stacking: 'normal',
fillOpacity: 0.2,
lineWidth: 2,
},
series: {
marker: {
enabled: false,
},
},
},
series: [{"name":"Avg Response Time","type":"areaspline","yAxis":0,"color":"#7ed78d","fillColor":{"linearGradient":{"x1":0,"x2":0,"y1":0,"y2":1},"stops":[[0,"rgb(126, 215, 141,0.1)"],[1,"rgb(126, 215, 141,0)"]]},"data":[[1631283240000,2000],[1631283180000,1909],[1631283120000,1992]]},{"name":"Errors","type":"column","yAxis":1,"color":"#d96a62","data":[[1631283240000,7],[1631283180000,500],[1631283120000,2]]}]
});