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

Trait Tick is not implemented for `Option<f64> #26

Open
TheToddmeister opened this issue Jul 23, 2024 · 5 comments
Open

Trait Tick is not implemented for `Option<f64> #26

TheToddmeister opened this issue Jul 23, 2024 · 5 comments

Comments

@TheToddmeister
Copy link

Hey
I really like this project!
Is conditional ticks possible and or wanted?
Is it within the wanted scope of the project?
There is no implementation for a non-continous line that that i can see, but i would like to either make it or see it made(as i need it).
Is it reasonable to make such an implementation?

@feral-dot-io
Copy link
Owner

Thanks, I'm glad you like it.

Yes conditional ticks are possible! You can use f64::NAN for this and the drawn line will stop and restart as expected.

This should probably be better documented with an example and as a type like Option<T>. I've been reluctant to expand on the tick types but will need to to address #17

@TheToddmeister
Copy link
Author

If i may add another issue to this thread. How would you implement an X tick where the X is (ordinate day, ordinate hour).
So far I've just transformed it to current year datetime. Would an ordinate definition be possible?

@feral-dot-io
Copy link
Owner

Let me try and understand this: you want ticks generated such that they align only to a specific hour / day / month / etc? I'm guessing you want something specific rather than just letting the tick generator work out the best scale (day, hour, or minute, etc) and fit whatever it can in the space it has? It might be worthwhile sharing an example of what you're trying to achieve to clear this up.

What you're asking for should be possible as tick labels are separated into a generator and a formatter. The TickGen will find the right scale and number of ticks to show given a range and available space so that's probably what you want to tweak. The formatter is more useful for things like showing the date under the mouse in a tooltip when it's not aligned to a specific tick without diving into nanoseconds or perhaps different formats in different contexts (think tooltip vs tick labels). The documentation, with hidden types, doesn't look to be that clear here.

So changing the tick gen to only generate ticks for the day would be to use Timestamps::from_periods and then you can pass it the list of Period you want which could be limited to just Period::Day. This then gets set in TickLabels::from_generator

I suppose there are no examples of this either :)

@feral-dot-io
Copy link
Owner

To review:

  • Document use of f64::NAN in Ticks.
  • Offering Option<Tick> to make f64::NAN clearer.
  • Example of a custom date time generator e.g., fewer periods.
  • Improve docs around custom tick gen e.g., TickGen is hidden and it's not clear that Timestamps could be used.

@TheToddmeister
Copy link
Author

TheToddmeister commented Sep 24, 2024

Apologies for disappearing:
I just came back to looking at this now as it is connected to a hobby project github account.
Thank you and I'll try that :)

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