Disable specific labels in Highcharts

972 views Asked by At

I tryed to disable some specific labels in a column charts in Highcharts. But i only can disable all labels or non. I search a bit in the internet and found commands like "labels"->"enabled" or "visible", but it won´t work. This is my code for a bar, where i want to disable the label.

{
  "color":"#ffff77",
  "x":"0.7",
  "pointWidth":"7",
  "labels":{
    "enabled":false
      },
  "dataLabels":{
    "enabled": false
  }    
}

My question is, if it is possible to disable just specific labels. PS: I use Highcharts in Grafana.

1

There are 1 answers

11
Sebastian Wędzel On BEST ANSWER

I assumed that you are asking about the dataLabels - so each label could be disabled inside the data array where specific point is defined.

Demo: https://jsfiddle.net/BlackLabel/9zdc2pnu/

Highcharts.chart('container', {

  series: [{
    data: [43934, 52503, 57177, {
      y: 69658,
      dataLabels: {
        enabled: false
      }
    }, 97031, 119931, 137133, 154175],
    dataLabels: {
      enabled: true
    }
  }]
});

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


EDIT

After getting more information - to disable specific labels for axis you can use the labels.formatter callback or find and hide the specific label in the render callback.

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

API: https://api.highcharts.com/highcharts/yAxis.labels.formatter

API: https://api.highcharts.com/highcharts/chart.events.render