Avoid showing duplicate stack labels on the every column series in a. highcharts

396 views Asked by At

I am using high-charts to render a stacked grouped high-charts as below. https://jsfiddle.net/4tojbfsq/1/

I'm able to get the total count of all the datalabels at the top and I also want to render a stack label on the x axis like a dual x-axis as shown in the above fiddle however my problem is I'm able to show the stacklabels on x-axis however I also see the same stack label duplicated for every stacked series.

enter image description here

is there any way I can just show the stack label at the bottom of the all the series and not repeat anywhere inside the stacked series.

code:

 yAxis: {
          allowDecimals: false,
          //offset:10,
          title: {
            text: 'Number of fruits'
          },
          stackLabels: {
          enabled: true,
            verticalAlign: 'top',
            formatter: function() {
            return this.total;
            },
          }

        },

        plotOptions: {
          column: {
            stacking: 'normal'
          },
          series: {
           dataLabels: {
            enabled: true,
            verticalAlign: 'bottom',
            
            overflow: 'none',
            crop: false,
            y: 20,
            formatter() {
              return this.series.userOptions.stack;
            }
          }
          }
        },

        series: [{
          name: 'John',
          data: [53, 33, 43,63,7,83],
          stack: 'malssses'
        }, {
          name: 'Joe',
          data: [33, 43,43,63,73,8],
          stack: 'female'
        }, {
          name: 'Jane',
          data: [42, 54,43,62,74,84],
          stack: 'malssses',
        
        }, {
          name: 'Janet',
          data: [34, 40, 42,36,74,83],
          stack: 'female',
        }]
1

There are 1 answers

0
Sebastian Wędzel On BEST ANSWER

The duplicate labels are not a stacklabels, but the dataLabels. You can display the dataLabels only for the particular series:

   {
              name: 'Jane',
              data: [42, 54, 43, 62, 74, 84],
              stack: 'malssses',
              dataLabels: {
                enabled: true,
                verticalAlign: 'bottom',
                overflow: 'none',
                crop: false,
                y: 20,
                formatter() {
                  return this.series.userOptions.stack;
                }
              }
    
            }, {
              name: 'Janet',
              data: [34, 40, 42, 36, 74, 83],
              stack: 'female',
              dataLabels: {
                enabled: true,
                verticalAlign: 'bottom',
                overflow: 'none',
                crop: false,
                y: 20,
                formatter() {
                  return this.series.userOptions.stack;
                }
              }
            }

Demo: https://jsfiddle.net/BlackLabel/t3sheqbu/

API: https://api.highcharts.com/highcharts/series.line.dataLabels