Reputation: 1115
I have a chart in which I combine a stacked column chart with a stacked line chart. I would like to have stackLabels for the column chart only, and suppress the stackLabels for the stacked line chart.
How can I achieve stack labels ONLY on the column chart?
Also see https://jsfiddle.net/o1bqwu7r/4/ or :
Highcharts.chart('container', {
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
stackLabels: {
enabled: true
}
},
plotOptions: {
series: {
stacking: 'normal'
},
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
type: 'column'
}, {
data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2],
type: 'column'
}, {
data: [2.9, 7.5, 16.4, 12.2, 14.0, 17.0, 13.6, 14.5, 21.4, 19.1, 9.6, 5.4],
type: 'line'
}, {
data: [14.0, 17.0, 13.6, 14.5, 21.4, 19.1, 9.6, 5.4, 2.9, 7.5, 10.4, 12.2],
type: 'line'
},]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
Upvotes: 1
Views: 239
Reputation: 39069
You can add a separate yAxis
for the line series:
yAxis: [{
stackLabels: {
enabled: true
}
}, {
linkedTo: 0,
visible: false
}],
series: [{
data: [...],
type: 'column'
}, {
data: [...],
type: 'column'
}, {
yAxis: 1,
data: [...],
type: 'line'
}, {
yAxis: 1,
data: [...],
type: 'line'
}]
Live demo: https://jsfiddle.net/BlackLabel/1ojnakzw/1/
API Reference: https://api.highcharts.com/highcharts/yAxis
Upvotes: 2