Skip to content
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

Support for getTotalLength() #3817

Open
Giammaria opened this issue Oct 31, 2023 · 3 comments
Open

Support for getTotalLength() #3817

Giammaria opened this issue Oct 31, 2023 · 3 comments
Labels
feature-request For requesting new features or transforms

Comments

@Giammaria
Copy link
Contributor

Giammaria commented Oct 31, 2023

Has there been any thought into adding an expression similar to getTotalLength() for calculating the entire length of a path? This could be helpful for calculating dashArray to be used in conjunction with dashOffset and timers to create animated paths. Not entirely sure if this would be possible due to dependencies, but figured I'd ask.

Here is a basic example where I'm explicitly providing the static dashArray to create this effect. It would be nice if there was a way to have the total path length be calculated.

@Giammaria Giammaria added the feature-request For requesting new features or transforms label Oct 31, 2023
@domoritz
Copy link
Member

domoritz commented Jan 6, 2024

I think adding new methods to the expression language is easy and we should do it if there is a good use case.

@Giammaria
Copy link
Contributor Author

Thanks @domoritz. Here's another resource breaking down the implementation. In conjunction with timers, I can see a use case where this new Vega expression with dashOffset and dashArray could all be used to animate path changes over time, providing another avenue for storytelling with time-series data. While I imagine implementing the expression in SVG would be relatively straightforward, I'm less sure about the level of effort involved to add the equivalent functionality in canvas.

@domoritz
Copy link
Member

domoritz commented Jan 6, 2024

In general, expression functions that are stand alone should be easy to add but anything that interacts with marks and rendering will be trickier to get right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request For requesting new features or transforms
Projects
None yet
Development

No branches or pull requests

2 participants