|
| 1 | +// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | + |
| 3 | +/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */ |
| 4 | + |
| 5 | +export const docs = { |
| 6 | + name: 'ChartGrid', |
| 7 | + displayName: 'Chart Grid', |
| 8 | + group: 'Charts', |
| 9 | + category: 'Data Visualization', |
| 10 | + isHiddenFromOverview: true, |
| 11 | + keywords: ['chart', 'grid', 'guides', 'axis', 'ticks', 'data visualization'], |
| 12 | + |
| 13 | + usage: { |
| 14 | + description: |
| 15 | + 'ChartGrid draws horizontal and vertical guide lines from the scales owned by a parent Chart. Use it in the Chart grid slot so guides share the plot dimensions and tick values used by the chart.', |
| 16 | + bestPractices: [ |
| 17 | + { |
| 18 | + guidance: true, |
| 19 | + description: |
| 20 | + 'Pair ChartGrid with ChartAxis when readers need labelled values beside the guide lines.', |
| 21 | + }, |
| 22 | + { |
| 23 | + guidance: true, |
| 24 | + description: |
| 25 | + 'Use horizontal guides for value comparison and add vertical guides only when they help readers align categories or continuous x values.', |
| 26 | + }, |
| 27 | + { |
| 28 | + guidance: false, |
| 29 | + description: |
| 30 | + 'Use grid lines as the only way to communicate a value or distinction. Keep meaningful chart information in labels, marks, and the parent Chart alternative.', |
| 31 | + }, |
| 32 | + { |
| 33 | + guidance: false, |
| 34 | + description: |
| 35 | + 'Expect tickCount to thin categorical band centers. It requests density only for continuous scales; categorical vertical guides render once per band.', |
| 36 | + }, |
| 37 | + ], |
| 38 | + accessibility: [ |
| 39 | + { |
| 40 | + name: 'Chart alternative', |
| 41 | + category: 'Content', |
| 42 | + criterion: '1.1.1 Non-text Content', |
| 43 | + requirement: 'Required on the parent Chart', |
| 44 | + states: ['All'], |
| 45 | + description: |
| 46 | + 'Chart owns the accessible image name and supported small-data table. Grid lines supplement that chart-level alternative rather than replacing it.', |
| 47 | + }, |
| 48 | + { |
| 49 | + name: 'Visual-only guides', |
| 50 | + category: 'Color contrast', |
| 51 | + criterion: '1.4.11 Non-text Contrast', |
| 52 | + requirement: 'Do not carry information alone', |
| 53 | + states: ['Horizontal', 'Vertical', 'Combined'], |
| 54 | + description: |
| 55 | + 'Grid lines are supporting guides. Preserve visible labels, marks, or another qualifying cue so understanding does not depend on the grid alone.', |
| 56 | + }, |
| 57 | + ], |
| 58 | + anatomy: [ |
| 59 | + { |
| 60 | + name: 'Grid lines', |
| 61 | + required: false, |
| 62 | + description: |
| 63 | + 'Horizontal lines at continuous y ticks and vertical lines at x ticks or categorical band centers.', |
| 64 | + }, |
| 65 | + ], |
| 66 | + }, |
| 67 | + |
| 68 | + props: [ |
| 69 | + { |
| 70 | + name: 'horizontal', |
| 71 | + type: 'boolean', |
| 72 | + description: |
| 73 | + 'Whether to draw horizontal guides at continuous y ticks other than zero.', |
| 74 | + default: 'true', |
| 75 | + }, |
| 76 | + { |
| 77 | + name: 'vertical', |
| 78 | + type: 'boolean', |
| 79 | + description: |
| 80 | + 'Whether to draw vertical guides at continuous x ticks or categorical band centers.', |
| 81 | + default: 'false', |
| 82 | + }, |
| 83 | + { |
| 84 | + name: 'tickCount', |
| 85 | + type: 'number', |
| 86 | + description: |
| 87 | + 'Approximate guide count requested from continuous scales. It does not thin categorical band centers.', |
| 88 | + default: '5', |
| 89 | + }, |
| 90 | + ], |
| 91 | + |
| 92 | + examples: [ |
| 93 | + { |
| 94 | + label: 'Horizontal guides', |
| 95 | + code: `import {Chart, ChartGrid, bar} from '@astryxdesign/charts'; |
| 96 | +
|
| 97 | +<Chart |
| 98 | + data={monthlyRevenue} |
| 99 | + xKey="month" |
| 100 | + series={[bar('revenue')]} |
| 101 | + grid={<ChartGrid />} |
| 102 | +/>;`, |
| 103 | + }, |
| 104 | + { |
| 105 | + label: 'Horizontal and vertical guides', |
| 106 | + code: `<Chart |
| 107 | + data={monthlyRevenue} |
| 108 | + xKey="month" |
| 109 | + series={[bar('revenue')]} |
| 110 | + grid={<ChartGrid horizontal vertical tickCount={6} />} |
| 111 | +/>;`, |
| 112 | + }, |
| 113 | + ], |
| 114 | +}; |
0 commit comments