A donut chart is essentially a PieChart with an area of the center cut out. In a donut chart, the arc length of each sector is proportional to the quantity it represents.
For DonutChart
, each data point will be defined by a DonutChart.Donut
child component.
By default, a Data Table is automatically generated in conjunction with the chart. While visually similar to a traditional legend, the data table provides colorblind users and users of screen readers with crucial content and data that they may not be able to gain from the chart itself. (See Accessibility for more details.)
The data table can be positioned in different locations relative to the chart. Use the tableLegendPosition
property to set the position.
If there is already a data table on the page, or if you intend to display a data table when a user clicks a trigger (link), you may use the traditional Legend
that only displays category labels and associated colors.
The traditional legend can also be positioned in different locations relative to the chart. Use the imageLegendPosition
property to set the position.
NUI Charts is intended to give consumers a simple, easy-to-use API for generating default charts. However, there are a number of customizations that consumers can use to access the full capability of the underlying chart library.
The example below shows a number of customizations:
See Recharts.org for more information about customizations.
Property | Type | Default | Description |
---|---|---|---|
children | Any | Required | One DonutChart.Donut component to be rendered in the chart. |
textNoData | String | Required | Localized text for the associated data table if no data exists. |
title | String | Required | The title of the chart. Will be offscreen, but still read by screen readers. |
containerProps | Object | Passthrough properties for the ResponsiveContainer component in the underlying chart library. See Recharts.org for more information. | |
height | Number | 300 | Height of the chart container (in pixels). |
imageLegendPosition | Object | The position of the chart legend relative to the chart. See imageLegendPosition for details about the available properties. NOTE: showImageLegend must be set to true for these properties to have any effect. | |
imageLegendProps | Object | Passthrough properties for the Legend component in the underlying chart library. See Recharts.org for more information. | |
showImageLegend | Boolean | false | When true , the chart legend will be drawn. NOTE: The chart legend itself is not accessible so it is typically only used when the associated table data is either in a linked table or is not immediately visible. |
showTooltip | Boolean | false | When true , the chart tooltip feature will be enabled. NOTE: The chart tooltip is not accessible so it is only used to augment functionality for users without sight or motor skill impairments. |
tableLegendExternalId | String | The DOM ID of a data table on the page that contains the data found in the chart. Setting this property will not render the companion data table, but rather link the chart to the table with this ID. | |
tableLegendPosition | Object | The position of the companion data table relative to the chart. See tableLegendPosition for details about the available properties. | |
tableLegendWidth | String | 'auto' | Will be set as an inline width style on the companion data table. Make sure to include the unit with any value (e.g. ‘400px’ or ‘100%’). |
tooltipProps | Object | Passthrough properties for the Tooltip component in the underlying chart library. See Recharts.org for more information. |
Property | Type | Default | Description |
---|---|---|---|
justify | String | 'center' | Justification of the table within the data table container. Available values are 'start' , 'center' , 'end' . If using a placement of top or bottom , these values will go from left to right, otherwise they will go from top to bottom. |
placement | String | 'right' | Placement of the data table container relative to the chart. Available values are 'top' , 'bottom' , 'left' , 'right' . |
Property | Type | Default | Description |
---|---|---|---|
align | String | 'center' | Horizontal alignment of the legend relative to the chart. Available values are 'left' , 'center' , 'right' . |
verticalAlign | String | 'bottom' | Vertical alignment of the legend relative to the chart. Available values are 'top' , 'middle' , 'bottom' . |
Property | Type | Default | Description |
---|---|---|---|
dataKey | String, Number or Function | Required | The key of each sector’s value (in the data property). |
data | Array | Source data for the chart and associated data table. | |
dataKeyLabel | String | Localized text label for the collection of data keys (values). | |
nameKey | String, Number or Function | 'name' | The key of each sector’s name (in the data property). |
nameKeyLabel | String | Localized text label for the collection of name keys (names). |
Property | Parameters | Description |
---|---|---|
valueFormatter | value (Number), name (String), payload (Object) | Function to format values on the companion data table and the tooltip, if used. |
See Recharts.org for more information.
Consumers of donut charts must:
By default, CoreUI components help assistive technology read a donut chart’s content by building the following into the default component: