-
-
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] Experiment with plugins for series+axes #15865
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-15865--material-ui-x.netlify.app/ |
afd23e6
to
d17f173
Compare
useEnhancedEffect(() => { | ||
store.update((prevState) => ({ | ||
...prevState, | ||
zoom: { | ||
...prevState.zoom, | ||
zoomData, | ||
}, | ||
})); | ||
}, [store, zoomData]); |
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.
Shouldn't this be inside the setZoomDataCallback
instead? 🤔
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
CodSpeed Performance ReportMerging #15865 will improve performances by 9.86%Comparing Summary
Benchmarks breakdown
|
@@ -45,20 +53,24 @@ export const useChartContainerProps = ( | |||
...other, | |||
}; | |||
|
|||
const chartDataProviderProps: ChartDataProviderProps = { | |||
const chartDataProviderProps: Omit< | |||
ChartDataProviderProps<[UseChartCartesianAxisSignature<TSeries>], TSeries>, |
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.
For typing reasons, I set the cartesian plugin here, such that props related to cartesian axes are correctly typed
const { xAxis, xAxisIds } = useXAxes(); | ||
const { yAxis, yAxisIds } = useYAxes(); |
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.
You might see lots of them. The initial idea was to split x/y axes such that updating one does not impact the other. Finally I'm not sure it's that usefull
<ChartProvider pluginParams={{ width: 100, height: 100, series: [] }}> | ||
<ChartsSurface | ||
ref={ref} | ||
disableAxisListener // TODO: remove during v8 when charts store is always available |
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.
The store is available but not yet the axes, so removing it still make the CI crash
// 'use client'; | ||
// import * as React from 'react'; | ||
// import { computeAxisValue } from '../../internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue'; |
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 just commented the file about polar coordinate. They got introduced when starting the effort on radar chart.
They should be translated into a useChartPolarAxisPlugin
if (skipError) { | ||
// TODO: Remove once store is used by all charts. | ||
// This line is only for `useAxisEvents` which is in the surface of the Gauge. | ||
// But the Gauge don't have store yet because it does not need the interaction provider. | ||
// Will be fixed when every thing move to the store since every component will have access to it. | ||
// @ts-ignore | ||
return context?.store; | ||
} |
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 one is good to remove 🎉
This PR is an attempt to migrate the axes, series and zoom to the plugin framework.
Modifications
Renaming that could be extracted
ZoomOptions
->ZoomOption
: Even if we have multiple options, it's too easy to mix the zoom option of an axis and the object that map axes ids to their optionsSeriesFormatterResult
-> SeriesProcessorResultLogic
Instance
The
isPointInside
got moved from the drawing area to theinstance
. It's our first instance method 🎉Renaming plugins
The
plugins
props which was an array of configuration objects, defining for each series how to compute the extremums, preprocess the data, ... is now an object called seriesConfig. That's only sementic modificationSelector usage
The data modification is now done in selectors. We have 3 states: series, cartesianAxes, and zoom which describe the state of the chart.
One issue with this strategy is that
useXAxis()
is defined in the MIT package. And if we want to have theBarPlot
supporting zoom out of the box for pro users, we need to have the zoom selectors that get zoom data.The workaround is to put types and selectors for zoom in the MIT package. But populate and manage the state in the pro package.
Zoom API
The zoom seems to be working ok. The new API proposed it the following one:
onZoomChange
now provide the new zoom value in its argument.zoom
props is replaced byinitialZoom
which is only used to initialize the zoom.apiRef
get a methodsetZoomData
that use can call to set the zoom data. MaybesetZoom
would be a better name