Closed DavidMarquezF closed 2 years ago
Hey, thanks for your contribution!
To answer your first question, yes, updateSeries
, addSeries
in ApexCharts context trigger a re-render themselves.
And to answer your second question, we need to only know if the reference provided to the chart component changed to trigger a re-render.
Perfect, then this pull-request should be complete now. We now run all the functions outside the angular zone and since we only care about an input reference change, I set the strategy to OnPush. In theory everything should still work without any issues and with much better performance, closer to the one of the native apexcharts.js
Any idea of when this could be released @junedchhipa ?
In order to do the "magic" of change detection, angular uses zone.js. This patches a lot of functions, like hover, requestAnimationFrame and others and tells angular to rerun changeDetection.
Right now the chart runs inside the angular zone which means that all requestAnimationFrame, hover for tooltips, clicks, etc. will trigger change detection. I don't think they should as this causes a big hit in performance for something that is not really needed since apexchart.js already runs without angular intervention.
To get an idea, see the console output, which says how many change detection cycles have ran:
Prior to this change, pressing the button add series:
After this change:
![Screenshot_1](https://user-images.githubusercontent.com/32216320/155773149-71cf4c5e-1218-488f-b532-718e4966f83f.png)
To solve this I run the rendering of the chart outside of the angular zone which means that it will not detect these calls.
However I am not sure of the following: