ng-apexcharts icon indicating copy to clipboard operation
ng-apexcharts copied to clipboard

Unable to update options(XAxis, YAxis) whenever the data is changed.

Open vgogineni2 opened this issue 4 years ago • 1 comments

Hello,

I am unable to update any of the chart options dynamically except "series" as mentioned in https://apexcharts.com/docs/angular-charts/

I am trying to get the chart object like below, but getting it as undefined. One way is to call "updateOptions" on the chart component which is undefined in my case.

@ViewChild("mainchart") mainchartcomponent: ChartComponent;

Any help is highly appreciated.

Thanks, Vamsi.

vgogineni2 avatar Jan 09 '21 19:01 vgogineni2

I managed to get access to the Chart component by adding a template reference to the apx-chart component

<apx-chart #apexChart><apx-chart>

then in ngAfterViewInit you can get access to the Chart component like so

@ViewChild('apexChart') apexChart:any;

ngAfterViewInit():void { if( typeof this.apexChart !== 'undefined'){ this.chart = this.apexChart as ChartComponent; }}

but that didn't help much actually...

My solution was to format the series object as numeric paired values in XY properties, basically forgetting about trying to update xaxis ( in my case ), since the series object updates without any issues

psegarel avatar Sep 10 '21 01:09 psegarel