Pie / Donut Chart
A pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportions. You can also make a variation of pieChart ( donutChart) from pieChart API.
Usage
2 . Add data or URL to PieChart component.
Example
PieChart: Demo
DonutChart: Demo
Click here for more variations of pie chart.
Props
Note: External props are mostly derived from react-vis & K2. All external props are linked. You can click highlighted props to get more details from official site.
Property | Type | Required | Default value | Description |
---|---|---|---|---|
data | PieChartData[] | yes | Data for the chart. | |
radial | RadialProps | no | None | Adjust radial properties. |
title | JSX.Element | string | no | None | Title of the chart. |
animate | boolean | no | true | Enable the animation. |
colors | {[theme-name: e.g "light" or "dark"] : string[] | GradientColor[] | no | None | Colors of chart in different theme modes. |
label | boolean | LabelComponent | no | true | Enable or customize the labels |
labelTickWidth | number | no | 1.25 | Lenth of label tick. |
centerLabel | boolean | CenterLabelComponent | no | true | Enable or customize the Center label. |
legends | boolean | LegendsProps | no | true | Enable or customize the legends. |
tooltip | boolean | TooltipProps | no | true | Enable or customize the tooltip. |
width | number | no | 300 | Width of chart. |
height | number | no | 300 | Height of chart. |
onClick | (event: { data:TransformedData}) => void | no | None | Callback for Slice click. |
style | CSSProperties | no | None | Styles applied to the root element of chart. |
className | string | no | None | Class applied to the root element of chart. |
classes | Classes | no | None | Classes of chart. |
PieChart is wrapped with fetchData HoC, to perform data handling tasks, which adds support for some additional props.
Custom Types
PieChartData
Here is the format of the data accepted by PieChart.
TransformedData
RadialProps
This is a prop to adjust anglePadding and innerRadius of the chart.
LabelComponent
This is a type of custom label component. You can create a custom label component by this.
CenterLabelComponent
This is type of custom centerlabel component. You can create a custom centerlabel component by this.
GradientColor
Type of GradientColor object.
Classes
Classes enable customization and styling of chart elements through their classes.
ClassName | Type | Required | Default value | Description |
---|---|---|---|---|
root | string | no | None | Applied to root element of chart. |
header | string | no | None | Applied to header of chart. |
title | string | no | None | Applied to title of chart. |
legends | string | no | None | Applied to legends of chart. |
tooltip | string | no | None | Applied to tooltip of chart. |
xyplot | string | no | None | Applied to svg component of chart. |
arc | string | no | None | Applied to arc path of chart. |
label | string | no | None | Applied to label of chart. |
centerlabel | string | no | None | Applied to centerLabel of chart. |
Please see Class Specificity for correctly defining it.