--- title: RadarChart description: "`RadarChart` is a component for drawing radar charts to compare multiple sets of data." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/chart/radar-chart.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/chart - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-chart-radarchart--basic --- # RadarChart `RadarChart` is a component for drawing radar charts to compare multiple sets of data. ```tsx interface Data { browser: string visits: number downloads: number fill?: CSSProps["fill"] } const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo( () => [ { browser: "Chrome", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Edge", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Firefox", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Opera", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Safari", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Other", visits: faker.number.int({ max: 5000, min: 1000 }), downloads: faker.number.int({ max: 5000, min: 1000 }), }, ], [], ) return ``` ## Usage ```tsx import { RadarChart } from "@yamada-ui/react" ``` ```tsx import { RadarChart } from "@/components/ui" ``` ```tsx import { RadarChart } from "@workspaces/ui" ``` ```tsx ``` :::tip To show differences or rankings between categories, use [BarChart](https://yamada-ui.com/docs/components/bar-chart.md). ::: :::tip To show each category's proportion of the whole, use [PieChart](https://yamada-ui.com/docs/components/pie-chart.md) or [DonutChart](https://yamada-ui.com/docs/components/donut-chart.md). ::: :::tip To show changes or trends over time, use [LineChart](https://yamada-ui.com/docs/components/line-chart.md) or [AreaChart](https://yamada-ui.com/docs/components/area-chart.md). ::: :::tip To show the breakdown of a whole with a stacked chart, use [BarChart](https://yamada-ui.com/docs/components/bar-chart.md) or [AreaChart](https://yamada-ui.com/docs/components/area-chart.md). ::: :::tip To show each item's progress toward completion, use [RadialChart](https://yamada-ui.com/docs/components/radial-chart.md). ::: ### Composition ```tsx const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Change Size ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( {(size, index) => ( )} ) ``` ### Change Color Scheme ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries( [ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ], "blue", ), [], ) const data = useMemo(() => createPolarChartData(), []) return ``` ### Change Color ```tsx const series = useMemo[]>( () => [ { color: "red", dataKey: "visits", name: "Visits" }, { color: "green", dataKey: "downloads", name: "Downloads" }, ], [], ) const data = useMemo(() => createPolarChartData(), []) return ``` ### Add Radius Axis To add the radius axis, set `withRadiusAxis` to `true`. The default is `false`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries( [ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ], "blue", ), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Change Radius Axis Angle To change the radius axis angle, set `radiusAxisProps.angle` to the desired angle. The default is `90`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries( [ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ], "blue", ), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Add Legend To add the legend, set `withLegend` to `true`. To change the placement, set `legendProps.placement`. ```tsx const series = useMemo[]>( () => [ { color: "red", dataKey: "visits", name: "Visits" }, { color: "green", dataKey: "downloads", name: "Downloads" }, ], [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Add Label To display labels, set `label` or `radarProps.label` to `true`. The default is `false`. ```tsx const series = useMemo[]>( () => [{ color: "blue", dataKey: "visits", name: "Visits" }], [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Change Grid Type To change the grid type, set `gridProps.gridType` to `"polygon"` or `"circle"`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( {(gridType, index) => ( )} ) ``` ### Fill Grid ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( {(gridType, index) => ( )} ) ``` ### Display Line Only ```tsx const series = useMemo[]>( () => [ { color: "red", dataKey: "visits", name: "Visits" }, { color: "green", dataKey: "downloads", name: "Downloads" }, ], [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Add Dot To display dots, set `dot` or `radarProps.dot` to `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Sync To sync charts, set `syncId` to a string. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Format To format the chart, use `formatter` or `tickFormatter` etc. ```tsx const series = useMemo[]>( () => [{ color: "blue", dataKey: "visits", name: "Visits" }], [], ) const data = useMemo(() => createPolarChartData(), []) return ( toTitleCase(value) }} data={data} nameKey="browser" radarProps={{ dot: true, label: { formatter: (value) => Number(value).toLocaleString() }, }} series={series} tooltipProps={{ formatter: (value, name = "") => [ Number(value).toLocaleString(), toTitleCase(name), ], labelFormatter: (value) => toTitleCase(isString(value) ? value : ""), }} /> ) ``` ### Add Angle Axis Line To display the axis line of the angle axis, set `angleAxisProps.axisLine` to `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Add Angle Axis Tick Line To display tick lines of the angle axis, set `angleAxisProps.tickLine` to `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Set Domain To set the value range, set `radiusAxisProps.domain` to an array in `radiusAxisProps`. To set the ticks, set `radiusAxisProps.ticks` to an array in `radiusAxisProps`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Add Tooltip Cursor To display the tooltip cursor, set `tooltipProps.cursor` to `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Hide Angle Axis To hide the angle axis, set `withAngleAxis` to `false`. The default is `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Hide Grid To hide the grid, set `withGrid` to `false`. The default is `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Hide Active Dot To hide active dots, set `activeDot` or `radarProps.activeDot` to `false`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Hide Tooltip To hide the tooltip, set `withTooltip` to `false`. The default is `true`. ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Customize Dot ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits", dot: { fill: "blue" } }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Customize Active Dot ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Customize Label ```tsx const series = useMemo[]>( () => [{ color: "blue", dataKey: "visits", name: "Visits" }], [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ### Customize Tooltip Cursor ```tsx const series = useMemo[]>( () => RadarChart.mergeSeries([ { dataKey: "visits", name: "Visits" }, { dataKey: "downloads", name: "Downloads" }, ]), [], ) const data = useMemo(() => createPolarChartData(), []) return ( ) ``` ## Accessibility ### Keyboard Navigation | Key | Description | State | | ------------ | ---------------------------------------------------------- | -------------------- | | `ArrowRight` | Moves to the next data point and displays the tooltip. | `withTooltip={true}` | | `ArrowLeft` | Moves to the previous data point and displays the tooltip. | `withTooltip={true}` | | `Enter` | Toggles the tooltip display for the active data point. | `withTooltip={true}` | ### ARIA Roles and Attributes | Component | Role and Attribute | Usage | | --------- | -------------------- | -------------------------------------- | | `svg` | `role="application"` | Indicates that this is an application. | ## Props