|
1 | 1 | --- |
2 | 2 | id: About charts |
3 | 3 | section: charts |
| 4 | +sortValue: 1 |
4 | 5 | --- |
5 | 6 |
|
6 | 7 | _Charts are only available in React_ |
7 | 8 |
|
8 | 9 | A **chart** visualizes data in an application. The type of chart you use will depend on your use case and the type of data you need to display. |
9 | 10 |
|
10 | 11 | ## Elements |
11 | | -<img src="./img/axis-labels.png" alt="Chart with axis labels" width="713"/> |
| 12 | +<img src="./img/axis-labels.png" alt="Chart with axis labels" width="713"/> |
12 | 13 |
|
13 | 14 | 1. **Title:** Titles should be left-aligned and appear above your chart. |
14 | 15 | 2. **Axis labels and scale values:** We recommend using tick marks to clearly mark scale values on the y-axis. The text for axis labels and scale values should be 12px font in standard text color. All scale values should be equally distributed across the axis and the axis label should fall outside the scale values, centered with the axis line. |
15 | 16 | 3. **Legends:** We recommend using legends when charts include more than one variable and therefore use more than one color. When datasets are overlapping, an [interactive legend](#interactive-chart-legends) can be used. If space is not available to display names of horizontal and vertical axes, a legend must be added instead. The legend should list the colors that each variable obtains and the name of the variable. The text on the legend should be 14px size and standard text color. They can either be placed left-aligned to the right of the chart or centered below the chart. |
16 | 17 | 4. **Chart tooltip:** A tooltip will appear on hover over certain elements of a chart, like bars in a bar chart or segments in a donut chart. [Chart tooltips](/charts/tooltips) should display the specific values related to the element the user is hovering over. |
17 | 18 |
|
18 | 19 | ## Chart types |
19 | | -<img src="./img/chart-legend.png" alt="Image displaying what chart types to use when" width="1024"/> |
| 20 | +<img src="./img/chart-legend.png" alt="Image displaying what chart types to use when" width="1024"/> |
20 | 21 |
|
21 | 22 | - [Area chart](/charts/area-chart/design-guidelines): Use to show (potentially multiple) trends over a continuous scale (usually time). |
22 | 23 | - [Bar chart](/charts/bar-chart/design-guidelines): Use to show and compare categories and their respective data point/value. Bar charts can be plotted vertically or horizontally. The axis that labels the bar is the category, the axis that marks the end point of the bar displays the data points/values. |
@@ -65,3 +66,14 @@ On click |
65 | 66 |
|
66 | 67 | 1. **Legend:** When a user clicks on a legend label, it becomes disabled and the color swatch is replaced with an eye-slashed icon. |
67 | 68 | 2. **Chart:** Data corresponding to the clicked legend label is hidden from view. |
| 69 | + |
| 70 | +## Develop with charts |
| 71 | + |
| 72 | +Default styles in the [@patternfly/react-charts package](https://www.npmjs.com/package/@patternfly/react-charts) are aligned with our light theme. Charts work with PatternFly's light theme by default—you don't need to import anything else. |
| 73 | + |
| 74 | +To support dark-themed charts, you must: |
| 75 | +1. Import the [@patternfly/patternfly package](https://www.npmjs.com/package/@patternfly/patternfly), so that you can use our global tokens. |
| 76 | +1. Import the stylesheet that contains dark theme styles by adding this line before importing your main application component: `import '@patternfly/patternfly/patternfly-charts.css';` |
| 77 | + - Once you import this file, you'll have access to [all chart variables](https://www.npmjs.com/package/@patternfly/patternfly?activeTab=code). Beyond dark theme, you could use these variables to match the style of other UI elements to your chart styles. |
| 78 | + |
| 79 | +To display the list of all available chart tokens, filter for "charts" in [the PatternFly design tokens table](/tokens/all-patternfly-tokens). |
0 commit comments