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

Is there a way to reset scales programmatically? #924

Open
trufflesprouts opened this issue Feb 12, 2024 · 3 comments
Open

Is there a way to reset scales programmatically? #924

trufflesprouts opened this issue Feb 12, 2024 · 3 comments
Labels
question Further information is requested

Comments

@trufflesprouts
Copy link

I'm trying to add a button to reset all scales similar to the way that double click works. Is there way to invoke the built in implementation of double click? or any clean way of doing this?

My current solution is saving the initial min and max in _range then setting the scale to be that value.

Another solution is emitting a double click event on u-over which seems a bit hacky.

@leeoniya
Copy link
Owner

leeoniya commented Feb 13, 2024

you can autorange/reset any scale by setting its min and max to null. the x scale is special, and setting it to any min/max will also reset/re-range all the y scales (assuming that they still have their original range fns). if you want to simulate what double-click does, you can do u.setScale('x', {min: null, max: null}) or u.setScale('x', {min: u.data[0][0], max: u.data[0].at(-1)}).

@leeoniya leeoniya added the question Further information is requested label Feb 13, 2024
@trufflesprouts
Copy link
Author

i tried setting it to null but it doesn't work as expected https://jsfiddle.net/7pzqbdy1/61/
the second solution works

@leeoniya
Copy link
Owner

let's leave this open. since i think null/null should work.

@leeoniya leeoniya reopened this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants