Skip to content
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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Jan 30, 2025

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

  • Polar coordinate
  • Map series config to rendering
  • Correct margins
  • Correct light/dark colors
  • Axes labels
  • Variants of axes shape (rounded one)
  • Interaction
  • Highlight
  • Tooltip
  • Defining the composition customization (opportunity to experiment with base-ui DX)
  • ARIA attributes?

Preview: https://deploy-preview-16406--material-ui-x.netlify.app/x/react-charts/radar/

@alexfauquette alexfauquette added new feature New feature or request component: charts This is the name of the generic UI component, not the React module! labels Jan 30, 2025
@mui-bot
Copy link

mui-bot commented Jan 30, 2025

Deploy preview: https://deploy-preview-16406--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against a6d0342

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 31, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 31, 2025
@alexfauquette alexfauquette marked this pull request as ready for review January 31, 2025 11:11
Copy link

codspeed-hq bot commented Jan 31, 2025

CodSpeed Performance Report

Merging #16406 will not alter performance

Comparing alexfauquette:radar-chart (a6d0342) with master (e71e831)

Summary

✅ 6 untouched benchmarks

@alexfauquette alexfauquette marked this pull request as draft January 31, 2025 15:28
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 4, 2025
@alexfauquette alexfauquette marked this pull request as ready for review February 4, 2025 10:59
@bernardobelchior
Copy link
Member

Is it just me or are the circles not being affected by the area above them?

For example, I think it's clear the blue area is below the yellow area because its color is affected by the yellow area's. However, this doesn't seem to be the case for the circles in blue, which seem unaffected.

image

params: UseChartPolarAxisParameters;
defaultizedParams: UseChartPolarAxisDefaultizedParameters;
state: UseChartPolarAxisState;
// instance: UseChartPolarAxisInstance;
Copy link
Member

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?

@JCQuintas
Copy link
Member

Is it just me or are the circles not being affected by the area above them?

I assume this got carried over because of how we handle the Line/Area charts as well. Should we start rendering the series fully one on top of eachother and only then adding "click/markhandlers" without styling on top of the charts? 🤔

This would make the styles more consistent, but might create other issues 🫠

Comment on lines +38 to +39
// 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
Copy link
Member

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

Copy link
Member Author

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.

Comment on lines +17 to +60
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);
},
);
Copy link
Member

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 😆

Comment on lines +26 to +40
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;
}
Copy link
Member

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 👍

@bernardobelchior
Copy link
Member

Is it just me or are the circles not being affected by the area above them?

I assume this got carried over because of how we handle the Line/Area charts as well. Should we start rendering the series fully one on top of eachother and only then adding "click/markhandlers" without styling on top of the charts? 🤔

This would make the styles more consistent, but might create other issues 🫠

Hm, good points. I don't have any suggestions at the moment, but I'll let you know if I can think of something.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Feb 11, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! new feature New feature or request PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants