Highcharts. Can data labels be programmatically displayed?
According to this my question, I can show / hide datalabels by clicking on a dot. But in this example dataLabels enabled
show is set by default true
, otherwise I cannot show them. Nothing happens when I click on the dot.
point: {
events: {
click: function() {
// on first click this.dataLabels is undefined...
var e = !this.dataLabels || this.dataLabels.enabled ? false : true;
this.update({
dataLabels: {
enabled: e
}
});
}
}
}
This code only works fine if I set
dataLabels: {
enabled: true
}
Thanks for the help.
+3
Daria
source
to share
1 answer
Just change the condition to:
click: function(){
var e = !this.dataLabels || !this.dataLabels.enabled ? true : false;
this.update({
dataLabels:{
enabled: e
}
});
}
Demo: http://jsfiddle.net/7wLxwfq6/2/
+1
Paweł Fus
source
to share