Highcharts Demo
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/exporting.js"></script>
<div id="container"></div>
CSS
@import 'https://code.highcharts.com/css/highcharts.css';
.highcharts-axis-title {
width: 200px;
white-space: normal !important;
}
#container {
height: 400px;
max-width: 800px;
margin: 0 auto;
}
.highcharts-plot-band-label {
font-size: 30px;
}
JavaScript
(function(H) {
H.wrap(H.PlotLineOrBand.prototype, 'render', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, ));
const label = this.label;
if (label) {
label.css({
lineHeight: label.alignOptions.style.lineHeight
})
}
});
}(Highcharts));
Highcharts.chart('container', {
chart: {
styledMode: true,
type: 'line'
},
title: {
text: 'How to control line heigh for plot band label without using useHTML?'
},
xAxis: {
plotBands: {
from: 1,
to: 2,
label: {
text: 'test <br>label',
y: 30,
style: {
lineHeight: 30
}
}
}
},
series: [{
data: [1, 3, 2, 4]
}, {
data: [324, 124, 547, 221],
}]
});