ng-apexcharts
ng-apexcharts copied to clipboard
Unable to update options(XAxis, YAxis) whenever the data is changed.
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.
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