Seeking Alternative Approach for Achieving "Counting Effect" in Bar Chart Component #5191
Unanswered
teotorstensson
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there,
I'm working on a bar chart component and aiming to implement a neat "counting effect" by having the numbers associated with each bar increment or decrement by 0.1. The idea is to create a visually appealing transition as the data changes.
However, I've run into a snag. When I set the increment value at 0.1 or even up to 0.3, the component starts to lag. It's only at 0.4-0.5 where it doesn't lag. Here's the code snippet where this is happening:
if (displayValue < targetValues[index]) { return Math.min(displayValue + 0.1, targetValues[index]); } else if (displayValue > targetValues[index]) { return Math.max(displayValue - 0.1, targetValues[index]); }
I've been stuck on this for a while now and am wondering if there's a smarter or more efficient way to achieve this counting effect without the lag. This is my first post on any forum since i like to solve problems on my own, but now I'm desperate for new ideas. Any suggestions or alternative approaches would be hugely appreciated!
Thanks a ton in advance for any help or insights!
Beta Was this translation helpful? Give feedback.
All reactions