New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ngx-Echarts Animation not working Initially #413
Comments
@KrisnaPrashatt option: EChartsOption = {}
ngAfterViewInit()
{
setTimeout(() => {
this.option = {
// options and series...
};
);
} |
@xieziyu , Thank you for your response but that did not work. But what did work, is the addition of |
This is a bug with [autoResize]. ResizeObserver is immediately called on init (as per spec) which then calls resize(). resize() defaults animation to none. The following fixes need to be made to source (or something like it): private resizeObFired: boolean = false;
ngOnInit() {
...
if (this.autoResize) {
this.resizeOb = this.ngZone.runOutsideAngular(() => new window.ResizeObserver((entries) => {
for (const entry of entries) {
if (entry.target === this.el.nativeElement) {
// Ignore first fire on insertion, no resize actually happened
if (!this.resizeObFired) {
this.resizeObFired = true
} else {
this.animationFrameID = window.requestAnimationFrame(() => {
this.resize$.next();
});
}
}
}
}));
this.resizeOb.observe(this.el.nativeElement);
}
}
ngAfterViewInit() {
this.initChart();
} |
@xieziyu Could the current fix on version 17 be applied to 16.2.0 ? or some kind of workaround to keep the auto resize and the initial animation on version 16? |
As a workaround, you could probably just add the property Here is the documentation on ECharts. |
I am using ngx echarts for my angular app and I am not able to get the animation to work during the initial load of the chart. I have attached a sample Stackblitz where you can observe that on initial load, the bars render faster whereas when toggling using the legend, the actual animation happens.
Can anyone help me out in the right direction saying what have I done wrong?
Html:
<div echarts [options]="options"></div>
Ts options object
{ xAxis: { data: xAxisData, }, legend: {}, yAxis: {}, series: [ { name: 'bar', type: 'bar', barCategoryGap: '0%', data: data1, animationDuration: 5000, }, { name: 'bar1', type: 'bar', barCategoryGap: '0%', data: data2, animationDuration: 3000, }, ], }
The text was updated successfully, but these errors were encountered: