HighCharts stack totals on top for percent stackin

2019-08-02 19:35发布

问题:

I'm displaying a stacked percent column chart. I want the total to be displayed on top. I added following to YAxis:

stackLabels: {
    enabled: true, // This is ignored <<<<<<
    style: {
      fontWeight: 'bold',
      color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
    }
}

But this works only if the stacking is not "percent". How can I achieve what I want (showing total on top of the stacked column?

The code can be checked at : http://jsfiddle.net/Bzs2k/1/

回答1:

Actually the stackLabels option is working, but there is not enough room for the labels at the top of the plot. Add this to the yAxis to pad some space:

yAxis: {
    min: 0,
    max: 105,
    endOnTick: false,
    etc...

Updated fiddle here.



回答2:

You can also set y value as positive value.

stackLabels: {
                 y:10,
                enabled: true, // This is ignored <<<<<<
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
}

http://jsfiddle.net/Bzs2k/4/