question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Realtime Line Chart: Animation gap after shift()

See original GitHub issue

Expected Behavior

Using a line chart, after I remove the first item of the data array and the first label, the remaining data points move from right to left. This is a useful setting for a realtime data chart.

The second data point should move to the first position while keep showing the line to the first point and the colored area below until the second data point is on it’s final position.

Current Behavior

While the second data point moves to the first position there is a gap without a line and without a colored area below.

Possible Solution

Change the animation after chart.dataset[0].data.shift(); chart.labels.shift(); is called.

Steps to Reproduce (for bugs)

See the following Plunker example (uses angular version ng2-charts, but has the same behavior than using charts.js directly): http://plnkr.co/edit/y0gKnQrv3PlIW5NgmXm0

Context

I want to use charts.js resp. ng2-charts to display realtime data that has a constant number of data points. As new data points are emitted the most left data point is removed. As I remove this first data point the gap animation occurs.

Environment

See link above. I tested it locally with the newest library versions and experienced the same behavior.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

10reactions
simonbrunelcommented, Sep 7, 2017

@nagix plugin might be helpful?! (demo)

2reactions
kurklecommented, Jun 9, 2020

With a little bit of trickery it can be made smooth for v3 (might work for v2 too): https://jsfiddle.net/dukfqjyr/ Requires unique labels (should work fine with other types of scales with little tweaking)

This is the workaround @etimberg described above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line Chart - Google Developers
A line chart that is rendered within the browser using SVG or VML. ... You load the Google Visualization API (although with the...
Read more >
Dynamically update values of a chartjs chart - Stack Overflow
in the test code, I am updating the values with datasets[0].data - is this the right way to do it? The problem with...
Read more >
How to Animate Transitions Between Multiple Charts
Animated transitioning between chart types can add depth to your data ... The attr() calls on the transition are in the later category....
Read more >
Time-stretching and time-remapping - Adobe Support
Speeding up or slowing down an entire layer by the same factor throughout is known as time-stretching. When you time-stretch a layer, ...
Read more >
Animations – amCharts 4 Documentation
Animations are actually automatically enabled. It's the various *Duration properties on Charts, Series, Axes, etc. that determine if something animates. The ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found