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
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/data/charts/radar/BasicRadar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

export default function BasicRadar() {
return (
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
max: 120,
metrics: ['Math', 'Chinese', 'English', 'Geography', 'Physics', 'History'],
}}
/>
);
}
15 changes: 15 additions & 0 deletions docs/data/charts/radar/BasicRadar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

export default function BasicRadar() {
return (
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
max: 120,
metrics: ['Math', 'Chinese', 'English', 'Geography', 'Physics', 'History'],
}}
/>
);
}
8 changes: 8 additions & 0 deletions docs/data/charts/radar/BasicRadar.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
max: 120,
metrics: ['Math', 'Chinese', 'English', 'Geography', 'Physics', 'History'],
}}
/>
37 changes: 37 additions & 0 deletions docs/data/charts/radar/CompositionExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from 'react';
import {
Unstable_RadarDataProvider as RadarDataProvider,
RadarGrid,
RadarSeriesArea,
RadarSeriesMarks,
} from '@mui/x-charts/RadarChart';
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';

export default function CompositionExample() {
return (
<RadarDataProvider
height={300}
series={[
{
id: 'usa-id',
label: 'USA',
data: [6.65, 2.76, 5.15, 0.19, 0.07, 0.12],
},
{
id: 'australia-id',
label: 'Australia',
data: [5.52, 5.5, 3.19, 0.51, 0.15, 0.11],
},
]}
radar={{
metrics: ['Oil', 'Coal', 'Gas', 'Flaring', 'Other industry', 'Cement'],
}}
>
<ChartsSurface>
<RadarGrid divisionNumber={3} />
<RadarSeriesArea />
<RadarSeriesMarks seriesId="usa-id" />
</ChartsSurface>
</RadarDataProvider>
);
}
37 changes: 37 additions & 0 deletions docs/data/charts/radar/CompositionExample.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from 'react';
import {
Unstable_RadarDataProvider as RadarDataProvider,
RadarGrid,
RadarSeriesArea,
RadarSeriesMarks,
} from '@mui/x-charts/RadarChart';
import { ChartsSurface } from '@mui/x-charts/ChartsSurface';

export default function CompositionExample() {
return (
<RadarDataProvider
height={300}
series={[
{
id: 'usa-id',
label: 'USA',
data: [6.65, 2.76, 5.15, 0.19, 0.07, 0.12],
},
{
id: 'australia-id',
label: 'Australia',
data: [5.52, 5.5, 3.19, 0.51, 0.15, 0.11],
},
]}
radar={{
metrics: ['Oil', 'Coal', 'Gas', 'Flaring', 'Other industry', 'Cement'],
}}
>
<ChartsSurface>
<RadarGrid divisionNumber={3} />
<RadarSeriesArea />
<RadarSeriesMarks seriesId="usa-id" />
</ChartsSurface>
</RadarDataProvider>
);
}
70 changes: 70 additions & 0 deletions docs/data/charts/radar/DemoRadarNoSnap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import ChartsUsageDemo from 'docsx/src/modules/components/ChartsUsageDemo';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

export default function DemoRadarNoSnap() {
return (
<ChartsUsageDemo
componentName="Alert"
data={[
{
propName: 'startAngle',
knob: 'number',
defaultValue: 0,
min: -180,
max: 180,
},

{
propName: 'divisionNumber',
knob: 'number',
defaultValue: 5,
min: 0,
max: 20,
},
]}
renderDemo={(props) => (
<Box sx={{ width: '100%', maxWidth: 400 }}>
<RadarChart
height={250}
margin={{ top: 20 }}
series={[
{
// label: 'Lisa',
data: [120, 98, 86, 99, 85, 65],
},
]}
divisionNumber={props.divisionNumber}
radar={{
max: 120,
startAngle: props.startAngle,
metrics: [
'Math',
'Chinese',
'English',
'Geography',
'Physics',
'History',
],
}}
/>
</Box>
)}
getCode={({ props }) =>
[
`import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';`,
'',
`<RadarChart`,
' {/** ... */}',
` divisionNumber={${props.divisionNumber}}`,
` radar={{`,
` startAngle: ${props.startAngle},`,
` metrics: [...],`,
' }}',
'/>',
].join('\n')
}
/>
);
}
44 changes: 44 additions & 0 deletions docs/data/charts/radar/MultiSeriesRadar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

// Data from https://ourworldindata.org/emissions-by-fuel

const highlightScope = { highlight: 'item', fade: 'global' };

function valueFormatter(v) {
if (v === null) {
return 'NaN';
}
return `${v.toLocaleString()}t CO2eq/pers`;
}

export default function MultiSeriesRadar() {
return (
<RadarChart
height={300}
series={[
{
label: 'USA',
data: [6.65, 2.76, 5.15, 0.19, 0.07, 0.12],
highlightScope,
valueFormatter,
},
{
label: 'Australia',
data: [5.52, 5.5, 3.19, 0.51, 0.15, 0.11],
highlightScope,
valueFormatter,
},
{
label: 'United Kingdom',
data: [2.26, 0.29, 2.03, 0.05, 0.04, 0.06],
highlightScope,
valueFormatter,
},
]}
radar={{
metrics: ['Oil', 'Coal', 'Gas', 'Flaring', 'Other industry', 'Cement'],
}}
/>
);
}
45 changes: 45 additions & 0 deletions docs/data/charts/radar/MultiSeriesRadar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';
import { HighlightScope } from '@mui/x-charts/context';

// Data from https://ourworldindata.org/emissions-by-fuel

const highlightScope: HighlightScope = { highlight: 'item', fade: 'global' };

function valueFormatter(v: number | null) {
if (v === null) {
return 'NaN';
}
return `${v.toLocaleString()}t CO2eq/pers`;
}

export default function MultiSeriesRadar() {
return (
<RadarChart
height={300}
series={[
{
label: 'USA',
data: [6.65, 2.76, 5.15, 0.19, 0.07, 0.12],
highlightScope,
valueFormatter,
},
{
label: 'Australia',
data: [5.52, 5.5, 3.19, 0.51, 0.15, 0.11],
highlightScope,
valueFormatter,
},
{
label: 'United Kingdom',
data: [2.26, 0.29, 2.03, 0.05, 0.04, 0.06],
highlightScope,
valueFormatter,
},
]}
radar={{
metrics: ['Oil', 'Coal', 'Gas', 'Flaring', 'Other industry', 'Cement'],
}}
/>
);
}
21 changes: 21 additions & 0 deletions docs/data/charts/radar/RadarAxis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

export default function RadarAxis() {
return (
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
metrics: [
{ name: 'Math', max: 120 },
{ name: 'Chinese', max: 120 },
{ name: 'English', max: 120 },
{ name: 'Geography', max: 120 },
{ name: 'Physics', max: 120 },
{ name: 'History', max: 120 },
],
}}
/>
);
}
21 changes: 21 additions & 0 deletions docs/data/charts/radar/RadarAxis.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { Unstable_RadarChart as RadarChart } from '@mui/x-charts/RadarChart';

export default function RadarAxis() {
return (
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
metrics: [
{ name: 'Math', max: 120 },
{ name: 'Chinese', max: 120 },
{ name: 'English', max: 120 },
{ name: 'Geography', max: 120 },
{ name: 'Physics', max: 120 },
{ name: 'History', max: 120 },
],
}}
/>
);
}
14 changes: 14 additions & 0 deletions docs/data/charts/radar/RadarAxis.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<RadarChart
height={300}
series={[{ label: 'Lisa', data: [120, 98, 86, 99, 85, 65] }]}
radar={{
metrics: [
{ name: 'Math', max: 120 },
{ name: 'Chinese', max: 120 },
{ name: 'English', max: 120 },
{ name: 'Geography', max: 120 },
{ name: 'Physics', max: 120 },
{ name: 'History', max: 120 },
],
}}
/>
Loading
Loading