@cdc/chart 4.25.11 → 4.26.2
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/CLAUDE.local.md +79 -0
- package/dist/{cdcchart-dgT_1dIT.es.js → cdcchart-DQ00cQCm.es.js} +1 -20
- package/dist/cdcchart.js +51401 -50814
- package/examples/default.json +378 -0
- package/examples/feature/__data__/horizon-chart-data.json +373 -0
- package/examples/feature/annotations/index.json +3 -6
- package/examples/feature/horizon/horizon-chart.json +395 -0
- package/examples/feature/pie/planet-pie-example-config.json +48 -2
- package/examples/line-chart-states.json +1085 -0
- package/examples/private/123.json +694 -0
- package/examples/private/DEV-12100.json +1303 -0
- package/examples/private/anchor-issue.json +4094 -0
- package/examples/private/backwards-slider.json +10430 -0
- package/examples/private/cat-y.json +1235 -0
- package/examples/private/data-points.json +228 -0
- package/examples/private/georgia.csv +160 -0
- package/examples/private/height.json +3915 -0
- package/examples/private/links.json +569 -0
- package/examples/private/quadrant.txt +30 -0
- package/examples/private/test-forecast.json +5510 -0
- package/examples/private/timeline-data.json +1 -0
- package/examples/private/timeline.json +389 -0
- package/examples/private/warming-stripe-test.json +2578 -0
- package/examples/private/warming-stripes.json +4763 -0
- package/examples/radar-chart-simple.json +133 -0
- package/examples/radar-chart.json +148 -0
- package/examples/tech-adoption-with-links.json +560 -0
- package/index.html +1 -36
- package/package.json +59 -60
- package/src/CdcChartComponent.tsx +206 -89
- package/src/_stories/Chart.Anchors.stories.tsx +10 -0
- package/src/_stories/Chart.BoxPlot.stories.tsx +7 -0
- package/src/_stories/Chart.CI.stories.tsx +13 -0
- package/src/_stories/Chart.Combo.stories.tsx +17 -0
- package/src/_stories/Chart.CustomColors.stories.tsx +4 -0
- package/src/_stories/Chart.DynamicSeries.stories.tsx +19 -0
- package/src/_stories/Chart.Filters.stories.tsx +4 -0
- package/src/_stories/Chart.Forecast.stories.tsx +4 -0
- package/src/_stories/Chart.HTMLInDataTable.stories.tsx +22 -0
- package/src/_stories/Chart.Legend.Gradient.stories.tsx +28 -0
- package/src/_stories/Chart.Patterns.stories.tsx +4 -0
- package/src/_stories/Chart.PreserveDecimals.stories.tsx +25 -0
- package/src/_stories/Chart.Regions.Categorical.stories.tsx +161 -0
- package/src/_stories/Chart.Regions.DateScale.stories.tsx +216 -0
- package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +312 -0
- package/src/_stories/Chart.ScatterPlot.stories.tsx +4 -0
- package/src/_stories/Chart.SmallMultiples.stories.tsx +16 -0
- package/src/_stories/Chart.stories.tsx +45 -0
- package/src/_stories/Chart.tooltip.stories.tsx +7 -0
- package/src/_stories/ChartAnnotation.stories.tsx +10 -0
- package/src/_stories/ChartAxisLabels.stories.tsx +4 -0
- package/src/_stories/ChartAxisTitles.stories.tsx +10 -0
- package/src/_stories/ChartBar.Editor.stories.tsx +11 -6
- package/src/_stories/ChartBrush.Editor.stories.tsx +295 -0
- package/src/_stories/ChartBrush.Matrix.Continuous.stories.tsx +41 -0
- package/src/_stories/ChartBrush.Matrix.Date.stories.tsx +114 -0
- package/src/_stories/ChartBrush.Matrix.DateTime.stories.tsx +78 -0
- package/src/_stories/ChartBrush.stories.tsx +57 -0
- package/src/_stories/ChartEditor.Editor.stories.tsx +3 -5
- package/src/_stories/ChartEditor.stories.tsx +7 -0
- package/src/_stories/ChartLine.QuadrantAngles.stories.tsx +89 -0
- package/src/_stories/ChartLine.Suppression.stories.tsx +7 -0
- package/src/_stories/ChartLine.Symbols.stories.tsx +4 -0
- package/src/_stories/ChartPrefixSuffix.stories.tsx +46 -1
- package/src/_stories/TechAdoptionWithLinks.stories.tsx +34 -0
- package/src/_stories/_mock/brush_continuous.json +86 -0
- package/src/_stories/_mock/brush_date_large.json +176 -0
- package/src/_stories/_mock/brush_enabled.json +326 -0
- package/src/_stories/_mock/brush_mock.json +2 -69
- package/src/_stories/_mock/horizontal-bars-dynamic-y-axis.json +413 -0
- package/src/_stories/_mock/line_chart_angle_near_zero_fall.json +195 -0
- package/src/_stories/_mock/line_chart_angle_near_zero_rise.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q1_steep_upward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q2_gentle_downward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q3_steep_downward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q4_gentle_upward.json +195 -0
- package/src/_stories/_mock/line_chart_quadrant_angles.json +264 -0
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +11 -17
- package/src/components/Annotations/components/AnnotationDraggable.tsx +240 -116
- package/src/components/Annotations/components/AnnotationDropdown.styles.css +1 -2
- package/src/components/Annotations/components/AnnotationDropdown.tsx +8 -12
- package/src/components/Annotations/components/AnnotationList.styles.css +4 -10
- package/src/components/Annotations/components/AnnotationList.tsx +5 -4
- package/src/components/Annotations/components/findNearestDatum.ts +75 -85
- package/src/components/Annotations/helpers/getVisibleAnnotations.ts +38 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -2
- package/src/components/Axis/BottomAxis.tsx +270 -0
- package/src/components/Axis/Categorical.Axis.tsx +6 -7
- package/src/components/Axis/LeftAxis.tsx +404 -0
- package/src/components/Axis/LeftAxisGridlines.tsx +77 -0
- package/src/components/Axis/PairedBarAxis.tsx +186 -0
- package/src/components/Axis/README.md +94 -0
- package/src/components/Axis/RightAxis.tsx +108 -0
- package/src/components/Axis/axis.constants.ts +21 -0
- package/src/components/Axis/index.ts +7 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +178 -24
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +3 -1
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +1 -0
- package/src/components/BarChart/components/BarChart.Vertical.tsx +6 -8
- package/src/components/BarChart/components/BarChart.tsx +7 -1
- package/src/components/BarChart/components/context.tsx +1 -0
- package/src/components/BarChart/helpers/useBarChart.ts +14 -2
- package/src/components/Brush/BrushSelector.tsx +1390 -0
- package/src/components/Brush/MiniChartPreview.tsx +400 -0
- package/src/components/DeviationBar.jsx +9 -7
- package/src/components/EditorPanel/EditorPanel.tsx +2734 -2595
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +60 -22
- package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +56 -34
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +137 -30
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +2 -0
- package/src/components/EditorPanel/components/Panels/Panel.Radar.tsx +353 -0
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +0 -1
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +30 -25
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +42 -28
- package/src/components/EditorPanel/components/Panels/index.tsx +2 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +81 -39
- package/src/components/HorizonChart/HorizonChart.tsx +131 -0
- package/src/components/HorizonChart/components/HorizonBand.tsx +160 -0
- package/src/components/HorizonChart/helpers/calculateHorizonBands.ts +27 -0
- package/src/components/HorizonChart/helpers/getHorizonLayerColors.ts +40 -0
- package/src/components/HorizonChart/index.tsx +3 -0
- package/src/components/Legend/Legend.Component.tsx +52 -4
- package/src/components/Legend/Legend.tsx +4 -3
- package/src/components/Legend/LegendValueRange.tsx +77 -0
- package/src/components/Legend/helpers/createFormatLabels.tsx +164 -2
- package/src/components/Legend/helpers/generateValueRanges.ts +92 -0
- package/src/components/Legend/helpers/index.ts +10 -6
- package/src/components/LineChart/helpers/README.md +292 -0
- package/src/components/LineChart/helpers/labelPositioning.test.ts +245 -0
- package/src/components/LineChart/helpers/labelPositioning.ts +304 -0
- package/src/components/LineChart/index.tsx +44 -8
- package/src/components/LinearChart/README.md +109 -0
- package/src/components/LinearChart/VisualizationRenderer.tsx +267 -0
- package/src/components/LinearChart/linearChart.constants.ts +84 -0
- package/src/components/LinearChart/tests/LinearChart.test.tsx +201 -0
- package/src/components/LinearChart/tests/mockConfigContext.ts +129 -0
- package/src/components/LinearChart/utils/tickFormatting.ts +146 -0
- package/src/components/LinearChart.tsx +338 -1082
- package/src/components/PairedBarChart.jsx +20 -3
- package/src/components/PieChart/PieChart.tsx +1 -1
- package/src/components/RadarChart/RadarAxis.tsx +78 -0
- package/src/components/RadarChart/RadarChart.tsx +298 -0
- package/src/components/RadarChart/RadarGrid.tsx +64 -0
- package/src/components/RadarChart/RadarPolygon.tsx +91 -0
- package/src/components/RadarChart/helpers.ts +83 -0
- package/src/components/RadarChart/index.tsx +3 -0
- package/src/components/Regions/components/Regions.tsx +365 -122
- package/src/components/ScatterPlot/ScatterPlot.jsx +2 -2
- package/src/components/SmallMultiples/SmallMultipleTile.tsx +5 -1
- package/src/components/WarmingStripes/WarmingStripes.tsx +230 -0
- package/src/components/WarmingStripes/WarmingStripesGradientLegend.css +35 -0
- package/src/components/WarmingStripes/WarmingStripesGradientLegend.tsx +104 -0
- package/src/components/WarmingStripes/index.tsx +3 -0
- package/src/data/initial-state.js +17 -2
- package/src/helpers/calculateHorizontalBarCategoryLabelWidth.ts +57 -0
- package/src/helpers/getExcludedData.ts +4 -0
- package/src/helpers/getMinMax.ts +12 -7
- package/src/helpers/handleChartAriaLabels.ts +19 -19
- package/src/helpers/handleLineType.ts +22 -18
- package/src/helpers/sizeHelpers.ts +0 -20
- package/src/helpers/smallMultiplesHelpers.ts +1 -1
- package/src/hooks/useChartHoverAnalytics.tsx +10 -9
- package/src/hooks/useProgrammaticTooltip.ts +23 -2
- package/src/hooks/useScales.ts +18 -1
- package/src/hooks/useTooltip.tsx +34 -10
- package/src/scss/DataTable.scss +0 -4
- package/src/scss/main.scss +22 -3
- package/src/selectors/README.md +68 -0
- package/src/store/chart.reducer.ts +2 -0
- package/src/test/CdcChart.test.jsx +1 -1
- package/src/types/ChartConfig.ts +21 -0
- package/src/types/ChartContext.ts +1 -0
- package/src/types/Horizon.ts +64 -0
- package/src/types/Label.ts +1 -0
- package/src/utils/analyticsTracking.ts +19 -0
- package/LICENSE +0 -201
- package/src/components/Annotations/components/helpers/index.tsx +0 -46
- package/src/components/Brush/BrushChart.tsx +0 -128
- package/src/components/Brush/BrushController.tsx +0 -71
- package/src/components/Brush/types.tsx +0 -8
- package/src/components/BrushChart.tsx +0 -223
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChart'
|
|
3
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Chart> = {
|
|
6
|
+
title: 'Components/Templates/Chart/Regions/Date Scale (Band)',
|
|
7
|
+
component: Chart
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof Chart>
|
|
11
|
+
|
|
12
|
+
const dateData = [
|
|
13
|
+
{ date: '2024-01-01', value: 10 },
|
|
14
|
+
{ date: '2024-01-08', value: 25 },
|
|
15
|
+
{ date: '2024-01-15', value: 35 },
|
|
16
|
+
{ date: '2024-01-22', value: 45 },
|
|
17
|
+
{ date: '2024-01-29', value: 55 },
|
|
18
|
+
{ date: '2024-02-05', value: 40 },
|
|
19
|
+
{ date: '2024-02-12', value: 60 },
|
|
20
|
+
{ date: '2024-02-19', value: 75 },
|
|
21
|
+
{ date: '2024-02-26', value: 65 },
|
|
22
|
+
{ date: '2024-03-04', value: 80 }
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
const baseDateConfig = {
|
|
26
|
+
type: 'chart',
|
|
27
|
+
visualizationType: 'Line',
|
|
28
|
+
orientation: 'vertical',
|
|
29
|
+
showTitle: true,
|
|
30
|
+
theme: 'theme-blue',
|
|
31
|
+
animate: false,
|
|
32
|
+
xAxis: {
|
|
33
|
+
type: 'date',
|
|
34
|
+
dataKey: 'date',
|
|
35
|
+
dateParseFormat: '%Y-%m-%d',
|
|
36
|
+
dateDisplayFormat: '%b %-d',
|
|
37
|
+
size: '0',
|
|
38
|
+
hideAxis: false,
|
|
39
|
+
hideTicks: false,
|
|
40
|
+
numTicks: '6'
|
|
41
|
+
},
|
|
42
|
+
yAxis: {
|
|
43
|
+
size: '50',
|
|
44
|
+
hideAxis: false,
|
|
45
|
+
hideTicks: false,
|
|
46
|
+
gridLines: true,
|
|
47
|
+
min: '0',
|
|
48
|
+
max: '100'
|
|
49
|
+
},
|
|
50
|
+
series: [{ dataKey: 'value', type: 'Line', axis: 'Left', tooltip: true, name: 'Value' }],
|
|
51
|
+
legend: { hide: true },
|
|
52
|
+
data: dateData,
|
|
53
|
+
regions: []
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// LINE CHARTS
|
|
57
|
+
|
|
58
|
+
export const Line_Fixed_From_Fixed_To: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
config: {
|
|
61
|
+
...baseDateConfig,
|
|
62
|
+
title: 'Date Scale - Line: Fixed From + Fixed To',
|
|
63
|
+
regions: [
|
|
64
|
+
{
|
|
65
|
+
from: '2024-01-15',
|
|
66
|
+
to: '2024-02-12',
|
|
67
|
+
fromType: 'Fixed',
|
|
68
|
+
toType: 'Fixed',
|
|
69
|
+
label: 'Fixed Region',
|
|
70
|
+
background: '#0077cc',
|
|
71
|
+
color: '#000000',
|
|
72
|
+
range: 'Custom'
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
isEditor: true
|
|
77
|
+
},
|
|
78
|
+
play: async ({ canvasElement }) => {
|
|
79
|
+
await assertVisualizationRendered(canvasElement)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Line_Fixed_From_Last_Date: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
config: {
|
|
86
|
+
...baseDateConfig,
|
|
87
|
+
title: 'Date Scale - Line: Fixed From + Last Date',
|
|
88
|
+
regions: [
|
|
89
|
+
{
|
|
90
|
+
from: '2024-02-05',
|
|
91
|
+
to: '',
|
|
92
|
+
fromType: 'Fixed',
|
|
93
|
+
toType: 'Last Date',
|
|
94
|
+
label: 'To Last Date',
|
|
95
|
+
background: '#00aa55',
|
|
96
|
+
color: '#000000',
|
|
97
|
+
range: 'Custom'
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
isEditor: true
|
|
102
|
+
},
|
|
103
|
+
play: async ({ canvasElement }) => {
|
|
104
|
+
await assertVisualizationRendered(canvasElement)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const Line_Previous_Days_Last_Date: Story = {
|
|
109
|
+
args: {
|
|
110
|
+
config: {
|
|
111
|
+
...baseDateConfig,
|
|
112
|
+
title: 'Date Scale - Line: Previous Days + Last Date',
|
|
113
|
+
regions: [
|
|
114
|
+
{
|
|
115
|
+
from: '28',
|
|
116
|
+
to: '',
|
|
117
|
+
fromType: 'Previous Days',
|
|
118
|
+
toType: 'Last Date',
|
|
119
|
+
label: 'Last 28 Days',
|
|
120
|
+
background: '#aa0077',
|
|
121
|
+
color: '#000000',
|
|
122
|
+
range: 'Custom'
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
isEditor: true
|
|
127
|
+
},
|
|
128
|
+
play: async ({ canvasElement }) => {
|
|
129
|
+
await assertVisualizationRendered(canvasElement)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// BAR CHARTS
|
|
134
|
+
|
|
135
|
+
export const Bar_Fixed_From_Fixed_To: Story = {
|
|
136
|
+
args: {
|
|
137
|
+
config: {
|
|
138
|
+
...baseDateConfig,
|
|
139
|
+
visualizationType: 'Bar',
|
|
140
|
+
barThickness: 0.7,
|
|
141
|
+
title: 'Date Scale - Bar: Fixed From + Fixed To',
|
|
142
|
+
regions: [
|
|
143
|
+
{
|
|
144
|
+
from: '2024-01-15',
|
|
145
|
+
to: '2024-02-12',
|
|
146
|
+
fromType: 'Fixed',
|
|
147
|
+
toType: 'Fixed',
|
|
148
|
+
label: 'Fixed Region',
|
|
149
|
+
background: '#0077cc',
|
|
150
|
+
color: '#000000',
|
|
151
|
+
range: 'Custom'
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
isEditor: true
|
|
156
|
+
},
|
|
157
|
+
play: async ({ canvasElement }) => {
|
|
158
|
+
await assertVisualizationRendered(canvasElement)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const Bar_Fixed_From_Last_Date: Story = {
|
|
163
|
+
args: {
|
|
164
|
+
config: {
|
|
165
|
+
...baseDateConfig,
|
|
166
|
+
visualizationType: 'Bar',
|
|
167
|
+
barThickness: 0.7,
|
|
168
|
+
title: 'Date Scale - Bar: Fixed From + Last Date',
|
|
169
|
+
regions: [
|
|
170
|
+
{
|
|
171
|
+
from: '2024-02-05',
|
|
172
|
+
to: '',
|
|
173
|
+
fromType: 'Fixed',
|
|
174
|
+
toType: 'Last Date',
|
|
175
|
+
label: 'To Last Date',
|
|
176
|
+
background: '#00aa55',
|
|
177
|
+
color: '#000000',
|
|
178
|
+
range: 'Custom'
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
isEditor: true
|
|
183
|
+
},
|
|
184
|
+
play: async ({ canvasElement }) => {
|
|
185
|
+
await assertVisualizationRendered(canvasElement)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const Bar_Previous_Days_Last_Date: Story = {
|
|
190
|
+
args: {
|
|
191
|
+
config: {
|
|
192
|
+
...baseDateConfig,
|
|
193
|
+
visualizationType: 'Bar',
|
|
194
|
+
barThickness: 0.7,
|
|
195
|
+
title: 'Date Scale - Bar: Previous Days + Last Date',
|
|
196
|
+
regions: [
|
|
197
|
+
{
|
|
198
|
+
from: '28',
|
|
199
|
+
to: '',
|
|
200
|
+
fromType: 'Previous Days',
|
|
201
|
+
toType: 'Last Date',
|
|
202
|
+
label: 'Last 28 Days',
|
|
203
|
+
background: '#aa0077',
|
|
204
|
+
color: '#000000',
|
|
205
|
+
range: 'Custom'
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
isEditor: true
|
|
210
|
+
},
|
|
211
|
+
play: async ({ canvasElement }) => {
|
|
212
|
+
await assertVisualizationRendered(canvasElement)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default meta
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChart'
|
|
3
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Chart> = {
|
|
6
|
+
title: 'Components/Templates/Chart/Regions/Date-Time Scale (Continuous)',
|
|
7
|
+
component: Chart
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof Chart>
|
|
11
|
+
|
|
12
|
+
const dateData = [
|
|
13
|
+
{ date: '2024-01-01', value: 10 },
|
|
14
|
+
{ date: '2024-01-08', value: 25 },
|
|
15
|
+
{ date: '2024-01-15', value: 35 },
|
|
16
|
+
{ date: '2024-01-22', value: 45 },
|
|
17
|
+
{ date: '2024-01-29', value: 55 },
|
|
18
|
+
{ date: '2024-02-05', value: 40 },
|
|
19
|
+
{ date: '2024-02-12', value: 60 },
|
|
20
|
+
{ date: '2024-02-19', value: 75 },
|
|
21
|
+
{ date: '2024-02-26', value: 65 },
|
|
22
|
+
{ date: '2024-03-04', value: 80 }
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
const baseDateTimeConfig = {
|
|
26
|
+
type: 'chart',
|
|
27
|
+
visualizationType: 'Line',
|
|
28
|
+
orientation: 'vertical',
|
|
29
|
+
showTitle: true,
|
|
30
|
+
theme: 'theme-blue',
|
|
31
|
+
animate: false,
|
|
32
|
+
xAxis: {
|
|
33
|
+
type: 'date-time',
|
|
34
|
+
dataKey: 'date',
|
|
35
|
+
dateParseFormat: '%Y-%m-%d',
|
|
36
|
+
dateDisplayFormat: '%b %-d',
|
|
37
|
+
size: '0',
|
|
38
|
+
hideAxis: false,
|
|
39
|
+
hideTicks: false,
|
|
40
|
+
numTicks: '6'
|
|
41
|
+
},
|
|
42
|
+
yAxis: {
|
|
43
|
+
size: '50',
|
|
44
|
+
hideAxis: false,
|
|
45
|
+
hideTicks: false,
|
|
46
|
+
gridLines: true,
|
|
47
|
+
min: '0',
|
|
48
|
+
max: '100'
|
|
49
|
+
},
|
|
50
|
+
series: [{ dataKey: 'value', type: 'Line', axis: 'Left', tooltip: true, name: 'Value' }],
|
|
51
|
+
legend: { hide: true },
|
|
52
|
+
data: dateData,
|
|
53
|
+
regions: []
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const play = async ({ canvasElement }) => {
|
|
57
|
+
await assertVisualizationRendered(canvasElement)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// LINE CHARTS
|
|
61
|
+
|
|
62
|
+
export const Line_Fixed_From_Fixed_To: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
config: {
|
|
65
|
+
...baseDateTimeConfig,
|
|
66
|
+
title: 'Date-Time Scale - Line: Fixed From + Fixed To',
|
|
67
|
+
regions: [
|
|
68
|
+
{
|
|
69
|
+
from: '2024-01-15',
|
|
70
|
+
to: '2024-02-11',
|
|
71
|
+
fromType: 'Fixed',
|
|
72
|
+
toType: 'Fixed',
|
|
73
|
+
label: 'Fixed Region',
|
|
74
|
+
background: '#0077cc',
|
|
75
|
+
color: '#000000',
|
|
76
|
+
range: 'Custom'
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
isEditor: true
|
|
81
|
+
},
|
|
82
|
+
play
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const Line_Fixed_From_Last_Date: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
config: {
|
|
88
|
+
...baseDateTimeConfig,
|
|
89
|
+
title: 'Date-Time Scale - Line: Fixed From + Last Date',
|
|
90
|
+
regions: [
|
|
91
|
+
{
|
|
92
|
+
from: '2024-02-05',
|
|
93
|
+
to: '',
|
|
94
|
+
fromType: 'Fixed',
|
|
95
|
+
toType: 'Last Date',
|
|
96
|
+
label: 'To Last Date',
|
|
97
|
+
background: '#00aa55',
|
|
98
|
+
color: '#000000',
|
|
99
|
+
range: 'Custom'
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
isEditor: true
|
|
104
|
+
},
|
|
105
|
+
play
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const Line_Previous_Days_Last_Date: Story = {
|
|
109
|
+
args: {
|
|
110
|
+
config: {
|
|
111
|
+
...baseDateTimeConfig,
|
|
112
|
+
title: 'Date-Time Scale - Line: Previous Days + Last Date',
|
|
113
|
+
regions: [
|
|
114
|
+
{
|
|
115
|
+
from: '8',
|
|
116
|
+
to: '',
|
|
117
|
+
fromType: 'Previous Days',
|
|
118
|
+
toType: 'Last Date',
|
|
119
|
+
label: 'Last 8 Days',
|
|
120
|
+
background: '#aa0077',
|
|
121
|
+
color: '#000000',
|
|
122
|
+
range: 'Custom'
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
isEditor: true
|
|
127
|
+
},
|
|
128
|
+
play
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// BAR CHARTS
|
|
132
|
+
|
|
133
|
+
export const Bar_Fixed_From_Fixed_To: Story = {
|
|
134
|
+
args: {
|
|
135
|
+
config: {
|
|
136
|
+
...baseDateTimeConfig,
|
|
137
|
+
visualizationType: 'Bar',
|
|
138
|
+
barThickness: 0.7,
|
|
139
|
+
title: 'Date-Time Scale - Bar: Fixed From + Fixed To',
|
|
140
|
+
regions: [
|
|
141
|
+
{
|
|
142
|
+
from: '2024-01-15',
|
|
143
|
+
to: '2024-02-12',
|
|
144
|
+
fromType: 'Fixed',
|
|
145
|
+
toType: 'Fixed',
|
|
146
|
+
label: 'Fixed Region',
|
|
147
|
+
background: '#0077cc',
|
|
148
|
+
color: '#000000',
|
|
149
|
+
range: 'Custom'
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
isEditor: true
|
|
154
|
+
},
|
|
155
|
+
play
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const Bar_Fixed_From_Last_Date: Story = {
|
|
159
|
+
args: {
|
|
160
|
+
config: {
|
|
161
|
+
...baseDateTimeConfig,
|
|
162
|
+
visualizationType: 'Bar',
|
|
163
|
+
barThickness: 0.7,
|
|
164
|
+
title: 'Date-Time Scale - Bar: Fixed From + Last Date',
|
|
165
|
+
regions: [
|
|
166
|
+
{
|
|
167
|
+
from: '2024-02-05',
|
|
168
|
+
to: '',
|
|
169
|
+
fromType: 'Fixed',
|
|
170
|
+
toType: 'Last Date',
|
|
171
|
+
label: 'To Last Date',
|
|
172
|
+
background: '#00aa55',
|
|
173
|
+
color: '#000000',
|
|
174
|
+
range: 'Custom'
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
isEditor: true
|
|
179
|
+
},
|
|
180
|
+
play
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export const Bar_Previous_Days_Last_Date: Story = {
|
|
184
|
+
args: {
|
|
185
|
+
config: {
|
|
186
|
+
...baseDateTimeConfig,
|
|
187
|
+
visualizationType: 'Bar',
|
|
188
|
+
barThickness: 0.7,
|
|
189
|
+
title: 'Date-Time Scale - Bar: Previous Days + Last Date',
|
|
190
|
+
regions: [
|
|
191
|
+
{
|
|
192
|
+
from: '28',
|
|
193
|
+
to: '',
|
|
194
|
+
fromType: 'Previous Days',
|
|
195
|
+
toType: 'Last Date',
|
|
196
|
+
label: 'Last 28 Days',
|
|
197
|
+
background: '#aa0077',
|
|
198
|
+
color: '#000000',
|
|
199
|
+
range: 'Custom'
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
isEditor: true
|
|
204
|
+
},
|
|
205
|
+
play
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// EDGE CASES
|
|
209
|
+
|
|
210
|
+
export const Edge_Region_At_Start: Story = {
|
|
211
|
+
args: {
|
|
212
|
+
config: {
|
|
213
|
+
...baseDateTimeConfig,
|
|
214
|
+
title: 'Edge Case: Region at Start',
|
|
215
|
+
regions: [
|
|
216
|
+
{
|
|
217
|
+
from: '2024-01-01',
|
|
218
|
+
to: '2024-01-21',
|
|
219
|
+
fromType: 'Fixed',
|
|
220
|
+
toType: 'Fixed',
|
|
221
|
+
label: 'At Start',
|
|
222
|
+
background: '#0077cc',
|
|
223
|
+
color: '#000000',
|
|
224
|
+
range: 'Custom'
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
isEditor: true
|
|
229
|
+
},
|
|
230
|
+
play
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const Edge_Region_At_End: Story = {
|
|
234
|
+
args: {
|
|
235
|
+
config: {
|
|
236
|
+
...baseDateTimeConfig,
|
|
237
|
+
title: 'Edge Case: Region at End',
|
|
238
|
+
regions: [
|
|
239
|
+
{
|
|
240
|
+
from: '2024-02-19',
|
|
241
|
+
to: '2024-03-04',
|
|
242
|
+
fromType: 'Fixed',
|
|
243
|
+
toType: 'Fixed',
|
|
244
|
+
label: 'At End',
|
|
245
|
+
background: '#00aa55',
|
|
246
|
+
color: '#000000',
|
|
247
|
+
range: 'Custom'
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
isEditor: true
|
|
252
|
+
},
|
|
253
|
+
play
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export const Edge_Full_Coverage: Story = {
|
|
257
|
+
args: {
|
|
258
|
+
config: {
|
|
259
|
+
...baseDateTimeConfig,
|
|
260
|
+
title: 'Edge Case: Full Chart Coverage',
|
|
261
|
+
regions: [
|
|
262
|
+
{
|
|
263
|
+
from: '2024-01-01',
|
|
264
|
+
to: '',
|
|
265
|
+
fromType: 'Fixed',
|
|
266
|
+
toType: 'Last Date',
|
|
267
|
+
label: 'Full Coverage',
|
|
268
|
+
background: '#cc7700',
|
|
269
|
+
color: '#000000',
|
|
270
|
+
range: 'Custom'
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
isEditor: true
|
|
275
|
+
},
|
|
276
|
+
play
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export const Multiple_Regions: Story = {
|
|
280
|
+
args: {
|
|
281
|
+
config: {
|
|
282
|
+
...baseDateTimeConfig,
|
|
283
|
+
title: 'Multiple Regions',
|
|
284
|
+
regions: [
|
|
285
|
+
{
|
|
286
|
+
from: '2024-01-08',
|
|
287
|
+
to: '2024-01-21',
|
|
288
|
+
fromType: 'Fixed',
|
|
289
|
+
toType: 'Fixed',
|
|
290
|
+
label: 'Region 1',
|
|
291
|
+
background: '#0077cc',
|
|
292
|
+
color: '#000000',
|
|
293
|
+
range: 'Custom'
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
from: '2024-02-05',
|
|
297
|
+
to: '2024-02-18',
|
|
298
|
+
fromType: 'Fixed',
|
|
299
|
+
toType: 'Fixed',
|
|
300
|
+
label: 'Region 2',
|
|
301
|
+
background: '#00aa55',
|
|
302
|
+
color: '#000000',
|
|
303
|
+
range: 'Custom'
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
isEditor: true
|
|
308
|
+
},
|
|
309
|
+
play
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export default meta
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
2
|
import Chart from '../CdcChartComponent'
|
|
3
3
|
import scatterPlotDownloadImage from './_mock/scatterplot-image-download.json'
|
|
4
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
4
5
|
|
|
5
6
|
const meta: Meta<typeof Chart> = {
|
|
6
7
|
title: 'Components/Templates/Chart/Scatter Plot Download Image',
|
|
@@ -13,6 +14,9 @@ export const ScatterPlot_Download_Image: Story = {
|
|
|
13
14
|
args: {
|
|
14
15
|
config: scatterPlotDownloadImage,
|
|
15
16
|
isEditor: false
|
|
17
|
+
},
|
|
18
|
+
play: async ({ canvasElement }) => {
|
|
19
|
+
await assertVisualizationRendered(canvasElement)
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -5,6 +5,7 @@ import smallMultiplesBigDataBars from './_mock/small_multiples/small_multiples_b
|
|
|
5
5
|
import smallMultiplesLinesColors from './_mock/small_multiples/small_multiples_lines_colors.json'
|
|
6
6
|
import smallMultiplesLines from './_mock/small_multiples/small_multiples_lines.json'
|
|
7
7
|
import smallMultiplesStackedBars from './_mock/small_multiples/small_multiples_stacked_bars.json'
|
|
8
|
+
import { assertVisualizationRendered } from '@cdc/core/helpers/testing'
|
|
8
9
|
|
|
9
10
|
const meta: Meta<typeof Chart> = {
|
|
10
11
|
title: 'Components/Templates/Chart/Small Multiples',
|
|
@@ -17,6 +18,9 @@ export const smallMultiples_Bars: Story = {
|
|
|
17
18
|
args: {
|
|
18
19
|
config: smallMultiplesBars,
|
|
19
20
|
isEditor: false
|
|
21
|
+
},
|
|
22
|
+
play: async ({ canvasElement }) => {
|
|
23
|
+
await assertVisualizationRendered(canvasElement)
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -24,24 +28,36 @@ export const smallMultiples_BigDataBars: Story = {
|
|
|
24
28
|
args: {
|
|
25
29
|
config: smallMultiplesBigDataBars,
|
|
26
30
|
isEditor: false
|
|
31
|
+
},
|
|
32
|
+
play: async ({ canvasElement }) => {
|
|
33
|
+
await assertVisualizationRendered(canvasElement)
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
export const smallMultiples_LinesColors: Story = {
|
|
30
37
|
args: {
|
|
31
38
|
config: smallMultiplesLinesColors,
|
|
32
39
|
isEditor: false
|
|
40
|
+
},
|
|
41
|
+
play: async ({ canvasElement }) => {
|
|
42
|
+
await assertVisualizationRendered(canvasElement)
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
export const smallMultiples_Lines: Story = {
|
|
36
46
|
args: {
|
|
37
47
|
config: smallMultiplesLines,
|
|
38
48
|
isEditor: false
|
|
49
|
+
},
|
|
50
|
+
play: async ({ canvasElement }) => {
|
|
51
|
+
await assertVisualizationRendered(canvasElement)
|
|
39
52
|
}
|
|
40
53
|
}
|
|
41
54
|
export const smallMultiples_StackedBars: Story = {
|
|
42
55
|
args: {
|
|
43
56
|
config: smallMultiplesStackedBars,
|
|
44
57
|
isEditor: false
|
|
58
|
+
},
|
|
59
|
+
play: async ({ canvasElement }) => {
|
|
60
|
+
await assertVisualizationRendered(canvasElement)
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
63
|
export default meta
|