--- title: RadialChart description: "`RadialChart` is a component for drawing radial charts to compare multiple sets of data." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/chart/radial-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-radialchart--basic --- # RadialChart `RadialChart` is a component for drawing radial charts to compare multiple sets of data. ```tsx interface Data { browser: string visits: number fill?: CSSProps["fill"] } const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => RadialChart.mergeData([ { browser: "Chrome", visits: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Edge", visits: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Firefox", visits: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Opera", visits: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Safari", visits: faker.number.int({ max: 5000, min: 1000 }), }, { browser: "Other", visits: faker.number.int({ max: 5000, min: 1000 }), }, ]), [], ) return ``` ## Usage ```tsx import { RadialChart } from "@yamada-ui/react" ``` ```tsx import { RadialChart } from "@/components/ui" ``` ```tsx import { RadialChart } 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 the overall balance or characteristics across multiple metrics, use [RadarChart](https://yamada-ui.com/docs/components/radar-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). ::: ### Composition ```tsx const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ( ) ``` ### Change Size ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ( {(size, index) => ( )} ) ``` ### Change Color ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => RadialChart.mergeData(createPolarChartData(), "blue"), [], ) return ``` ### Change Sector Colors ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => createPolarChartData().map((item, index) => ({ ...item, fill: ["cyan", "green", "orange", "red", "blue", "gray"][index], })), [], ) return ``` ### Add Legend To add the legend, set `withLegend` to `true`. To change placement, set `legendProps.placement` to `"start-start"`, `"end-end"`, etc. The default is `"start-end"`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => createPolarChartData().map((item, index) => ({ ...item, fill: ["cyan", "green", "orange", "red", "blue", "gray"][index], })), [], ) return ``` ### Add Label To display labels, set `label` or `radialProps.label` to `true`. The default is `false`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => RadialChart.mergeData(createPolarChartData(), "blue"), [], ) return ( ) ``` ### Add Label List To display label list, set `labelList` or `radialProps.labelList` to `true`. The default is `false`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ( ) ``` ### Add Center Label ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => RadialChart.mergeData([ { browser: "Chrome", visits: faker.number.int({ max: 5000, min: 1000 }) }, { browser: "Edge", visits: faker.number.int({ max: 5000, min: 1000 }) }, { browser: "Safari", visits: faker.number.int({ max: 5000, min: 1000 }) }, ]), [], ) const total = useMemo( () => data.reduce((acc, { visits }) => acc + visits, 0), [data], ) return ( Visitors { if (!viewBox) return null if (!("cx" in viewBox) || !("cy" in viewBox)) return null return ( {total.toLocaleString()} Visitors ) }} /> ) ``` ### Change Start Angle To change the start angle, set `startAngle` to a number. The default is `90`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ``` ### Change End Angle To change the end angle, set `endAngle` to a number. The default is `-270`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ``` ### Change Inner Radius To change the inner radius, set `innerRadius` to a number or string. The default is `"20%"`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ``` ### Change Outer Radius To change the outer radius, set `outerRadius` to a number or string. The default is `"90%"`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ``` ### Change Corner Radius To round sector corners, set `cornerRadius` to a number. ```tsx const series = useMemo[]>( () => [{ cornerRadius: 9999, dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ``` ### Change Gap To change the gap between bars, set `barCategoryGap` to a number or string. The default is `"10%"`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ( ) ``` ### Stacked ```tsx const series = useMemo( () => [ { color: "blue.500", dataKey: "desktop", nameKey: "browser" }, { color: "blue.300", dataKey: "mobile", nameKey: "browser" }, ], [], ) const data = useMemo( () => [ { browser: "Chrome", desktop: faker.number.int({ max: 3000, min: 2000 }), mobile: faker.number.int({ max: 5000, min: 4000 }), }, ], [], ) const total = useMemo( () => data.reduce((acc, { desktop, mobile }) => acc + desktop + mobile, 0), [data], ) return ( [ Number(value).toLocaleString(), toTitleCase(isString(data.dataKey) ? data.dataKey : ""), ], }} > { if (!viewBox) return null if (!("cx" in viewBox) || !("cy" in viewBox)) return null return ( {total.toLocaleString()} Visitors ) }} /> ) ``` ### Sync To sync charts, set `syncId` to a string. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(createPolarChartData()), []) return ( ) ``` ### Format To format the chart, use `formatter`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo( () => RadialChart.mergeData(createPolarChartData(), "blue"), [], ) return ( Number(value).toLocaleString(), }, labelList: { formatter: (value) => (isString(value) ? toTitleCase(value) : value), }, }} series={series} tooltipProps={{ formatter: (value, name = "") => [ Number(value).toLocaleString(), toTitleCase(name), ], }} /> ) ``` ### Hide Tooltip To hide the tooltip, set `withTooltip` to `false`. The default is `true`. ```tsx const series = useMemo[]>( () => [{ dataKey: "visits", nameKey: "browser" }], [], ) const data = useMemo(() => RadialChart.mergeData(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