| id | Patterns | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| section | components | ||||||||||||||
| subsection | charts | ||||||||||||||
| propComponents |
|
||||||||||||||
| hideDarkMode | true |
import { cloneElement, createRef } from 'react'; import { useEffect, useRef, useState } from 'react'; import { Chart, ChartArea, ChartAxis, ChartBar, ChartDonut, ChartDonutThreshold, ChartDonutUtilization, ChartGroup, ChartLegend, ChartLegendTooltip, ChartPie, ChartScatter, ChartStack, ChartThemeColor, ChartVoronoiContainer, createContainer, getInteractiveLegendEvents, getInteractiveLegendItemStyles } from '@patternfly/react-charts/victory'; import { getResizeObserver } from '@patternfly/react-core'; import chart_color_black_500 from '@patternfly/react-tokens/dist/esm/chart_color_black_500'; import chart_color_blue_300 from '@patternfly/react-tokens/dist/esm/chart_color_blue_300'; import chart_color_green_300 from '@patternfly/react-tokens/dist/esm/chart_color_green_300'; import chart_color_teal_300 from '@patternfly/react-tokens/dist/esm/chart_color_teal_300'; import chart_color_yellow_300 from '@patternfly/react-tokens/dist/esm/chart_color_yellow_300'; import '@patternfly/patternfly/patternfly-charts.css';
Note: PatternFly React charts live in its own package at @patternfly/react-charts!
The examples below are based on the Victory chart library, along with additional functionality, custom components, and theming for PatternFly. This provides a collection of React based components you can use to build PatternFly patterns with consistent markup, styling, and behavior.
This demonstrates how to hide a pattern for the static, unused portion of the donut utilization chart.
This demonstrates how to apply patterns to thresholds.
This demonstrates how to add an interactive legend to a pie chart using events such as onMouseOver, onMouseOut, and onClick.
This demonstrates how to add an interactive legend using events such as onMouseOver, onMouseOut, and onClick.
This demonstrates how to omit patterns from pie chart segments.
This demonstrates how to apply a custom color scale to patterns.
This demonstrates how to create custom patterns.
- See Victory's FAQ
ChartLegendmay be used as a standalone component, instead of usinglegendData
Currently, the generated documentation below is not able to resolve type definitions from Victory imports. For the components used in the examples above, Victory pass-thru props are also documented here:
- For
Chartprops, see VictoryChart - For
ChartAreaprops, see VictoryArea - For
ChartAxisprops, see VictoryAxis - For
ChartBarprops, see VictoryBar - For
ChartDonutprops, see VictoryPie - For
ChartDonutThresholdprops, see VictoryPie - For
ChartDonutUtilizationprops, see VictoryPie - For
ChartGroupprops, see VictoryGroup - For
ChartLegendprops, see VictoryLegend - For
ChartPieprops, see VictoryPie - For
ChartScatterprops, see VictoryScatter - For
ChartStackprops, see VictoryStack - For
ChartVoronoiContainerprops, see VictoryVoronoiContainer