React

Donut utilization

ExamplesProps

Examples

Simple donut utilization chart

75%of 100 GBps
Copied to clipboard

Simple donut utilization chart with right-aligned legend

0%of 100 GBpsGBps capacity - 0%Unused
Copied to clipboard

Simple, green donut utilization chart with right-aligned legend

0%of 100 GBpsGBps capacity - 0%Unused
Copied to clipboard

Simple donut utilization chart with bottom-aligned legend

45%of 100 GBpsGBps capacity - 45%Unused
Copied to clipboard

Simple donut utilization chart with left-aligned legend

45%of 100 GBpsGBps capacity - 45%Unused
Copied to clipboard

Donut utilization chart with static thresholds

45%of 100 GBps
Copied to clipboard

Donut utilization chart with static thresholds and right-aligned legend

0%of 100 GBpsGBps capacity - 0%Warning threshold at - 60%Danger threshold at - 90%
Copied to clipboard

Green donut utilization chart with static thresholds and right-aligned legend

0%of 100 GBpsGBps capacity - 0%Warning threshold at - 60%Danger threshold at - 90%
Copied to clipboard

Donut utilization chart with static thresholds and bottom-aligned legend

45%of 100 GBpsGBps capacity - 45%Warning threshold at - 60%Danger threshold at - 90%
Copied to clipboard

Donut utilization chart with static thresholds and left-aligned legend

45%of 100 GBpsGBps capacity - 45%Warning threshold at - 60%Danger threshold at - 90%
Copied to clipboard

Props

ChartDonutThreshold Props

The ChartDonutThreshold component accepts the following props.

NameTypeRequiredDefaultDescription
anySee Victory type docs: https://formidable.com/open-source/victory/docs/victory-pie/
animateAnimatePropTypeInterfaceThe animate prop specifies props for VictoryAnimation to use. The animate prop should also be used to specify enter and exit transition configurations with the `onExit` and `onEnter` namespaces respectively. @example {duration: 500, onExit: () => {}, onEnter: {duration: 500, before: () => ({y: 0})})}
categoriesCategoryPropTypeThe categories prop specifies how categorical data for a chart should be ordered. This prop should be given as an array of string values, or an object with these arrays of values specified for x and y. If this prop is not set, categorical data will be plotted in the order it was given in the data array @example ["dogs", "cats", "mice"]
childrenReact.ReactElement<any>The utilization donut chart to render with the threshold donut chart
colorScaleColorScalePropTypeThe colorScale prop is an optional prop that defines the color scale the pie will be created on. This prop should be given as an array of CSS colors, or as a string corresponding to one of the built in color scales. ChartDonutThreshold will automatically assign values from this color scale to the pie slices unless colors are explicitly provided in the data object
containerComponentReact.ReactElement<any>The containerComponent prop takes an entire component which will be used to create a container element for standalone charts. The new element created from the passed containerComponent wil be provided with these props from ChartDonutThreshold: height, width, children (the chart itself) and style. Props that are not provided by the child chart component include title and desc, both of which are intended to add accessibility to Victory components. The more descriptive these props are, the more accessible your data will be for people using screen readers. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If a dataComponent is not provided, ChartDonutThreshold will use the default ChartContainer component. @example <ChartContainer title="Chart of Dog Breeds" desc="This chart shows ..." />
cornerRadiusnumberSet the cornerRadius for every dataComponent (Slice by default) within ChartDonutThreshold
dataany[][]The data prop specifies the data to be plotted, where data X-value is the slice label (string or number), and Y-value is the corresponding number value represented by the slice Data should be in the form of a single data point. The data point may be any format you wish (depending on the `x` and `y` accessor props), but by default, an object with x and y properties is expected. Note: The Y-value is expected to represent a percentage @example data={[{ x: 'Warning at 60%', y: 60 }, { x: 'Danger at 90%', y: 90 }]}
dataComponentReact.ReactElement<any>The dataComponent prop takes an entire, HTML-complete data component which will be used to create slices for each datum in the pie chart. The new element created from the passed dataComponent will have the property datum set by the pie chart for the point it renders; properties style and pathFunction calculated by ChartDonutThreshold; an index property set corresponding to the location of the datum in the data provided to the pie; events bound to the ChartDonutThreshold; and the d3 compatible slice object. If a dataComponent is not provided, ChartDonutThreshold's Slice component will be used.
donutHeightnumbertheme.pie.heightSpecifies the height of the donut threshold chart. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: The parent container must be set to the same height in order to maintain the aspect ratio. Otherwise, the innerRadius may need to be set when using this property.
donutOrientation'left' | 'right' | 'top''left'The orientation of the donut chart in relation to the legend. Valid values are 'left', 'top', and 'right'
donutWidthnumbertheme.pie.widthSpecifies the width of the donut chart. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: The parent container must be set to the same height in order to maintain the aspect ratio. Otherwise, the innerRadius may need to be set when using this property.
endAnglenumberThe overall end angle of the pie in degrees. This prop is used in conjunction with startAngle to create a pie that spans only a segment of a circle.
eventKeyStringOrNumberOrCallbackSimilar to data accessor props `x` and `y`, this prop may be used to functionally assign eventKeys to data
eventsEventPropTypeInterface<"data" | "labels" | "parent", StringOrNumberOrCallback | string[] | number[]>[]The event prop takes an array of event objects. Event objects are composed of a target, an eventKey, and eventHandlers. Targets may be any valid style namespace for a given component, so "data" and "labels" are all valid targets for ChartDonutThreshold events. The eventKey may optionally be used to select a single element by index rather than an entire set. The eventHandlers object should be given as an object whose keys are standard event names (i.e. onClick) and whose values are event callbacks. The return value of an event handler is used to modify elemnts. The return value should be given as an object or an array of objects with optional target and eventKey keys, and a mutation key whose value is a function. The target and eventKey keys will default to those corresponding to the element the event handler was attached to. The mutation function will be called with the calculated props for the individual selected element (i.e. a single bar), and the object returned from the mutation function will override the props of the selected element via object assignment. @examples events={[ { target: "data", eventKey: 1, eventHandlers: { onClick: () => { return [ { eventKey: 2, mutation: (props) => { return {style: merge({}, props.style, {fill: "orange"})}; } }, { eventKey: 2, target: "labels", mutation: () => { return {text: "hey"}; } } ]; } } } ]}
externalEventMutationsany[]ChartDonutThreshold uses the standard externalEventMutations prop.
groupComponentReact.ReactElement<any>The groupComponent prop takes an entire component which will be used to create group elements for use within container elements. This prop defaults to a <g> tag on web, and a react-native-svg <G> tag on mobile
heightnumbertheme.pie.heightSpecifies the height the svg viewBox of the chart container. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: innerRadius may need to be set when using this property.
innerRadiusnumber((donutHeight || donutWidth) - 34) / 2When creating a donut chart, this prop determines the number of pixels between the center of the chart and the inner edge of a donut. When this prop is set to zero a regular pie chart is rendered.
labelRadiusnumberThe labelRadius prop defines the radius of the arc that will be used for positioning each slice label. If this prop is not set, the label radius will default to the radius of the pie + label padding.
labelsstring[] | ((data: any) => string)The labels prop defines labels that will appear above each bar in your chart. This prop should be given as an array of values or as a function of data. If given as an array, the number of elements in the array should be equal to the length of the data array. Labels may also be added directly to the data object like data={[{x: 1, y: 1, label: "first"}]}. @example ["spring", "summer", "fall", "winter"], (datum) => datum.title
namestringThe name prop is used to reference a component instance when defining shared events.
origin{ x: number, y: number }Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. **This prop should not be set manually.**
padAnglenumberThe padAngle prop determines the amount of separation between adjacent data slices in number of degrees
paddingPaddingPropsThe padding props specifies the amount of padding in number of pixels between the edge of the chart and any rendered child components. This prop can be given as a number or as an object with padding specified for top, bottom, left and right.
radiusnumberSpecifies the radius of the chart. If this property is not provided it is computed from width, height, and padding props
sharedEventsanyThe sharedEvents prop is used internally to coordinate events between components. It should not be set manually.
showStaticbooleanThis will show the static, unused portion of the donut chart
sortKeystring | string[] | FunctionUse the sortKey prop to indicate how data should be sorted. This prop is given directly to the lodash sortBy function to be executed on the final dataset.
sortOrder'ascending' | 'descending'The sortOrder prop specifies whether sorted data should be returned in ascending or descending order.
standalonebooleantrueThe standalone prop determines whether the component will render a standalone svg or a <g> tag that will be included in an external svg. Set standalone to false to compose ChartDonutThreshold with other components within an enclosing <svg> tag.
startAnglenumberThe overall start angle of the pie in degrees. This prop is used in conjunction with endAngle to create a pie that spans only a segment of a circle.
styleVictoryStyleInterfaceThe style prop specifies styles for your pie. ChartDonutThreshold relies on Radium, so valid Radium style objects should work for this prop. Height, width, and padding should be specified via the height, width, and padding props. @example {data: {stroke: "black"}, label: {fontSize: 10}}
subTitlestringThe subtitle for the donut chart
themeChartThemeDefinitiongetDonutThresholdStaticTheme(themeColor, themeVariant)The theme prop takes a style object with nested data, labels, and parent objects. You can create this object yourself, or you can use a theme provided by When using ChartDonutThreshold as a solo component, implement the theme directly on ChartDonutThreshold. If you are wrapping ChartDonutThreshold in ChartChart or ChartGroup, please call the theme on the outermost wrapper component instead.
themeColorstringSpecifies the theme color. Valid values are 'blue', 'green', 'grey' (recomended), 'multi', etc. Note: Not compatible with theme prop @example themeColor={ChartThemeColor.blue}
themeVariantstringSpecifies the theme variant. Valid values are 'dark' or 'light' Note: Not compatible with theme prop @example themeVariant={ChartThemeVariant.light}
titlestringThe title for the donut chart
thresholdsany[]The dynamic portion of the chart will change colors when data reaches the given threshold. Colors may be overridden, but defaults shall be provided. @example thresholds={[{ value: 60, color: '#F0AB00' }, { value: 90, color: '#C9190B' }]}
widthnumbertheme.pie.widthSpecifies the width of the svg viewBox of the chart container. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: innerRadius may need to be set when using this property.
xDataGetterPropTypeThe x prop specifies how to access the X value of each data point. If given as a function, it will be run on each data point, and returned value will be used. If given as an integer, it will be used as an array index for array-type data points. If given as a string, it will be used as a property key for object-type data points. If given as an array of strings, or a string containing dots or brackets, it will be used as a nested object property path (for details see Lodash docs for _.get). If `null` or `undefined`, the data value will be used as is (identity function/pass-through). @example 0, 'x', 'x.value.nested.1.thing', 'x[2].also.nested', null, d => Math.sin(d)
yDataGetterPropTypeThe y prop specifies how to access the Y value of each data point. If given as a function, it will be run on each data point, and returned value will be used. If given as an integer, it will be used as an array index for array-type data points. If given as a string, it will be used as a property key for object-type data points. If given as an array of strings, or a string containing dots or brackets, it will be used as a nested object property path (for details see Lodash docs for _.get). If `null` or `undefined`, the data value will be used as is (identity function/pass-through). @example 0, 'y', 'y.value.nested.1.thing', 'y[2].also.nested', null, d => Math.sin(d)

ChartDonutUtilization Props

The ChartDonutUtilization component accepts the following props.

NameTypeRequiredDefaultDescription
anySee Victory type docs: https://formidable.com/open-source/victory/docs/victory-pie/
animateAnimatePropTypeInterfaceThe animate prop specifies props for VictoryAnimation to use. The animate prop should also be used to specify enter and exit transition configurations with the `onExit` and `onEnter` namespaces respectively. @example {duration: 500, onExit: () => {}, onEnter: {duration: 500, before: () => ({y: 0})})}
categoriesCategoryPropTypeThe categories prop specifies how categorical data for a chart should be ordered. This prop should be given as an array of string values, or an object with these arrays of values specified for x and y. If this prop is not set, categorical data will be plotted in the order it was given in the data array @example ["dogs", "cats", "mice"]
colorScaleColorScalePropTypeThe colorScale prop is an optional prop that defines the color scale the pie will be created on. This prop should be given as an array of CSS colors, or as a string corresponding to one of the built in color scales. ChartDonutUtilization will automatically assign values from this color scale to the pie slices unless colors are explicitly provided in the data object
containerComponentReact.ReactElement<any>The containerComponent prop takes an entire component which will be used to create a container element for standalone charts. The new element created from the passed containerComponent wil be provided with these props from ChartDonutUtilization: height, width, children (the chart itself) and style. Props that are not provided by the child chart component include title and desc, both of which are intended to add accessibility to Victory components. The more descriptive these props are, the more accessible your data will be for people using screen readers. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If a dataComponent is not provided, ChartDonutUtilization will use the default ChartContainer component. @example <ChartContainer title="Chart of Dog Breeds" desc="This chart shows ..." />
cornerRadiusnumberSet the cornerRadius for every dataComponent (Slice by default) within ChartDonutUtilization
dataanyThe data prop specifies the data to be plotted, where data X-value is the slice label (string or number), and Y-value is the corresponding number value represented by the slice Data should be in the form of a single data point. The data point may be any format you wish (depending on the `x` and `y` accessor props), but by default, an object with x and y properties is expected. Note: The Y-value is expected to represent a percentage @example data={{ x: 'GBps capacity', y: 75 }}
dataComponentReact.ReactElement<any>The dataComponent prop takes an entire, HTML-complete data component which will be used to create slices for each datum in the pie chart. The new element created from the passed dataComponent will have the property datum set by the pie chart for the point it renders; properties style and pathFunction calculated by ChartDonutUtilization; an index property set corresponding to the location of the datum in the data provided to the pie; events bound to the ChartDonutUtilization; and the d3 compatible slice object. If a dataComponent is not provided, ChartDonutUtilization's Slice component will be used.
donutDxnumber0Defines a horizontal shift from the x coordinate. This should not be set manually.
donutDynumber0Defines a vertical shift from the y coordinate. This should not be set manually.
donutHeightnumbertheme.pie.heightSpecifies the height of the donut chart. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: The parent container must be set to the same height in order to maintain the aspect ratio. Otherwise, the innerRadius may need to be set when using this property.
donutOrientation'left' | 'right' | 'top''left'The orientation of the donut chart in relation to the legend. Valid values are 'left', 'top', and 'right'
donutWidthnumbertheme.pie.widthSpecifies the width of the donut chart. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: The parent container must be set to the same height in order to maintain the aspect ratio. Otherwise, the innerRadius may need to be set when using this property.
endAnglenumberThe overall end angle of the pie in degrees. This prop is used in conjunction with startAngle to create a pie that spans only a segment of a circle.
eventKeyStringOrNumberOrCallbackSimilar to data accessor props `x` and `y`, this prop may be used to functionally assign eventKeys to data
eventsEventPropTypeInterface<"data" | "labels" | "parent", StringOrNumberOrCallback | string[] | number[]>[]The event prop takes an array of event objects. Event objects are composed of a target, an eventKey, and eventHandlers. Targets may be any valid style namespace for a given component, so "data" and "labels" are all valid targets for ChartDonutUtilization events. The eventKey may optionally be used to select a single element by index rather than an entire set. The eventHandlers object should be given as an object whose keys are standard event names (i.e. onClick) and whose values are event callbacks. The return value of an event handler is used to modify elemnts. The return value should be given as an object or an array of objects with optional target and eventKey keys, and a mutation key whose value is a function. The target and eventKey keys will default to those corresponding to the element the event handler was attached to. The mutation function will be called with the calculated props for the individual selected element (i.e. a single bar), and the object returned from the mutation function will override the props of the selected element via object assignment. @examples events={[ { target: "data", eventKey: 1, eventHandlers: { onClick: () => { return [ { eventKey: 2, mutation: (props) => { return {style: merge({}, props.style, {fill: "orange"})}; } }, { eventKey: 2, target: "labels", mutation: () => { return {text: "hey"}; } } ]; } } } ]}
externalEventMutationsany[]ChartDonutUtilization uses the standard externalEventMutations prop.
groupComponentReact.ReactElement<any>The groupComponent prop takes an entire component which will be used to create group elements for use within container elements. This prop defaults to a <g> tag on web, and a react-native-svg <G> tag on mobile
heightnumbertheme.pie.heightSpecifies the height the svg viewBox of the chart container. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: innerRadius may need to be set when using this property.
innerRadiusnumber((donutHeight || donutWidth) - 34) / 2When creating a donut chart, this prop determines the number of pixels between the center of the chart and the inner edge of a donut. When this prop is set to zero a regular pie chart is rendered.
labelComponentReact.ReactElement<any>The labelComponent prop takes in an entire label component which will be used to create a label for the area. The new element created from the passed labelComponent will be supplied with the following properties: x, y, index, data, verticalAnchor, textAnchor, angle, style, text, and events. any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If labelComponent is omitted, a new ChartLabel will be created with props described above. This labelComponent prop should be used to provide a series label for ChartDonutUtilization. If individual labels are required for each data point, they should be created by composing ChartDonutUtilization with VictoryScatter
labelPosition'startAngle' | 'endAngle' | 'centroid'The labelPosition prop specifies the angular position of each label relative to its corresponding slice. When this prop is not given, the label will be positioned at the centroid of each slice.
legendComponentReact.ReactElement<any>The legend component to render with chart. This overrides other legend props.
legendDataany[]The data prop specifies the data to be plotted, where data X-value is the slice label (string or number), and Y-value is the corresponding number value represented by the slice Data should be in the form of an array of data points. Each data point may be any format you wish (depending on the `x` and `y` accessor props), but by default, an object with x and y properties is expected. Note: Not compatible with legendComponent prop. @example legendData={[{ name: `GBps capacity - 45%` }, { name: 'Unused' }]}
legendOrientation'horizontal' | 'vertical'DonutUtilizationStyles.legend.orientation as ChartDonutUtilizationLabelOrientationThe orientation prop takes a string that defines whether legend data are displayed in a row or column. When orientation is "horizontal", legend items will be displayed in a single row. When orientation is "vertical", legend items will be displayed in a single column. Line and text-wrapping is not currently supported, so "vertical" orientation is both the default setting and recommended for displaying many series of data. Note: May need to set legendHeight and legendWidth in order to position properly. Not compatible with legendComponent prop.
labelRadiusnumberThe labelRadius prop defines the radius of the arc that will be used for positioning each slice label. If this prop is not set, the label radius will default to the radius of the pie + label padding.
labelsstring[] | ((data: any) => string)The labels prop defines labels that will appear above each bar in your chart. This prop should be given as an array of values or as a function of data. If given as an array, the number of elements in the array should be equal to the length of the data array. Labels may also be added directly to the data object like data={[{x: 1, y: 1, label: "first"}]}. @example ["spring", "summer", "fall", "winter"], (datum) => datum.title
namestringThe name prop is used to reference a component instance when defining shared events.
origin{ x: number, y: number }Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. **This prop should not be set manually.**
padAnglenumberThe padAngle prop determines the amount of separation between adjacent data slices in number of degrees
paddingPaddingPropsThe padding props specifies the amount of padding in number of pixels between the edge of the chart and any rendered child components. This prop can be given as a number or as an object with padding specified for top, bottom, left and right.
radiusnumberSpecifies the radius of the chart. If this property is not provided it is computed from width, height, and padding props
sharedEventsanyThe sharedEvents prop is used internally to coordinate events between components. It should not be set manually.
showStaticbooleantrueThis will show the static, unused portion of the donut chart
sortKeystring | string[] | FunctionUse the sortKey prop to indicate how data should be sorted. This prop is given directly to the lodash sortBy function to be executed on the final dataset.
sortOrder'ascending' | 'descending'The sortOrder prop specifies whether sorted data should be returned in ascending or descending order.
standalonebooleantrueThe standalone prop determines whether the component will render a standalone svg or a <g> tag that will be included in an external svg. Set standalone to false to compose ChartDonutUtilization with other components within an enclosing <svg> tag.
startAnglenumberThe overall start angle of the pie in degrees. This prop is used in conjunction with endAngle to create a pie that spans only a segment of a circle.
styleVictoryStyleInterfaceThe style prop specifies styles for your pie. ChartDonutUtilization relies on Radium, so valid Radium style objects should work for this prop. Height, width, and padding should be specified via the height, width, and padding props. @example {data: {stroke: "black"}, label: {fontSize: 10}}
subTitlestringThe subtitle for the donut chart
themeChartThemeDefinitiongetDonutUtilizationTheme(themeColor, themeVariant)The theme prop takes a style object with nested data, labels, and parent objects. You can create this object yourself, or you can use a theme provided by When using ChartDonutUtilization as a solo component, implement the theme directly on ChartDonutUtilization. If you are wrapping ChartDonutUtilization in ChartChart, ChartGroup, or ChartThreshold please call the theme on the outermost wrapper component instead.
themeColorstringSpecifies the theme color. Valid values are 'blue', 'green', 'grey' (recomended), 'multi', etc. Note: Not compatible with theme prop @example themeColor={ChartThemeColor.blue}
themeVariantstringSpecifies the theme variant. Valid values are 'dark' or 'light' Note: Not compatible with theme prop @example themeVariant={ChartThemeVariant.light}
titlestringThe title for the donut chart
thresholdsany[]The dynamic portion of the chart will change colors when data reaches the given threshold. Colors may be overridden, but defaults shall be provided. @example thresholds={[{ value: 60, color: '#F0AB00' }, { value: 90, color: '#C9190B' }]}
widthnumbertheme.pie.widthSpecifies the width of the svg viewBox of the chart container. This value should be given as a number of pixels. Because Victory renders responsive containers, the width and height props do not determine the width and height of the chart in number of pixels, but instead define an aspect ratio for the chart. The exact number of pixels will depend on the size of the container the chart is rendered into. Note: innerRadius may need to be set when using this property.
xDataGetterPropTypeThe x prop specifies how to access the X value of each data point. If given as a function, it will be run on each data point, and returned value will be used. If given as an integer, it will be used as an array index for array-type data points. If given as a string, it will be used as a property key for object-type data points. If given as an array of strings, or a string containing dots or brackets, it will be used as a nested object property path (for details see Lodash docs for _.get). If `null` or `undefined`, the data value will be used as is (identity function/pass-through). @example 0, 'x', 'x.value.nested.1.thing', 'x[2].also.nested', null, d => Math.sin(d)
yDataGetterPropTypeThe y prop specifies how to access the Y value of each data point. If given as a function, it will be run on each data point, and returned value will be used. If given as an integer, it will be used as an array index for array-type data points. If given as a string, it will be used as a property key for object-type data points. If given as an array of strings, or a string containing dots or brackets, it will be used as a nested object property path (for details see Lodash docs for _.get). If `null` or `undefined`, the data value will be used as is (identity function/pass-through). @example 0, 'y', 'y.value.nested.1.thing', 'y[2].also.nested', null, d => Math.sin(d)