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

Clamp ContinuousTimeScale ticks to round(er) values #24

Open
hsuominen opened this issue Jan 30, 2018 · 2 comments
Open

Clamp ContinuousTimeScale ticks to round(er) values #24

hsuominen opened this issue Jan 30, 2018 · 2 comments

Comments

@hsuominen
Copy link

I'm implementing a zoomable time axis (from seconds up to months, ) and ContinuousTimeScale works almost perfectly out of the box but for certain zoom levels the resulting ticks could be improved.

As the ideal result seems quite case specific I was wondering if it would make sense to add the ability to pass custom tickIntervals through to the Scale? Essentially what I would want is to modify this https://github.com/gampleman/elm-visualization/blob/master/src/Visualization/Scale/Time.elm#L51 but due to most of the machinery being private modifying it without forking the whole library seems a no go.

@gampleman
Copy link
Owner

Interesting question. I feel like I would like to hear a bit more details about what you are doing and what the specific issues you are running into are. Passing in a custom tickIntervals isn't entirely straightforward without further complicating scales which are already fairly complex.

On another note, Axis that ship with elm-visualization provide an option for you to pass in custom ticks, so you can implement your own functionality if need be, while still using the provided scales for other purposes.

@hsuominen
Copy link
Author

hsuominen commented Jan 30, 2018

To demonstrate the problem below are some screen shots at different zoom levels (effectively expanding the time range)

This looks good, but there is a date switch at 12:00 which we miss
screen shot 2018-01-31 at 00 11 09

Zooming out we get the hours together with the date changeover, this is great
screen shot 2018-01-31 at 00 11 23

Going further out we miss the date change again
screen shot 2018-01-31 at 00 11 51

Which gets especially confusing further out
screen shot 2018-01-31 at 00 12 31

Going out further things are great
screen shot 2018-01-31 at 00 12 43

Thinking about this more, messing with tickIntervals would not solve the issue, as it stems from the axis limits and whether the autocomputed ticks happen to fall on the "magic" values (eg. date/month change).

As I'm working with a fully dynamic canvas (the user can zoom in and out, and pan around) I don't want to set the axis limits to "round" numbers unnecessarily. I could of course compute tick positions and pass them directly to Axis but this seems overkill seeming that the scales are doing effectively the same job behind the scenes.

Now I'm thinking what might make most sense is to add further rounding to the start/end values inside ticks (https://github.com/gampleman/elm-visualization/blob/master/src/Visualization/Scale/Time.elm#L48). Date.Extra.range implements rounding at the level of the intended time interval, but I think to solve this issue we would need to perform rounding at a longer time interval.

@hsuominen hsuominen changed the title Expose tickIntervals to allow custom (dynamic) intervals Clamp ContinuousTimeScale ticks to round(er) values Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants