-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[charts] Improve axis tooltip performances #17398
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] Improve axis tooltip performances #17398
Conversation
Thanks for adding a type label to the PR! 👍 |
Please add one type label to categorize the purpose of this PR appropriately:
|
Deploy preview: https://deploy-preview-17398--material-ui-x.netlify.app/ |
store, | ||
selectorChartsInteractionTooltipRotationAxes, | ||
[], | ||
compareTooltipAxes, |
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.
Would it make sense to use isDeepEqual
instead?
Otherwise, it's easy to forget to update compareTooltipAxes
if we add more properties.
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.
Otherwise, it's easy to forget to update compareTooltipAxes if we add more properties.
I assume TS should prevent use from that issue. I updated the selector definition to make sure the type is enfoced on both side.
My issue with isDeepEqual
is the ease of use. It would be tempting to put that every where.
I prefer a custom funciton, used only on simple usecases when necessary.
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.
My issue with isDeepEqual is the ease of use. It would be tempting to put that every where.
I agree with that feeling, but I feel the risk of forgetting to add a prop to compareTooltipAxes
is greater than using isDeepEqual
. It's a matter of personal opinion, so it isn't a blocker.
If we want to avoid using isDeepEqual
everywhere we can add a comment explaining why it's ok to use it in this case, and require an explanation from now on whenever we need to use it. Do you think that would be acceptable?
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.
That would be a solution. I let the PR open for the week-end to discuss with @JCQuintas if he think about another solution to memorize this selector
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.
Maybe we can pass the function to the third argument of createSelector
as
export const selectorChartsInteractionTooltipXAxes = createSelector(
[selectorChartsInteractionPointerX, selectorChartXAxis],
(value, axes) => {
if (value === null) {
return [];
}
return axes.axisIds
.filter((id) => axes.axis[id].triggerTooltip)
.map(
(axisId): AxisItemIdentifier => ({
axisId,
dataIndex: getAxisIndex(axes.axis[axisId], value),
}),
)
.filter(({ dataIndex }) => dataIndex >= 0);
},
{
memoizeOptions: {
resultEqualityCheck: compareTooltipAxes,
},
},
);
to prevent exporting the func? This would also be advantageous as we wouldn't need to remember to add it when using the selector itself.
Other than that I don't have much preference to which we use, but I do agree isDeepEqual
is more complete.
CodSpeed Performance ReportMerging #17398 will not alter performanceComparing Summary
|
Fix #17367
Axis tooltip content is re-rendering a log because of similar issues as the one in #16575
Here I don't see a way to fix it except by doing a quick JS comparison if the array to return the same ref if value do not change.
Why it broke
The root issue comes from the x/y position update triggers a computation of the axes indexes (which is expected) but if indexes are unchanged, it should not cause further updates.
It's the case for single axis manipulation. For example the axis highlight, because we manipulate numbers. So when the selector returns
2
asdataIndex
the process stops as long as the value stay the same.But now tooltip suports multiple axes, so when the selector returns
[{ axisId: "A", dataIndex: 2 }]
the array reference is always a new one triggering the entire pipelineAfter the fix
Capture.video.du.2025-04-16.12-16-20.mp4