Comments (10)
Does this happen with the same chart outside Angular?
Can you share the particular chart you are testing with, so that we can experiment ourselves?
Thanks!
from amcharts4.
Issue can be reproducted with the example code you provided:
https://github.com/amcharts/amcharts4/blob/master/dist/es2015/examples/angular/simple-line-chart/src/app/app.component.ts
Without angular and also not interacting with the page:
15-20% CPU:
https://codepen.io/team/amcharts/pen/ZoOyOz
100% CPU:
https://codepen.io/team/amcharts/pen/MGVbNV
25% CPU:
https://codepen.io/team/amcharts/pen/qYVVEa
etc...
Can be reproducted in firefox 52.8.0 and chrome 66.0.3359.139 (probably on other browsers too)
Changed the issue subject accordingly
Best regards,
from amcharts4.
Yeah, Angular's Zones tend to cause big performance problems (for third-party code, and also sometimes for Angular code!)
Zones cause some performance overhead, but that's not the real problem: the problem is that on every frame (or anytime anything changes in amCharts), Angular will do dirty checking of everything (including your app).
That's just how Angular is designed to work, so I'm not sure if there's anything we can do in amCharts to fix it, but you can fix it yourself by disabling Zones:
import { Component, NgZone } from "@angular/core";
import * as am4core from "@amcharts/amcharts4/core";
import * as am4charts from "@amcharts/amcharts4/charts";
import am4themes_animated from "@amcharts/amcharts4/themes/animated";
am4core.useTheme(am4themes_animated);
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
private chart: am4charts.XYChart;
constructor(private zone: NgZone) {}
ngAfterViewInit() {
this.zone.runOutsideAngular(() => {
let chart = am4core.create("chartdiv", am4charts.XYChart);
chart.paddingRight = 20;
let data = [];
let visits = 10;
for (let i = 1; i < 366; i++) {
visits += Math.round((Math.random() < 0.5 ? 1 : -1) * Math.random() * 10);
data.push({ date: new Date(2018, 0, i), name: "name" + i, value: visits });
}
chart.data = data;
let dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.renderer.grid.template.location = 0;
let valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.tooltip.disabled = true;
valueAxis.renderer.minWidth = 35;
let series = chart.series.push(new am4charts.LineSeries());
series.dataFields.dateX = "date";
series.dataFields.valueY = "value";
series.tooltipText = "{valueY.value}";
chart.cursor = new am4charts.XYCursor();
let scrollbarX = new am4charts.XYChartScrollbar();
scrollbarX.series.push(series);
chart.scrollbarX = scrollbarX;
this.chart = chart;
});
}
ngOnDestroy() {
this.zone.runOutsideAngular(() => {
if (this.chart) {
this.chart.dispose();
}
});
}
}
from amcharts4.
We have updated our Angular tutorial to disable Zones, so future projects won't run into this problem.
from amcharts4.
The issue is present without angular so zone.js is not entirely responsable, see provided examples in my previous comment.
Can you open the issue again ?
Best regards,
from amcharts4.
Used UC instead of CPU in my previous mesurements.
Comparing realtime graph (15.1% CPU, 5% GPU):
https://codepen.io/team/amcharts/pen/MGVbNV
To highchart equivalent (6% CPU, 20% GPU):
https://www.highcharts.com/demo/dynamic-update/dark-unica
Amchart does not seem to use the GPU as much as possible and results in lags.
Interacting with:
https://codepen.io/team/amcharts/pen/qYVVEa
Shows high CPU usage (30%) in the task manager and very low GPU usage
Best regards,
from amcharts4.
@xire28 Yes, we are aware that there are some things we can do to optimize our animations.
from amcharts4.
@Pauan is there anything you can advise doing or disabling to increase responsiveness and performance?
from amcharts4.
@calvinanderson You can try disabling animations (by using a non-animated theme, such as themes/material
).
Other than that, I think the best you can do is wait for us to optimize it.
If you have some V4 code which is consistently slow, you can send it to us (either in a Codepen or a Gist) and we'll try to optimize it.
from amcharts4.
Hi there,
We've come a long way since this was first reported. A lot of performance enhancing improvements were introduced.
I'm going to go ahead and close this. But please, anyone, if you still feel there are significant shortcomings in performance, please let us know.
from amcharts4.
Related Issues (20)
- Not able to print whole chart HOT 2
- How to change legend when use slice grouper by zoom click behavior HOT 3
- Remove Fill color from Pictorial Stacked Chart HOT 4
- In a FunnelSeries chart, how can I show labels in the sliceLinks? HOT 2
- How to hide the tooltip shown for xAxis title HOT 2
- How to hide the bullets when zoom in or zoomout event called HOT 2
- How bar chart with parent and sub catagory HOT 15
- Amchart 4 Legend In Arabic are not Showing Properly HOT 2
- Unable set label for radar chart as per my requirements HOT 2
- How to ensure consistent PNG export appearance regardless of browser zoom? HOT 5
- Amchart4 is ignoring null-category in data HOT 3
- minZoomCount for categoryAxis on yAxis HOT 2
- Pie of a Pie (problems with the lines) HOT 2
- How to show text in chart area without overlapping with the bars ? HOT 2
- Local formatter for ValueAxis HOT 2
- [Question] Multiple CandlestickSeries is shifted relative to each other HOT 2
- Wrong cursor position when viewbox and real width/height not matching HOT 2
- Map with clustered points and lines HOT 2
- Center wrapped legend items HOT 2
- How to access legend from another Element HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amcharts4.