Ngx-charts: display live data in a line chart

Created on 29 May 2017  路  12Comments  路  Source: swimlane/ngx-charts

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
If I insert a new data point to a line chart, all data points will be animated.
This will lead to a messy data visualization.

At first I tryed to simply push new data points, but it looks like change detection does not recognize this.
this.multi[0].series.push(data);
Rewriting the whole array works but leads to the described behavior.
this.multi[0].series.push(data);
this.multi = [...this.multi];

Expected behavior
Only the the line for the new data point should be animated.
Otherwise it would be good to have a option flag, to turn off animations.

Reproduction of the problem
I created a plunkr to show the current behavior:

https://plnkr.co/edit/FXA7r6ISQguTrqAF5YS5?p=preview

What is the motivation / use case for changing the behavior?
I would like to create a chart that shows realtime data.
Like flot chart does in this example: http://www.flotcharts.org/flot/examples/realtime/index.html

Environment:

  • ngx-charts version: 5.3.1
  • Angular version: 4.0.0
  • Browser: [Chrome]
  • Language: [ TypeScript 2.3.2]

Thank you for your feedback.

Accept PRs New Feature Backlog

Most helpful comment

Any updates on this?

All 12 comments

Same problem since up from 5.1.2 to 5.3.1

This post explains the current behavior, and why it doesn't work like what you describe as the expected behavior: https://bost.ocks.org/mike/path/

We will need to add a special animation when the line chart is used for live data, as it's a pretty common use case.

Any updates on this?

Any updates? Considering using this in a commercial project so project sponsorship/donations to get blockers fixed is possible :)

^ Any updates?

An alternative to the fancy horizontal animation (which would be nice), would be to just turn off animations. It isn't nearly as nice as with horizontal interpolation, but it works.

It looks like this (using a fork of the plunker found above):
https://plnkr.co/edit/6GHWvXPZvanbB1FR8dum?p=preview

Any updates on this?

Any Updates?

I achieved a possible solution!
The solution found is to keep a "local results" in the chart component, and the template consumes it instead of the given by @Input(), and each update adds the newly received data to the local one.

line-chart.component.ts

Note the lines 75, 236 and 282.

Good news ^! I created a PR for an Realtime option for the line chart. Imgur link to what it looks like here.

So, still no way to have realtime data? The documentation really fails to have good examples...

Unfortunately @darkguy2008, the best way is to still turn off animations like I suggested here. It doesn't do anybody any favors that they haven't even looked at my PR for adding the animations.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faisalnet5 picture faisalnet5  路  3Comments

Hypercubed picture Hypercubed  路  3Comments

jvbianchi picture jvbianchi  路  4Comments

cfremgen picture cfremgen  路  3Comments

ronybarbosa picture ronybarbosa  路  3Comments