-
-
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] Introduce the radar chart #16406
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-16406--material-ui-x.netlify.app/ Updated pages: |
37ed9fc
to
a95fddc
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
a589b3a
to
e1b7842
Compare
CodSpeed Performance ReportMerging #16406 will not alter performanceComparing Summary
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
packages/x-charts/src/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.ts
Show resolved
Hide resolved
params: UseChartPolarAxisParameters; | ||
defaultizedParams: UseChartPolarAxisDefaultizedParameters; | ||
state: UseChartPolarAxisState; | ||
// instance: UseChartPolarAxisInstance; |
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.
Just double-checking: is this commented on purpose?
I assume this got carried over because of how we handle the This would make the styles more consistent, but might create other issues 🫠 |
// The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartPolarAxis` | ||
// As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one |
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 didn't understand this comment
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.
It's a copy past from the data grid.
We skip the first useEffect, to be in sync with other part of the stor we needs to be sure this hook does not depend on other variable that could be modified by other pluggins running after it.
For charts I don't se a usecases, but for datagrid you might have weird case with the focus, scroll position, and other interaction features.
We can remove the comment if it's confusing.
testSkipIf(!isJSDOM)('should throw an error when axis have duplicate ids', () => { | ||
const expectedError = [ | ||
'MUI X: The following axis ids are duplicated: qwerty.', | ||
'Please make sure that each axis has a unique id.', | ||
].join('\n'); | ||
|
||
expect(() => | ||
render( | ||
<BarChart | ||
xAxis={[ | ||
{ scaleType: 'band', id: 'qwerty', data: ['a', 'b', 'c'] }, | ||
{ scaleType: 'band', id: 'qwerty', data: ['a', 'b', 'c'] }, | ||
]} | ||
series={[{ data: [1, 2, 3] }]} | ||
height={100} | ||
width={100} | ||
/>, | ||
), | ||
).toErrorDev(expectedError); | ||
}); | ||
|
||
// can't catch render errors in the browser for unknown reason | ||
// tried try-catch + error boundary + window onError preventDefault | ||
testSkipIf(!isJSDOM)( | ||
'should throw an error when axis have duplicate ids across different directions (x,y)', | ||
() => { | ||
const expectedError = [ | ||
'MUI X: The following axis ids are duplicated: qwerty.', | ||
'Please make sure that each axis has a unique id.', | ||
].join('\n'); | ||
|
||
expect(() => | ||
render( | ||
<BarChart | ||
xAxis={[{ scaleType: 'band', id: 'qwerty', data: ['a', 'b', 'c'] }]} | ||
yAxis={[{ id: 'qwerty' }]} | ||
series={[{ data: [1, 2, 3] }]} | ||
height={100} | ||
width={100} | ||
/>, | ||
), | ||
).toErrorDev(expectedError); | ||
}, | ||
); |
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 guess you missed the tests here 😆
export interface RadarDataProviderProps | ||
extends Omit< | ||
ChartContainerProps<'radar', RadarPluginSignatures>, | ||
'series' | 'plugins' | 'rotationAxis' | 'radiusAxis' | 'dataset' | ||
> { | ||
/** | ||
* The series to display in the bar chart. | ||
* An array of [[RadarSeriesType]] objects. | ||
*/ | ||
series: MakeOptional<RadarSeriesType, 'type'>[]; | ||
/** | ||
* The configuration of the radar scales. | ||
*/ | ||
radar: RadarConfig; | ||
} |
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 like the API, sounds reasonable. series
handles the series, radar
is the chart config 👍
Hm, good points. I don't have any suggestions at the moment, but I'll let you know if I can think of something. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This PR is a rough first version of the Radar chart #7925. Lots of features are missing.
The idea is to validate the data structure, and it's mapping to a rotation/radius scale system. If ok, we can merge this one and add features in distinct PR such that we keep them small enough to be relevant (I don't expect someone to read 200 files with 10 different features and spot any bug or room for improvement)
Main idea
The polar plugin introduce the support of rotatio/radius axes that work similarly to the x/y axes
The radar don't expose directly those axies. It uses an intermediate
metrics
to make sure the radar has only one rotation axis with scale point, and one radius axis per metric.Then we have one component per item rendered (grid, area, and marks)
Features
Preview: https://deploy-preview-16406--material-ui-x.netlify.app/x/react-charts/radar/