본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Donut Utilization Chart

원문 보기 위키 갱신

도넛 활용도 차트(Donut utilization chart)는 저장 공간 같은 리소스의 사용률을 시각화하는 차트예요. 다양한 범례 배치와 정적 임계값(threshold) 예시를 제공해요.

출처: 문서

본문

소개

참고: PatternFly React charts live in its own package at @patternfly/react-charts! 아래 예시들은 Victory 차트 라이브러리를 기반으로 하며, PatternFly를 위한 추가 기능, 사용자 지정 컴포넌트, 테마가 함께 포함되어 있어요. 이를 통해 일관된 마크업, 스타일, 동작으로 PatternFly 패턴을 만들 수 있는 React 기반 컴포넌트 모음을 제공해요.

도넛 활용도 예시

기본

Donut utilization chart exampleStorage capacity75%of 100 GBps

오른쪽 정렬 범례

Donut utilization chart exampleStorage capacityStorage capacity: 0%Unused0%of 100 GBps

오른쪽 정렬 범례가 있는 역방향

Donut utilization chart exampleStorage capacityStorage capacity: 0%Unused0%of 100 GBps

오른쪽 정렬 세로 범례

Donut utilization chart exampleStorage capacityStorage capacity: 0%Unused0%of 100 GBps

아래 정렬 범례

Donut utilization chart exampleStorage capacityStorage capacity: 45%Unused45%of 100 GBps

Small

Donut utilization chart exampleStorage capacity75%of 100 GBps

오른쪽 정렬 범례가 있는 소형

Donut utilization chart exampleStorage capacityStorage capacity: 0%Unused0%of 100 GBps

아래 정렬 부제목이 있는 소형

아래 정렬 범례와 오른쪽 정렬 부제목을 가진 소형 도넛 활용도 차트입니다.

Donut utilization chart exampleStorage capacityStorage capacity: 45%Unused45%of 100 GBps

오른쪽 정렬 부제목이 있는 소형

Donut utilization chart exampleStorage capacityStorage capacity: 45%Unused45%of 100 GBps

도넛 활용도 임계값 예시

정적 임계값

Donut utilization chart with static threshold exampleStorage capacity45%of 100 GBps

정적 임계값 with right aligned legend

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 0%Warning threshold at 60%Danger threshold at 90%0%of 100 GBps

오른쪽 정렬 범례가 있는 역방향 정적 임계값

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 100%Warning threshold at 60%Danger threshold at 20%100%of 100 GBps

정적 임계값 with custom legend

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 0%Warning threshold at 60%Danger threshold at 90%0%of 100 GBps

정적 임계값 with bottom aligned legend

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 45%Warning threshold at 60%Danger threshold at 90%45%of 100 GBps

정적 임계값이 있는 소형

Donut utilization chart with static threshold exampleStorage capacity45%of 100 GBps

정적 임계값이 있는 소형 and right aligned legend

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 0%Warning threshold at 60%Danger threshold at 90%0%of 100 GBps

부제목이 있는 소형

오른쪽 정렬 범례와 아래 정렬 부제목, 정적 임계값을 가진 소형 도넛 활용도 차트입니다.

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 45%Warning threshold at 60%Danger threshold at 90%45%of 100 GBps

임계값과 오른쪽 정렬 부제목이 있는 소형

Donut utilization chart with static threshold exampleStorage capacityStorage capacity: 45%Warning threshold at 60%Danger threshold at 90%45%of 100 GBps

문서

팁

  • Victory의 FAQ를 참고하세요.

  • For single data points or zero values, you may want to set the domain prop

  • ChartLegend may be used as a standalone component, instead of using legendData

참고

현재 아래 생성된 문서는 Victory import에서 타입 정의를 해석하지 못합니다. 위 예시에서 사용된 컴포넌트에 대한 Victory 패스스루(pass-thru) 속성도 여기에 문서화되어 있습니다: components used in the examples above, Victory pass-thru props are also documented here:

Props

ChartDonutThreshold

ChartDonutThreshold renders a dataset as a donut threshold chart.

See https://github.com/FormidableLabs/victory/blob/main/packages/victory-pie/src/index.d.ts

*required | | Name | Type | Default | Description | allowTooltip | boolean | true | Specifies the tooltip capability of the container component. A value of true allows the chart to add a ChartTooltip component to the labelComponent property. This is a shortcut to display tooltips when the labels property is also provided.

| animate | boolean | object | | The 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})})}

| ariaDesc | string | | The ariaDesc prop specifies the description of the chart/SVG to assist with accessibility for screen readers.

참고: Overridden by the desc prop of containerComponent

| ariaTitle | string | | The ariaTitle prop specifies the title to be applied to the SVG to assist accessibility for screen readers.

참고: Overridden by the title prop of containerComponent

| capHeight | number | string | Function | | The capHeight prop defines a text metric for the font being used: the expected height of capital letters. This is necessary because of SVG, which (a) positions the bottom of the text at y, and (b) has no notion of line height. The value should ideally use the same units as lineHeight and dy, preferably ems. If given a unitless number, it is assumed to be ems.

| categories | string[] | { x: string[], y: string[] } | | The 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"]

| colorScale | string[] | | The 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. ChartPie will automatically assign values from this color scale to the pie slices unless colors are explicitly provided in the data object

| constrainToVisibleArea | boolean | false | The constrainToVisibleArea prop determines whether to coerce tooltips so that they fit within the visible area of the chart. When this prop is set to true, tooltip pointers will still point to the correct data point, but the center of the tooltip will be shifted to fit within the overall width and height of the svg Victory renders.

| containerComponent | React.ReactElement | | 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 ChartPie: 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, ChartPie will use the default ChartContainer component.

@example

| cornerRadius | number | Function | | Set the cornerRadius for every dataComponent (Slice by default) within ChartPie

| data | any[] | [] | 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.

@example [{x: 1, y: 2}, {x: 2, y: 3}], [[1, 2], [2, 3]], [[{x: "a", y: 1}, {x: "b", y: 2}], [{x: "a", y: 2}, {x: "b", y: 3}]]

| dataComponent | React.ReactElement | | 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 ChartPie; an index property set corresponding to the location of the datum in the data provided to the pie; events bound to the ChartPie; and the d3 compatible slice object. If a dataComponent is not provided, ChartPie's Slice component will be used.

| desc | string | | The desc prop specifies the description of the chart/SVG to assist with accessibility for screen readers. The more info about the chart provided in the description, the more usable it will be for people using screen readers. This prop defaults to an empty string.

참고: Overridden by containerComponent

@example "Golden retrievers make up 30%, Labs make up 25%, and other dog breeds are not represented above 5% each."

| endAngle | number | | The 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.

| eventKey | number | string | Function | | Similar to data accessor props x and y, this prop may be used to functionally assign eventKeys to data

| events | object[] | | 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 ChartPie 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 elements. 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.

@example 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"}; } } ]; } } } ]}

| externalEventMutations | object[] | | ChartPie uses the standard externalEventMutations prop.

| groupComponent | React.ReactElement | | 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 tag on web, and a react-native-svg tag on mobile

| hasPatterns | boolean | boolean[] | | The hasPatterns prop is an optional prop that indicates whether a pattern is shown for a chart. SVG patterns are dynamically generated (unique to each chart) in order to apply colors from the selected color theme or custom color scale. Those generated patterns are applied in a specific order (via a URL), similar to the color theme ordering defined by PatternFly. If the multi-color theme was in use; for example, colorized patterns would be displayed in that same order. Create custom patterns via the patternScale prop.

참고: Not all components are supported; for example, ChartLine, ChartBullet, ChartThreshold, etc.

@example hasPatterns={ true } @example hasPatterns={[ true, true, false ]}

| height | number | theme.pie.height | Specifies 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.

참고: When adding a legend, height (the overall SVG height) may need to be larger than pieHeight (the pie size) in order to accommodate the extra legend.

By default, pieHeight is the min. of either height or width. This covers most use cases in order to accommodate legends within the same SVG. However, pieHeight (not height) may need to be set in order to adjust the pie height.

Typically, the parent container is set to the same width in order to maintain the aspect ratio.

| innerRadius | number | Function | | When creating a donut chart, this prop determines the number of pixels between the center of the chart and the inner edge. When this prop is set to zero a regular pie chart is rendered.

| invert | boolean | false | Invert the threshold color scale used to represent warnings, errors, etc.

| labelComponent | React.ReactElement | | 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 ChartPie. If individual labels are required for each data point, they should be created by composing ChartPie with VictoryScatter

| labelPosition | string | Function | | The labelPosition prop specifies the angular position of each label relative to its corresponding slice. This prop should be given as "startAngle", "endAngle", "centroid", or as a function that returns one of these values. When this prop is not given, the label will be positioned at the centroid of each slice.

| labelRadius | number | Function | | The 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.

| labels | string[] | number[] | ((data: any) => string | number | null) | [] | 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

| legendAllowWrap | boolean | ((extraHeight: number) => void) | | Allows legend items to wrap onto the next line if the chart is not wide enough.

참고 that the chart's SVG height and width are 100% by default, so it can be responsive itself. However, if you define the height and width of the chart's parent container, you must accommodate for extra legend height due to legend items wrapping onto the next line. When the height of the chart's parent container is too small, some legend items may not be visible.

Alternatively, a callback function may be provided, which will be called after the legend's itemsPerRow property has been calculated. The value provided can be used to increase the chart's parent container height as legend items wrap onto the next line. If no adjustment is necessary, the value will be zero.

참고: This is overridden by the legendItemsPerRow property

| legendComponent | React.ReactElement | | The legend component to render with chart.

참고: Use legendData so the legend width can be calculated and positioned properly. Default legend properties may be applied

| legendData | { name?: string; symbol?: { fill?: string; type?: string; }; }[] | | Specify data via the data prop. ChartLegend expects data as an array of objects with name (required), symbol, and labels properties. The data prop must be given as an array.

@example legendData={[{ name: GBps capacity - 45% }, { name: 'Unused' }]}

| legendDirection | 'ltr' | 'rtl' | | Text direction of the legend labels.

| legendOrientation | 'horizontal' | 'vertical' | | The 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.

| legendPosition | 'bottom' | 'right' | | The legend position relation to the pie chart. Valid values are 'bottom' and 'right'

참고: When adding a legend, padding may need to be adjusted in order to accommodate the extra legend. In some cases, the legend may not be visible until enough padding is applied.

| name | string | | The name prop is typically used to reference a component instance when defining shared events. However, this optional prop may also be applied to child elements as an ID prefix. This is a workaround to ensure Victory based components output unique IDs when multiple charts appear in a page.

| origin | { x: number, y: number } | | Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts.

참고: It will not typically be necessary to set an origin prop manually

| padAngle | number | Function | | The padAngle prop determines the amount of separation between adjacent data slices in number of degrees

| padding | number | { top: number, bottom: number, left: number, right: number } | | The 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.

| patternScale | string[] | | The patternScale prop is an optional prop that defines patterns to apply, where applicable. This prop should be given as a string array of pattern URLs. Patterns will be assigned to children by index and will repeat when there are more children than patterns in the provided patternScale. Use null to omit the pattern for a given index.

참고: Not all components are supported; for example, ChartLine, ChartBullet, ChartThreshold, etc.

@example patternScale={[ 'url("#pattern1")', 'url("#pattern2")', null ]}

| radius | number | Function | | Specifies the radius of the chart. If this property is not provided it is computed from width, height, and padding props

| sortKey | number | string | Function | string[] | | Use 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 | string | | The sortOrder prop specifies whether sorted data should be returned in 'ascending' or 'descending' order.

| standalone | boolean | true | The standalone prop determines whether the component will render a standalone svg or a tag that will be included in an external svg. Set standalone to false to compose ChartPie with other components within an enclosing

| startAngle | number | | The 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.

| style | { parent: object, data: object, labels: object } | | The style prop specifies styles for your pie. ChartPie 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}}

| subTitle | string | | The subtitle for the donut chart

| subTitleComponent | React.ReactElement | | The label component to render the chart subTitle.

When overriding the subTitleComponent prop, title and subTitle will be centered independently. You may choose to use the x and y props of ChartLabel to adjust the center position. For example:

subTitle="Pets"
subTitleComponent={}
title={100}
titleComponent={}

참고: Default label properties may be applied

| subTitlePosition | 'bottom' | 'center' | 'right' | "center" | The orientation of the subtitle position. Valid values are 'bottom', 'center', and 'right'

| theme | object | getDonutThresholdStaticTheme(themeColor, invert) | 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 ChartPie as a solo component, implement the theme directly on ChartPie. If you are wrapping ChartPie in ChartChart or ChartGroup, please call the theme on the outermost wrapper component instead.

| themeColor | string | | Specifies the theme color. Valid values are 'blue', 'green', 'multi', etc.

참고: Not compatible with theme prop

@example themeColor={ChartThemeColor.blue}

| title | string | | The title for the donut chart

| titleComponent | React.ReactElement | | The label component to render the chart title.

When centering both title and subTitle props, it's possible to override both styles via an array provided to ChartLabel. The first item in the array is associated with title styles, while the second item in the array is associated with subtitle styles.

subTitle="Pets"
title={100}
titleComponent={
  
}

In this case, both title and subTitle will be centered together. However, should you also override the subTitleComponent prop, title and subTitle will be centered independently. You may choose to use the x and y props of ChartLabel to adjust the center position. For example:

subTitle="Pets"
subTitleComponent={}
title={100}
titleComponent={}

참고: Default label properties may be applied

| width | number | theme.pie.width | Specifies 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. Typically, the parent container is set to the same width in order to maintain the aspect ratio.

| x | number | string | Function | string[] | | The 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)

| y | number | string | Function | string[] | | The 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

ChartDonutUtilization renders a dataset as a donut utilization chart.

See https://github.com/FormidableLabs/victory/blob/main/packages/victory-pie/src/index.d.ts

*required | | Name | Type | Default | Description | allowTooltip | boolean | true | Specifies the tooltip capability of the container component. A value of true allows the chart to add a ChartTooltip component to the labelComponent property. This is a shortcut to display tooltips when the labels property is also provided.

| animate | boolean | object | | The 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})})}

| ariaDesc | string | | The ariaDesc prop specifies the description of the chart/SVG to assist with accessibility for screen readers.

참고: Overridden by the desc prop of containerComponent

| ariaTitle | string | | The ariaTitle prop specifies the title to be applied to the SVG to assist accessibility for screen readers.

참고: Overridden by the title prop of containerComponent

| capHeight | number | string | Function | | The capHeight prop defines a text metric for the font being used: the expected height of capital letters. This is necessary because of SVG, which (a) positions the bottom of the text at y, and (b) has no notion of line height. The value should ideally use the same units as lineHeight and dy, preferably ems. If given a unitless number, it is assumed to be ems.

| categories | string[] | { x: string[], y: string[] } | | The 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"]

| colorScale | string[] | | The 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. ChartPie will automatically assign values from this color scale to the pie slices unless colors are explicitly provided in the data object

| constrainToVisibleArea | boolean | | The constrainToVisibleArea prop determines whether to coerce tooltips so that they fit within the visible area of the chart. When this prop is set to true, tooltip pointers will still point to the correct data point, but the center of the tooltip will be shifted to fit within the overall width and height of the svg Victory renders.

| containerComponent | React.ReactElement | | 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 ChartPie: 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, ChartPie will use the default ChartContainer component.

@example

| cornerRadius | number | Function | | Set the cornerRadius for every dataComponent (Slice by default) within ChartPie

| data | any | | 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.

@example [{x: 1, y: 2}, {x: 2, y: 3}], [[1, 2], [2, 3]], [[{x: "a", y: 1}, {x: "b", y: 2}], [{x: "a", y: 2}, {x: "b", y: 3}]]

| dataComponent | React.ReactElement | | 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 ChartPie; an index property set corresponding to the location of the datum in the data provided to the pie; events bound to the ChartPie; and the d3 compatible slice object. If a dataComponent is not provided, ChartPie's Slice component will be used.

| desc | string | | The desc prop specifies the description of the chart/SVG to assist with accessibility for screen readers. The more info about the chart provided in the description, the more usable it will be for people using screen readers. This prop defaults to an empty string.

참고: Overridden by containerComponent

@example "Golden retrievers make up 30%, Labs make up 25%, and other dog breeds are not represented above 5% each."

| endAngle | number | | The 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.

| eventKey | number | string | Function | | Similar to data accessor props x and y, this prop may be used to functionally assign eventKeys to data

| events | object[] | | 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 ChartPie 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 elements. 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.

@example 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"}; } } ]; } } } ]}

| externalEventMutations | object[] | | ChartPie uses the standard externalEventMutations prop.

| groupComponent | React.ReactElement | | 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 tag on web, and a react-native-svg tag on mobile

| hasPatterns | boolean | boolean[] | | The hasPatterns prop is an optional prop that indicates whether a pattern is shown for a chart. SVG patterns are dynamically generated (unique to each chart) in order to apply colors from the selected color theme or custom color scale. Those generated patterns are applied in a specific order (via a URL), similar to the color theme ordering defined by PatternFly. If the multi-color theme was in use; for example, colorized patterns would be displayed in that same order. Create custom patterns via the patternScale prop.

참고: Not all components are supported; for example, ChartLine, ChartBullet, ChartThreshold, etc.

@example hasPatterns={ true } @example hasPatterns={[ true, true, false ]}

| height | number | theme.pie.height | Specifies 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.

참고: When adding a legend, height (the overall SVG height) may need to be larger than pieHeight (the pie size) in order to accommodate the extra legend.

By default, pieHeight is the min. of either height or width. This covers most use cases in order to accommodate legends within the same SVG. However, pieHeight (not height) may need to be set in order to adjust the pie height.

Typically, the parent container is set to the same width in order to maintain the aspect ratio.

| innerRadius | number | Function | | When creating a donut chart, this prop determines the number of pixels between the center of the chart and the inner edge. When this prop is set to zero a regular pie chart is rendered.

| invert | boolean | false | Invert the threshold color scale used to represent warnings, errors, etc.

Instead of showing a warning at 60% and an error at 90%; for example, this would allow users to show a warning below 60% and an error below 20%

| labelComponent | React.ReactElement | | 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 ChartPie. If individual labels are required for each data point, they should be created by composing ChartPie with VictoryScatter

| labelPosition | string | Function | | The labelPosition prop specifies the angular position of each label relative to its corresponding slice. This prop should be given as "startAngle", "endAngle", "centroid", or as a function that returns one of these values. When this prop is not given, the label will be positioned at the centroid of each slice.

| labelRadius | number | Function | | The 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.

| labels | string[] | number[] | ((data: any) => string | number | null) | | 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

| legendAllowWrap | boolean | ((extraHeight: number) => void) | | Allows legend items to wrap onto the next line if the chart is not wide enough.

참고 that the chart's SVG height and width are 100% by default, so it can be responsive itself. However, if you define the height and width of the chart's parent container, you must accommodate for extra legend height due to legend items wrapping onto the next line. When the height of the chart's parent container is too small, some legend items may not be visible.

Alternatively, a callback function may be provided, which will be called after the legend's itemsPerRow property has been calculated. The value provided can be used to increase the chart's parent container height as legend items wrap onto the next line. If no adjustment is necessary, the value will be zero.

참고: This is overridden by the legendItemsPerRow property

| legendComponent | React.ReactElement | | The legend component to render with chart.

참고: Use legendData so the legend width can be calculated and positioned properly. Default legend properties may be applied

| legendData | { name?: string; symbol?: { fill?: string; type?: string; }; }[] | | Specify data via the data prop. ChartLegend expects data as an array of objects with name (required), symbol, and labels properties. The data prop must be given as an array.

@example legendData={[{ name: GBps capacity - 45% }, { name: 'Unused' }]}

| legendDirection | 'ltr' | 'rtl' | 'ltr' | Text direction of the legend labels.

| legendOrientation | 'horizontal' | 'vertical' | | The 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.

| legendPosition | 'bottom' | 'right' | "right" | The legend position relation to the pie chart. Valid values are 'bottom' and 'right'

참고: When adding a legend, padding may need to be adjusted in order to accommodate the extra legend. In some cases, the legend may not be visible until enough padding is applied.

| name | string | | The name prop is typically used to reference a component instance when defining shared events. However, this optional prop may also be applied to child elements as an ID prefix. This is a workaround to ensure Victory based components output unique IDs when multiple charts appear in a page.

| origin | { x: number, y: number } | | Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts.

참고: It will not typically be necessary to set an origin prop manually

| padAngle | number | Function | | The padAngle prop determines the amount of separation between adjacent data slices in number of degrees

| padding | number | { top: number, bottom: number, left: number, right: number } | | The 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.

| patternScale | string[] | | The patternScale prop is an optional prop that defines patterns to apply, where applicable. This prop should be given as a string array of pattern URLs. Patterns will be assigned to children by index and will repeat when there are more children than patterns in the provided patternScale. Use null to omit the pattern for a given index.

참고: Not all components are supported; for example, ChartLine, ChartBullet, ChartThreshold, etc.

@example patternScale={[ 'url("#pattern1")', 'url("#pattern2")', null ]}

| radius | number | Function | | Specifies the radius of the chart. If this property is not provided it is computed from width, height, and padding props

| sortKey | number | string | Function | string[] | | Use 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 | string | | The sortOrder prop specifies whether sorted data should be returned in 'ascending' or 'descending' order.

| standalone | boolean | true | The standalone prop determines whether the component will render a standalone svg or a tag that will be included in an external svg. Set standalone to false to compose ChartPie with other components within an enclosing

| startAngle | number | | The 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.

| style | { parent: object, data: object, labels: object } | | The style prop specifies styles for your pie. ChartPie 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}}

| subTitle | string | | The subtitle for the donut chart

| subTitleComponent | React.ReactElement | | The label component to render the chart subTitle.

When overriding the subTitleComponent prop, title and subTitle will be centered independently. You may choose to use the x and y props of ChartLabel to adjust the center position. For example:

subTitle="Pets"
subTitleComponent={}
title={100}
titleComponent={}

참고: Default label properties may be applied

| subTitlePosition | 'bottom' | 'center' | 'right' | | The orientation of the subtitle position. Valid values are 'bottom', 'center', and 'right'

| theme | object | getDonutUtilizationTheme(themeColor) | 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 ChartPie as a solo component, implement the theme directly on ChartPie. If you are wrapping ChartPie in ChartChart or ChartGroup, please call the theme on the outermost wrapper component instead.

| themeColor | string | | Specifies the theme color. Valid values are 'blue', 'green', 'multi', etc.

참고: Not compatible with theme prop

@example themeColor={ChartThemeColor.blue}

| thresholds | any[] | | 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' }]}

| title | string | | The title for the donut chart

| titleComponent | React.ReactElement | | The label component to render the chart title.

When centering both title and subTitle props, it's possible to override both styles via an array provided to ChartLabel. The first item in the array is associated with title styles, while the second item in the array is associated with subtitle styles.

subTitle="Pets"
title={100}
titleComponent={
  
}

In this case, both title and subTitle will be centered together. However, should you also override the subTitleComponent prop, title and subTitle will be centered independently. You may choose to use the x and y props of ChartLabel to adjust the center position. For example:

subTitle="Pets"
subTitleComponent={}
title={100}
titleComponent={}

참고: Default label properties may be applied

| width | number | theme.pie.width | Specifies 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. Typically, the parent container is set to the same width in order to maintain the aspect ratio.

| x | number | string | Function | string[] | | The 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)

| y | number | string | Function | string[] | | The 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)

Edit this page on GitHub

더 알아보기 (Learn more)