@cdc/chart 4.26.5 → 4.26.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONFIG.md +12 -8
- package/dist/{cdcchart-DQ00cQCm.es.js → cdcchart-BWVIUcAF.es.js} +5 -55
- package/dist/cdcchart.js +34093 -32767
- package/examples/feature/heatmap/average-age-categorical.json +1 -1
- package/examples/feature/heatmap/calendar-heatmap.json +1 -1
- package/examples/feature/heatmap/sparse-aggregation.json +1 -1
- package/examples/private/bad-y-axis.json +543 -0
- package/examples/private/bar-chart-negative-value.json +455 -0
- package/package.json +3 -3
- package/src/CdcChart.tsx +5 -4
- package/src/CdcChartComponent.tsx +32 -9
- package/src/_stories/Chart.SeriesColorAssignments.stories.tsx +183 -0
- package/src/_stories/Chart.YAxisAutoMaxStrategy.stories.tsx +52 -0
- package/src/_stories/Chart.YAxisFilterDomain.stories.tsx +90 -0
- package/src/_stories/ChartAnnotation.smoke.stories.tsx +10 -0
- package/src/_stories/_mock/annotation_event-line_mock.json +1064 -0
- package/src/_stories/_mock/heatmap-average-age-categorical.json +1 -1
- package/src/_stories/_mock/heatmap.json +1 -1
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +22 -1
- package/src/components/Annotations/components/AnnotationDraggable.tsx +219 -119
- package/src/components/Annotations/tests/AnnotationDraggable.test.tsx +198 -0
- package/src/components/Axis/LeftAxis.tsx +3 -0
- package/src/components/Axis/LeftAxisGridlines.tsx +8 -1
- package/src/components/Axis/RightAxis.tsx +3 -0
- package/src/components/Axis/tests/AxisTickValues.test.tsx +86 -0
- package/src/components/EditorPanel/EditorPanel.tsx +367 -136
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +101 -52
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.test.tsx +98 -0
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +10 -0
- package/src/components/EditorPanel/components/Panels/Panel.Visual.test.tsx +484 -0
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +3 -0
- package/src/components/EditorPanel/components/Panels/SeriesColorAssignments.tsx +262 -0
- package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +32 -0
- package/src/components/EditorPanel/components/panels.scss +10 -0
- package/src/components/EditorPanel/editor-panel.scss +47 -0
- package/src/components/EditorPanel/helpers/getVisualizationTypeConfigUpdate.ts +6 -2
- package/src/components/EditorPanel/helpers/tests/getVisualizationTypeConfigUpdate.test.ts +20 -2
- package/src/components/EditorPanel/useEditorPermissions.test.tsx +256 -11
- package/src/components/EditorPanel/useEditorPermissions.ts +41 -5
- package/src/components/HeatMap/components/HeatMap.tsx +22 -17
- package/src/components/HeatMap/components/HeatMapGradientLegend.tsx +29 -15
- package/src/components/HeatMap/heatmap.css +15 -1
- package/src/components/HeatMap/tests/HeatMap.test.tsx +39 -7
- package/src/components/Legend/Legend.Component.tsx +2 -2
- package/src/components/Legend/helpers/createFormatLabels.test.ts +88 -0
- package/src/components/Legend/helpers/createFormatLabels.tsx +6 -1
- package/src/components/LineChart/helpers.test.ts +230 -1
- package/src/components/LineChart/helpers.ts +26 -13
- package/src/components/LineChart/index.tsx +21 -4
- package/src/components/LinearChart/tests/LinearChart.test.tsx +30 -0
- package/src/components/LinearChart.tsx +50 -15
- package/src/components/ScatterPlot/ScatterPlot.jsx +3 -3
- package/src/components/SmallMultiples/SmallMultipleTile.tsx +3 -0
- package/src/components/SmallMultiples/SmallMultiples.tsx +38 -9
- package/src/components/SmallMultiples/tests/SmallMultiples.test.tsx +170 -0
- package/src/data/initial-state.js +1 -0
- package/src/helpers/calculateLeftYAxisWidth.ts +9 -3
- package/src/helpers/colorAssignmentHelpers.ts +102 -0
- package/src/helpers/dataHelpers.ts +11 -1
- package/src/helpers/getAxisMaxOverride.ts +16 -0
- package/src/helpers/getCleanTopTickMax.ts +64 -0
- package/src/helpers/getColorScale.ts +18 -9
- package/src/helpers/getHasBoundarySuppression.ts +26 -0
- package/src/helpers/getMinMax.ts +24 -22
- package/src/helpers/getYAxisDomainData.ts +38 -0
- package/src/helpers/getYAxisFinalizationEligibility.ts +40 -0
- package/src/helpers/hasSpacedInlineLabel.ts +10 -0
- package/src/helpers/seriesColumnSettings.ts +5 -4
- package/src/helpers/smallMultiplesHelpers.ts +5 -0
- package/src/helpers/tests/calculateLeftYAxisWidth.test.ts +38 -0
- package/src/helpers/tests/dataHelpers.test.ts +135 -0
- package/src/helpers/tests/getAxisMaxOverride.test.ts +36 -0
- package/src/helpers/tests/getCleanTopTickMax.test.ts +165 -0
- package/src/helpers/tests/getColorScale.test.ts +197 -0
- package/src/helpers/tests/getMinMax.test.ts +211 -0
- package/src/helpers/tests/getYAxisDomainData.test.ts +119 -0
- package/src/helpers/tests/getYAxisFinalizationEligibility.test.ts +185 -0
- package/src/helpers/tests/{getYAxisAutoPaddingMode.test.ts → hasSpacedInlineLabel.test.ts} +17 -32
- package/src/helpers/tests/seriesColumnSettings.test.ts +16 -2
- package/src/helpers/tests/smallMultiplesHelpers.test.ts +99 -0
- package/src/hooks/tests/useRightAxis.test.tsx +127 -0
- package/src/hooks/tests/useScales.test.tsx +307 -29
- package/src/hooks/useRightAxis.ts +30 -13
- package/src/hooks/useScales.ts +45 -28
- package/src/hooks/useTooltip.tsx +3 -1
- package/src/test/CdcChart.dataTable.test.tsx +122 -0
- package/src/types/ChartConfig.ts +6 -1
- package/src/types/ChartContext.ts +3 -0
- package/src/helpers/getYAxisAutoPadding.ts +0 -55
- package/src/helpers/getYAxisAutoPaddingMode.ts +0 -17
- package/src/helpers/tests/getYAxisAutoPadding.test.ts +0 -37
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChartComponent'
|
|
3
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
4
|
+
import { expect, userEvent, waitFor, within } from 'storybook/test'
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Chart> = {
|
|
7
|
+
title: 'Components/Templates/Chart/Series Color Assignments',
|
|
8
|
+
component: Chart
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof Chart>
|
|
12
|
+
|
|
13
|
+
const assignedColors = {
|
|
14
|
+
alpha: '#0057B7',
|
|
15
|
+
bravo: '#D94E5F',
|
|
16
|
+
charlie: '#5A8E3F'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const normalizeColor = (color: string) => {
|
|
20
|
+
const swatch = document.createElement('div')
|
|
21
|
+
swatch.style.color = color
|
|
22
|
+
document.body.appendChild(swatch)
|
|
23
|
+
const normalized = getComputedStyle(swatch).color
|
|
24
|
+
swatch.remove()
|
|
25
|
+
return normalized
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getVisiblePointColorsBySeries = (canvasElement: HTMLElement) => {
|
|
29
|
+
const groups = Array.from(canvasElement.querySelectorAll('.line-chart-group .visx-glyph-group')) as SVGGElement[]
|
|
30
|
+
const colorsBySeries = new Map<string, Set<string>>()
|
|
31
|
+
|
|
32
|
+
groups.forEach(group => {
|
|
33
|
+
const seriesIndex = group.getAttribute('data-seriesindex')
|
|
34
|
+
const glyph = group.querySelector('[fill]') as SVGElement | null
|
|
35
|
+
const fill = glyph?.getAttribute('fill')
|
|
36
|
+
|
|
37
|
+
if (!seriesIndex || !fill || fill === 'transparent') return
|
|
38
|
+
|
|
39
|
+
const seriesColors = colorsBySeries.get(seriesIndex) || new Set<string>()
|
|
40
|
+
seriesColors.add(normalizeColor(fill))
|
|
41
|
+
colorsBySeries.set(seriesIndex, seriesColors)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return colorsBySeries
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const expectVisibleSeriesColors = async (
|
|
48
|
+
canvasElement: HTMLElement,
|
|
49
|
+
expected: Array<[seriesIndex: string, color: string]>
|
|
50
|
+
) => {
|
|
51
|
+
await waitFor(() => {
|
|
52
|
+
const colorsBySeries = getVisiblePointColorsBySeries(canvasElement)
|
|
53
|
+
const expectedSeries = expected.map(([seriesIndex]) => seriesIndex)
|
|
54
|
+
|
|
55
|
+
expect(Array.from(colorsBySeries.keys()).sort()).toEqual(expectedSeries.sort())
|
|
56
|
+
|
|
57
|
+
expected.forEach(([seriesIndex, color]) => {
|
|
58
|
+
expect(Array.from(colorsBySeries.get(seriesIndex) || [])).toEqual([normalizeColor(color)])
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const expectLegendLabels = async (canvasElement: HTMLElement, expectedLabels: string[]) => {
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
const labels = Array.from(canvasElement.querySelectorAll('.legend-container [role="button"]')).map(item =>
|
|
66
|
+
item.textContent?.trim()
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
expect(labels).toEqual(expectedLabels)
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const config = {
|
|
74
|
+
type: 'chart',
|
|
75
|
+
version: '4.26.5',
|
|
76
|
+
title: 'Series Color Assignments With Filtered Series',
|
|
77
|
+
visualizationType: 'Line',
|
|
78
|
+
visualizationSubType: 'regular',
|
|
79
|
+
orientation: 'vertical',
|
|
80
|
+
filterBehavior: 'Filter Change',
|
|
81
|
+
lineDatapointStyle: 'always show',
|
|
82
|
+
lineDatapointColor: 'Same as Line',
|
|
83
|
+
general: {
|
|
84
|
+
palette: {
|
|
85
|
+
name: 'qualitative_standard',
|
|
86
|
+
version: '2.0',
|
|
87
|
+
colorAssignmentMode: 'by-value',
|
|
88
|
+
colorAssignments: [
|
|
89
|
+
{ key: 'alpha', color: assignedColors.alpha },
|
|
90
|
+
{ key: 'bravo', color: assignedColors.bravo },
|
|
91
|
+
{ key: 'charlie', color: assignedColors.charlie }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
legend: {
|
|
96
|
+
hide: false,
|
|
97
|
+
behavior: 'isolate',
|
|
98
|
+
dynamicLegend: false,
|
|
99
|
+
position: 'top',
|
|
100
|
+
style: 'circles',
|
|
101
|
+
unified: false
|
|
102
|
+
},
|
|
103
|
+
xAxis: {
|
|
104
|
+
dataKey: 'week',
|
|
105
|
+
type: 'date-time',
|
|
106
|
+
dateParseFormat: '%Y-%m-%d',
|
|
107
|
+
dateDisplayFormat: '%b. %-d',
|
|
108
|
+
label: 'Week',
|
|
109
|
+
sortDates: false
|
|
110
|
+
},
|
|
111
|
+
yAxis: {
|
|
112
|
+
label: 'Rate',
|
|
113
|
+
min: '0',
|
|
114
|
+
max: '50',
|
|
115
|
+
numTicks: '5',
|
|
116
|
+
gridLines: true
|
|
117
|
+
},
|
|
118
|
+
visual: {
|
|
119
|
+
lineDatapointSymbol: 'none',
|
|
120
|
+
verticalHoverLine: false,
|
|
121
|
+
horizontalHoverLine: false
|
|
122
|
+
},
|
|
123
|
+
tooltips: {
|
|
124
|
+
singleSeries: false
|
|
125
|
+
},
|
|
126
|
+
series: [
|
|
127
|
+
{ dataKey: 'alpha', name: 'Alpha', type: 'Line', axis: 'Left', tooltip: true },
|
|
128
|
+
{ dataKey: 'bravo', name: 'Bravo', type: 'Line', axis: 'Left', tooltip: true },
|
|
129
|
+
{ dataKey: 'charlie', name: 'Charlie', type: 'Line', axis: 'Left', tooltip: true }
|
|
130
|
+
],
|
|
131
|
+
filters: [
|
|
132
|
+
{
|
|
133
|
+
values: ['Alpha + Bravo', 'Bravo + Charlie'],
|
|
134
|
+
filterStyle: 'dropdown',
|
|
135
|
+
id: 1726688167657,
|
|
136
|
+
columnName: 'view',
|
|
137
|
+
active: 'Alpha + Bravo',
|
|
138
|
+
label: 'Visible series'
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
data: [
|
|
142
|
+
{ week: '2024-01-01', view: 'Alpha + Bravo', alpha: 12, bravo: 20, charlie: null },
|
|
143
|
+
{ week: '2024-01-08', view: 'Alpha + Bravo', alpha: 16, bravo: 23, charlie: null },
|
|
144
|
+
{ week: '2024-01-15', view: 'Alpha + Bravo', alpha: 21, bravo: 28, charlie: null },
|
|
145
|
+
{ week: '2024-01-22', view: 'Alpha + Bravo', alpha: 26, bravo: 31, charlie: null },
|
|
146
|
+
{ week: '2024-01-01', view: 'Bravo + Charlie', alpha: null, bravo: 20, charlie: 30 },
|
|
147
|
+
{ week: '2024-01-08', view: 'Bravo + Charlie', alpha: null, bravo: 23, charlie: 34 },
|
|
148
|
+
{ week: '2024-01-15', view: 'Bravo + Charlie', alpha: null, bravo: 28, charlie: 39 },
|
|
149
|
+
{ week: '2024-01-22', view: 'Bravo + Charlie', alpha: null, bravo: 31, charlie: 43 }
|
|
150
|
+
],
|
|
151
|
+
dataDescription: {
|
|
152
|
+
horizontal: false,
|
|
153
|
+
series: false
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export const FilteredSeriesKeepAssignedColors: Story = {
|
|
158
|
+
args: {
|
|
159
|
+
config,
|
|
160
|
+
isEditor: false
|
|
161
|
+
},
|
|
162
|
+
play: async ({ canvasElement }) => {
|
|
163
|
+
await assertVisualizationRendered(canvasElement)
|
|
164
|
+
|
|
165
|
+
await expectVisibleSeriesColors(canvasElement, [
|
|
166
|
+
['0', assignedColors.alpha],
|
|
167
|
+
['1', assignedColors.bravo]
|
|
168
|
+
])
|
|
169
|
+
await expectLegendLabels(canvasElement, ['Alpha', 'Bravo'])
|
|
170
|
+
|
|
171
|
+
const canvas = within(canvasElement)
|
|
172
|
+
const filter = canvas.getByLabelText(/filter by visible series/i) as HTMLSelectElement
|
|
173
|
+
await userEvent.selectOptions(filter, 'Bravo + Charlie')
|
|
174
|
+
|
|
175
|
+
await expectVisibleSeriesColors(canvasElement, [
|
|
176
|
+
['1', assignedColors.bravo],
|
|
177
|
+
['2', assignedColors.charlie]
|
|
178
|
+
])
|
|
179
|
+
await expectLegendLabels(canvasElement, ['Bravo', 'Charlie'])
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export default meta
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChartComponent'
|
|
3
|
+
import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
|
|
4
|
+
import smallestLeftAxisMaxConfig from './_mock/smallest_left_axis_max.json'
|
|
5
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Chart> = {
|
|
8
|
+
title: 'Components/Templates/Chart/Y Axis Auto Max Strategy',
|
|
9
|
+
component: Chart
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Chart>
|
|
13
|
+
|
|
14
|
+
const baseConfig = editConfigKeys(smallestLeftAxisMaxConfig, [
|
|
15
|
+
{ path: ['yAxis', 'smallestLeftAxisMax'], value: undefined },
|
|
16
|
+
{ path: ['yAxis', 'filterDomainBehavior'], value: 'dynamic' },
|
|
17
|
+
{ path: ['yAxis', 'numTicks'], value: 4 },
|
|
18
|
+
{ path: ['filters', '0', 'active'], value: 'Region A' }
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
export const Clean_Top_Tick_Strategy: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
config: editConfigKeys(baseConfig, [{ path: ['yAxis', 'autoMaxStrategy'], value: 'clean-top-tick' }])
|
|
24
|
+
},
|
|
25
|
+
play: async ({ canvasElement }) => {
|
|
26
|
+
await assertVisualizationRendered(canvasElement)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Default_Strategy: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
config: editConfigKeys(baseConfig, [{ path: ['yAxis', 'autoMaxStrategy'], value: 'default' }])
|
|
33
|
+
},
|
|
34
|
+
play: async ({ canvasElement }) => {
|
|
35
|
+
await assertVisualizationRendered(canvasElement)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Stable_Filter_Domain_With_Clean_Top_Tick: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
config: editConfigKeys(baseConfig, [
|
|
42
|
+
{ path: ['yAxis', 'filterDomainBehavior'], value: 'stable' },
|
|
43
|
+
{ path: ['yAxis', 'autoMaxStrategy'], value: 'clean-top-tick' },
|
|
44
|
+
{ path: ['filters', '0', 'active'], value: 'Region B' }
|
|
45
|
+
])
|
|
46
|
+
},
|
|
47
|
+
play: async ({ canvasElement }) => {
|
|
48
|
+
await assertVisualizationRendered(canvasElement)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default meta
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { expect, within } from 'storybook/test'
|
|
3
|
+
import Chart from '../CdcChartComponent'
|
|
4
|
+
import { editConfigKeys } from '@cdc/core/helpers/configHelpers'
|
|
5
|
+
import smallestLeftAxisMaxConfig from './_mock/smallest_left_axis_max.json'
|
|
6
|
+
import horizontalBarConfig from './_mock/horizontal_bar.json'
|
|
7
|
+
import { assertVisualizationRendered, openAccordion, waitForEditor } from '@cdc/core/helpers/testing'
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Chart> = {
|
|
10
|
+
title: 'Components/Templates/Chart/Y Axis Filter Domain',
|
|
11
|
+
component: Chart
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Chart>
|
|
15
|
+
|
|
16
|
+
const baseConfig = editConfigKeys(smallestLeftAxisMaxConfig, [
|
|
17
|
+
{ path: ['yAxis', 'smallestLeftAxisMax'], value: undefined },
|
|
18
|
+
{ path: ['yAxis', 'numTicks'], value: 4 }
|
|
19
|
+
])
|
|
20
|
+
|
|
21
|
+
export const Dynamic_Filter_Domain: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
config: editConfigKeys(baseConfig, [{ path: ['yAxis', 'filterDomainBehavior'], value: 'dynamic' }])
|
|
24
|
+
},
|
|
25
|
+
play: async ({ canvasElement }) => {
|
|
26
|
+
await assertVisualizationRendered(canvasElement)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Stable_Filter_Domain: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
config: editConfigKeys(baseConfig, [{ path: ['yAxis', 'filterDomainBehavior'], value: 'stable' }])
|
|
33
|
+
},
|
|
34
|
+
play: async ({ canvasElement }) => {
|
|
35
|
+
await assertVisualizationRendered(canvasElement)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Editor_Control: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
config: editConfigKeys(baseConfig, [
|
|
42
|
+
{ path: ['yAxis', 'filterDomainBehavior'], value: 'stable' },
|
|
43
|
+
{ path: ['yAxis', 'autoMaxStrategy'], value: 'clean-top-tick' }
|
|
44
|
+
]),
|
|
45
|
+
isEditor: true
|
|
46
|
+
},
|
|
47
|
+
play: async ({ canvasElement }) => {
|
|
48
|
+
const canvas = within(canvasElement)
|
|
49
|
+
await waitForEditor(canvas)
|
|
50
|
+
await openAccordion(canvas, 'Left Value Axis')
|
|
51
|
+
|
|
52
|
+
const filterDomainSelect = (await canvas.findByLabelText(/Filter Domain Behavior/i)) as HTMLSelectElement
|
|
53
|
+
expect(filterDomainSelect.value).toBe('stable')
|
|
54
|
+
expect(Array.from(filterDomainSelect.options).map(option => option.text)).toEqual(['Dynamic', 'Stable'])
|
|
55
|
+
|
|
56
|
+
const autoMaxStrategySelect = (await canvas.findByLabelText(/Automatic max strategy/i)) as HTMLSelectElement
|
|
57
|
+
expect(autoMaxStrategySelect.value).toBe('clean-top-tick')
|
|
58
|
+
expect(Array.from(autoMaxStrategySelect.options).map(option => option.text)).toEqual(['Default', 'Clean top tick'])
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Horizontal_Editor_Control: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
config: editConfigKeys(horizontalBarConfig, [
|
|
65
|
+
{ path: ['filters'], value: [{ columnName: 'Race', active: 'AI/AN, Non-Hispanic', showDropdown: true }] },
|
|
66
|
+
{ path: ['xAxis', 'max'], value: '' },
|
|
67
|
+
{ path: ['yAxis', 'type'], value: 'linear' },
|
|
68
|
+
{ path: ['yAxis', 'smallestLeftAxisMax'], value: 5 },
|
|
69
|
+
{ path: ['yAxis', 'filterDomainBehavior'], value: 'stable' },
|
|
70
|
+
{ path: ['yAxis', 'autoMaxStrategy'], value: 'clean-top-tick' }
|
|
71
|
+
]),
|
|
72
|
+
isEditor: true
|
|
73
|
+
},
|
|
74
|
+
play: async ({ canvasElement }) => {
|
|
75
|
+
const canvas = within(canvasElement)
|
|
76
|
+
await waitForEditor(canvas)
|
|
77
|
+
await openAccordion(canvas, 'Value Axis')
|
|
78
|
+
|
|
79
|
+
const smallestAxisMaxInput = (await canvas.findByLabelText(/Smallest axis maximum/i)) as HTMLInputElement
|
|
80
|
+
expect(smallestAxisMaxInput.value).toBe('5')
|
|
81
|
+
|
|
82
|
+
const filterDomainSelect = (await canvas.findByLabelText(/Filter Domain Behavior/i)) as HTMLSelectElement
|
|
83
|
+
expect(filterDomainSelect.value).toBe('stable')
|
|
84
|
+
|
|
85
|
+
const autoMaxStrategySelect = (await canvas.findByLabelText(/Automatic max strategy/i)) as HTMLSelectElement
|
|
86
|
+
expect(autoMaxStrategySelect.value).toBe('clean-top-tick')
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default meta
|
|
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
|
2
2
|
import annotationConfig from './_mock/annotation_category_mock.json'
|
|
3
3
|
import annotationConfigDateLinear from './_mock/annotation_date-linear_mock.json'
|
|
4
4
|
import annotationConfigDateTime from './_mock/annotation_date-time_mock.json'
|
|
5
|
+
import annotationConfigEventLine from './_mock/annotation_event-line_mock.json'
|
|
5
6
|
import Chart from '../CdcChartComponent'
|
|
6
7
|
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
7
8
|
|
|
@@ -42,4 +43,13 @@ export const Chart_Annotation_Date_Time: Story = {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
export const Chart_Annotation_Event_Line: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
config: annotationConfigEventLine
|
|
49
|
+
},
|
|
50
|
+
play: async ({ canvasElement }) => {
|
|
51
|
+
await assertVisualizationRendered(canvasElement)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
export default meta
|