-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[charts] Add context to axis value formatter #12172
Conversation
packages/x-charts/src/models/axis.ts
Outdated
* @param {V} value The value to format. | ||
* @returns {string} The string to display. | ||
*/ | ||
tickValueFormatter?: (value: V) => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitating with
tickFormatter
which is shorter and should not interfere with othersvalueTickFormatter
which has the advantage to group all the formatters at the same place in the alphabetical order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting situation. 🤔
tickValueFormatter
seems like it makes the most sense, but have you considered going the other way - adding a context to the existing valueFormatter
? 🤔
interface ValueFomatterContext {
location: 'value' | 'tick' | 'tooltip';
// or
location?: 'tick' | 'tooltip';
}
///
valueFormatter?: (value: V, context: ValueFomatterContext) => string;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not had preferences between the two, but effectively it fixes the naming issue 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is what I like the most about it.
Maybe I do not see some potential problems with it, but it feels that it would also be better suited for cases where we'd need to add the option to format the legend labels or something else as well 🙈
Deploy preview: https://deploy-preview-12172--material-ui-x.netlify.app/ Updated pages: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 👍 💯
Given the pivot in the solution, I took the liberty to update the PR title.
Feel free to update it if you can think of a more appropriate wording. 👌
Co-authored-by: Lukas <[email protected]> Signed-off-by: Alexandre Fauquette <[email protected]>
Signed-off-by: Alexandre Fauquette <[email protected]> Co-authored-by: Lukas <[email protected]>
Part of #10928