I've got a chart with two series. I want to toggle the dataLabels of the series by clicking a button.
changeDatalabel(): void {
if (!this.dataLabelEnabled) { // global Var
this.chart.ref.series[0].update({ dataLabels: { enabled: true } }); // Compile error
this.dataLabelEnabled = true; // for toggling
} else {
this.chart.ref.series[0].update({ dataLabels: { enabled: false } }); // Compile error
this.dataLabelEnabled = false; // for toggling
}
The problem is that the updateMethod get a compile error when I insert "dataLabels: {enable: true}" and he is jumping out of the method "changeDatalabel()".
When i got two buttons with the updateMethod the compile error turn up again but it works.
createLabel(): void {
this.chart.ref.series[0].update({ dataLabels: { enabled: true } });
deleteLabel(): void {
this.chart.ref.series[0].update({ dataLabels: { enabled: false } });