-
-
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] Allow SeriesValueFormatter
to return null
value
#15057
Conversation
Deploy preview: https://deploy-preview-15057--material-ui-x.netlify.app/ |
CodSpeed Performance ReportMerging #15057 will not alter performanceComparing Summary
|
Thanks @clins1994, this seems to be a good addition. @alexfauquette do you see any issue? |
SeriesValueFormatter
type to allow returning null
values
SeriesValueFormatter
type to allow returning null
valuesSeriesValueFormatter
to return null
value
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.
LGTM 👍
I considered moving this to the fact that the value
is null
instead of the formatted one. But a user could have the opposite need: showing something in the tooltip for missing values
@alexfauquette @JCQuintas thank you for the reviews 🤝 |
TL;DR
A. Omit irrelevant tooltip values by updating the SeriesValueFormatter type to allow retuning
null
valuesB. Usage: update
valueFormatter
function to return null if the value is irrelevantProblem
Use case: when displaying multiple series with the same label/color on a stacked bar chart it can be useful to omit the series that have no value for a given stack.
Note: I am interested in seeing 'axis' tooltip not 'item'
The screenshot below shows the tooltip of a stack that has "MOVING", "STOPPED", and "MOVING"
In this example the order of these events matter both on the x axis and y axis so it was decided to split the multiple "MOVING" data into separate series
When hovering over the tooltip it becomes polluted with irrelevant '-' values.
I am able to filter out the values by passing
null
as a return but I get a type error which I was able to ignore using!
With this I can visualize only the data that is displayed on the chart
Solution
Since forcing the return of
null
didn't break but actually fixed my issue I wrote this PR to update the type to match the already allowed and expected behavior