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

Add possibility to use default tick mark formatter implementation as a fallback #1210

Closed
kirchet opened this issue Nov 29, 2022 · 0 comments · Fixed by #1236
Closed

Add possibility to use default tick mark formatter implementation as a fallback #1210

kirchet opened this issue Nov 29, 2022 · 0 comments · Fixed by #1236
Labels
enhancement Feature requests, and general improvements.
Milestone

Comments

@kirchet
Copy link
Contributor

kirchet commented Nov 29, 2022

Is your feature request related to a problem? Please describe.

For now we can provide tickMarkFormatter to format time axis tick marks.

/**
* Tick marks formatter can be used to customize tick marks labels on the time axis.
*
* @defaultValue `undefined`
*/
tickMarkFormatter?: TickMarkFormatter;

/**
* The `TickMarkFormatter` is used to customize tick mark labels on the time scale.
*
* This function should return `time` as a string formatted according to `tickMarkType` type (year, month, etc) and `locale`.
*
* Note that the returned string should be the shortest possible value and should have no more than 8 characters.
* Otherwise, the tick marks will overlap each other.
*
* @example
* ```js
* const customFormatter = (time, tickMarkType, locale) => {
* // your code here
* };
* ```
*/
export type TickMarkFormatter = (time: Time, tickMarkType: TickMarkType, locale: string) => string;

But we cannot override the behaviour for some special cases and call the default implementation otherwise

Describe the solution you'd like

We can change the signature in the following way:

export type TickMarkFormatter = (time: Time, tickMarkType: TickMarkType, locale: string) => string | null;

In case when this funtion returns null we can use the default tick mark formatter implementation.

@SlicedSilver SlicedSilver added the enhancement Feature requests, and general improvements. label Nov 29, 2022
@SlicedSilver SlicedSilver added this to the 4.0 milestone Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, and general improvements.
Projects
None yet
2 participants