amcharts3-angular2 icon indicating copy to clipboard operation
amcharts3-angular2 copied to clipboard

Chart balloon not update using updateChart on amChartsService

Open MohamedChaabouni opened this issue 6 years ago • 3 comments

I working on updating all chart properties using amcharts angular 5. I changed successfully properties such as backgroundColor ect.. using amChartsService but on working with balloons the balloon color and background color aren't changing. I used to destroy the chart and re-create it, but it's not the best way to do it. I believe that there is a better way to do it there's my code.

this.amChartsService.updateChart(this.currentChart, () => { this.currentChart['balloon']['color'] = value; }); on the console.log(this.currentChart.balloon.color); the value already been changed but not in the chart.

Why i'm getting this ? is it a bugg that should be reported or I'm doing something wrong ??

Thanks.

MohamedChaabouni avatar May 09 '18 13:05 MohamedChaabouni

I'd say the code looks fine, where are you placing it?

Have a look at this example based on your code:

` ngAfterViewInit() { this.chart = this.amChartsService.makeChart('chartdiv', { …. });

this.amChartsService.updateChart(this.chart, () => { this.chart['balloon']['color'] = 'blue'; }); } `

shreddison avatar May 09 '18 22:05 shreddison

This is exactly what i'm doing and the color in the object is changing but not in the chart for other properties the chart is updated but not for the balloon properties that's quite strange

MohamedChaabouni avatar May 09 '18 22:05 MohamedChaabouni

New comment from Zendesk by Anthony Piris on ticket 34046. (replying here will automatically notify amCharts support agent)

Hi there,

Do you happen to have a chart cursor enabled? This might be due to a bug within the chart library itself. If you have a chart cursor enabled, updating the balloon through the global balloon property (this.chart.balloon.color = ...;) doesn't work, however if you update the balloon object inside the graph object(s), the update will work, i.e.

ngAfterViewInit() {
  // ...
  this.AmCharts.updateChart(this.chart, () => {
    this.chart.graphs[0].balloon.color = 'blue';
  });
}

Let me know if that helps.

Best,

Anthony Piris amCharts

amcharts avatar May 12 '18 01:05 amcharts