@cdc/chart 4.25.10 → 4.26.1
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/dist/{cdcchart-1a1724a1.es.js → cdcchart-dgT_1dIT.es.js} +136 -151
- package/dist/cdcchart.js +44003 -43518
- package/examples/feature/__data__/planet-example-data.json +1 -1
- package/examples/feature/boxplot/valid-boxplot.csv +38 -17
- package/examples/feature/pie/planet-pie-example-config.json +48 -2
- package/examples/private/DEV-11825.json +573 -0
- package/examples/private/DEV-12100.json +1303 -0
- package/examples/private/cat-y.json +1235 -0
- package/examples/private/data-points.json +228 -0
- package/examples/private/height.json +3915 -0
- package/examples/private/links.json +569 -0
- package/examples/private/na.json +913 -0
- package/examples/private/quadrant.txt +30 -0
- package/examples/private/test-data.csv +28 -0
- package/examples/private/test-forecast.json +5510 -0
- package/examples/private/warming-stripe-test.json +2578 -0
- package/examples/private/warming-stripes.json +4763 -0
- package/examples/tech-adoption-with-links.json +560 -0
- package/index.html +16 -140
- package/package.json +6 -5
- package/preview.html +1616 -0
- package/src/CdcChart.tsx +8 -11
- package/src/CdcChartComponent.tsx +329 -124
- package/src/_stories/Chart.Combo.stories.tsx +18 -0
- package/src/_stories/Chart.Forecast.stories.tsx +36 -0
- package/src/_stories/Chart.HTMLInDataTable.stories.tsx +520 -0
- package/src/_stories/Chart.Patterns.stories.tsx +2 -1
- package/src/_stories/Chart.PreserveDecimals.stories.tsx +220 -0
- package/src/_stories/Chart.Regions.Categorical.stories.tsx +148 -0
- package/src/_stories/Chart.Regions.DateScale.stories.tsx +197 -0
- package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +297 -0
- package/src/_stories/Chart.SmallMultiples.stories.tsx +47 -0
- package/src/_stories/Chart.stories.tsx +8 -0
- package/src/_stories/ChartAnnotation.stories.tsx +6 -3
- package/src/_stories/ChartBar.Editor.stories.tsx +3585 -0
- package/src/_stories/ChartBrush.Editor.stories.tsx +295 -0
- package/src/_stories/ChartBrush.stories.tsx +50 -0
- package/src/_stories/ChartEditor.Editor.stories.tsx +656 -0
- package/src/_stories/ChartEditor.stories.tsx +1 -2
- package/src/_stories/TechAdoptionWithLinks.stories.tsx +27 -0
- package/src/_stories/_mock/brush_enabled.json +326 -0
- package/src/_stories/_mock/brush_mock.json +2 -69
- package/src/_stories/_mock/combo.json +451 -0
- package/src/_stories/_mock/editor-test-configs.json +376 -0
- package/src/_stories/_mock/editor-test-datasets.json +477 -0
- package/src/_stories/_mock/editor-tests/bar-chart-editor-test.json +255 -0
- package/src/_stories/_mock/editor-tests/bar-chart-general-test.json +267 -0
- package/src/_stories/_mock/editor-tests/bar-chart-test.json +237 -0
- package/src/_stories/_mock/forecast_combo_with_gaps.json +913 -0
- package/src/_stories/_mock/horizontal-bars-dynamic-y-axis.json +413 -0
- package/src/_stories/_mock/pie_config.json +257 -62
- package/src/_stories/_mock/small_multiples/small_multiples_bars.json +1944 -0
- package/src/_stories/_mock/small_multiples/small_multiples_big_data_bars.json +1114 -0
- package/src/_stories/_mock/small_multiples/small_multiples_lines.json +2646 -0
- package/src/_stories/_mock/small_multiples/small_multiples_lines_colors.json +1305 -0
- package/src/_stories/_mock/small_multiples/small_multiples_stacked_bars.json +1936 -0
- package/src/components/Annotations/components/findNearestDatum.ts +6 -41
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +10 -7
- package/src/components/AreaChart/index.tsx +1 -2
- package/src/components/Axis/Categorical.Axis.tsx +6 -7
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +181 -27
- 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 +8 -9
- package/src/components/BarChart/components/context.tsx +1 -0
- package/src/components/BarChart/helpers/useBarChart.ts +14 -2
- package/src/components/BoxPlot/helpers/index.ts +3 -3
- package/src/components/Brush/BrushSelector.tsx +1258 -0
- package/src/components/Brush/MiniChartPreview.tsx +283 -0
- package/src/components/DeviationBar.jsx +9 -7
- package/src/components/EditorPanel/EditorPanel.tsx +2720 -2586
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +96 -111
- package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +56 -34
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +76 -31
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +104 -55
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +54 -49
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +427 -0
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +96 -48
- package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
- package/src/components/EditorPanel/editor-panel.scss +0 -20
- package/src/components/EditorPanel/useEditorPermissions.ts +36 -31
- package/src/components/Forecasting/Forecasting.tsx +139 -21
- package/src/components/Legend/Legend.Component.tsx +16 -9
- package/src/components/Legend/Legend.tsx +3 -2
- package/src/components/Legend/helpers/createFormatLabels.tsx +325 -176
- package/src/components/Legend/helpers/getLegendClasses.ts +0 -1
- package/src/components/Legend/helpers/index.ts +10 -6
- package/src/components/LineChart/LineChartProps.ts +0 -3
- package/src/components/LineChart/helpers.ts +1 -1
- package/src/components/LineChart/index.tsx +36 -13
- package/src/components/LinearChart.tsx +559 -499
- package/src/components/PairedBarChart.jsx +20 -3
- package/src/components/Regions/components/Regions.tsx +366 -144
- package/src/components/Sankey/types/index.ts +1 -1
- package/src/components/ScatterPlot/ScatterPlot.jsx +2 -2
- package/src/components/SmallMultiples/SmallMultipleTile.tsx +202 -0
- package/src/components/SmallMultiples/SmallMultiples.css +32 -0
- package/src/components/SmallMultiples/SmallMultiples.tsx +271 -0
- package/src/components/SmallMultiples/index.ts +2 -0
- package/src/components/WarmingStripes/WarmingStripes.tsx +160 -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 +16 -2
- package/src/helpers/buildForecastPaletteOptions.ts +0 -38
- package/src/helpers/calculateHorizontalBarCategoryLabelWidth.ts +57 -0
- package/src/helpers/getColorScale.ts +10 -0
- package/src/{hooks/useMinMax.ts → helpers/getMinMax.ts} +26 -14
- package/src/helpers/getYAxisAutoPadding.ts +53 -0
- package/src/helpers/sizeHelpers.ts +0 -20
- package/src/helpers/smallMultiplesHelpers.ts +529 -0
- package/src/hooks/useChartHoverAnalytics.tsx +10 -9
- package/src/hooks/useProgrammaticTooltip.ts +96 -0
- package/src/hooks/useScales.ts +98 -34
- package/src/hooks/useSmallMultipleSynchronization.ts +59 -0
- package/src/hooks/useTooltip.tsx +91 -25
- package/src/scss/DataTable.scss +0 -4
- package/src/scss/main.scss +18 -83
- package/src/store/chart.actions.ts +2 -0
- package/src/store/chart.reducer.ts +4 -0
- package/src/test/CdcChart.test.jsx +1 -1
- package/src/types/ChartConfig.ts +27 -6
- package/src/types/ChartContext.ts +3 -0
- package/src/types/Label.ts +1 -0
- package/src/utils/analyticsTracking.ts +19 -0
- package/LICENSE +0 -201
- package/src/_stories/_mock/pie_data.json +0 -218
- package/src/components/AreaChart/components/AreaChart.jsx +0 -109
- 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
- package/src/helpers/sort.ts +0 -7
- package/src/hooks/useActiveElement.js +0 -19
- package/src/hooks/useChartClasses.js +0 -41
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChartComponent'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Chart> = {
|
|
5
|
+
title: 'Components/Templates/Chart/Preserve Original Decimals',
|
|
6
|
+
component: Chart
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof Chart>
|
|
10
|
+
|
|
11
|
+
// Mock data with mixed decimal precision
|
|
12
|
+
const mixedDecimalData = [
|
|
13
|
+
{ Year: '2020', Value: '1000' },
|
|
14
|
+
{ Year: '2021', Value: '45.7' },
|
|
15
|
+
{ Year: '2022', Value: '12' },
|
|
16
|
+
{ Year: '2023', Value: '89.23' },
|
|
17
|
+
{ Year: '2024', Value: '156' },
|
|
18
|
+
{ Year: '2025', Value: '23.5' }
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const baseConfig: any = {
|
|
22
|
+
type: 'chart',
|
|
23
|
+
visualizationType: 'Bar',
|
|
24
|
+
data: mixedDecimalData,
|
|
25
|
+
xAxis: {
|
|
26
|
+
dataKey: 'Year',
|
|
27
|
+
type: 'categorical'
|
|
28
|
+
},
|
|
29
|
+
yAxis: {
|
|
30
|
+
label: 'Value'
|
|
31
|
+
},
|
|
32
|
+
series: [
|
|
33
|
+
{
|
|
34
|
+
dataKey: 'Value'
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
dataFormat: {
|
|
38
|
+
commas: true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Default_With_Forced_Rounding: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
config: {
|
|
45
|
+
...baseConfig,
|
|
46
|
+
dataFormat: {
|
|
47
|
+
commas: true,
|
|
48
|
+
roundTo: 1
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
parameters: {
|
|
53
|
+
docs: {
|
|
54
|
+
description: {
|
|
55
|
+
story:
|
|
56
|
+
'Default behavior forces all numbers to 1 decimal place. Notice how whole numbers like 1000 become "1,000.0" and 89.23 gets rounded to "89.2".'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Preserve_Original_Decimals_Enabled: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
config: {
|
|
65
|
+
...baseConfig,
|
|
66
|
+
dataFormat: {
|
|
67
|
+
commas: true,
|
|
68
|
+
roundTo: 1,
|
|
69
|
+
preserveOriginalDecimals: true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
parameters: {
|
|
74
|
+
docs: {
|
|
75
|
+
description: {
|
|
76
|
+
story:
|
|
77
|
+
'With "Preserve Original Decimals" enabled, numbers display exactly as they appear in the data: 1000 shows as "1,000", 45.7 shows as "45.7", and 89.23 shows as "89.23". The roundTo setting is ignored.'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Comparison_No_Decimals: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
config: {
|
|
86
|
+
...baseConfig,
|
|
87
|
+
dataFormat: {
|
|
88
|
+
commas: true,
|
|
89
|
+
roundTo: 0
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
parameters: {
|
|
94
|
+
docs: {
|
|
95
|
+
description: {
|
|
96
|
+
story:
|
|
97
|
+
'Forcing 0 decimal places rounds everything to whole numbers: 45.7 becomes "46", 89.23 becomes "89". This loses precision from the original data.'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const Comparison_Two_Decimals: Story = {
|
|
104
|
+
args: {
|
|
105
|
+
config: {
|
|
106
|
+
...baseConfig,
|
|
107
|
+
dataFormat: {
|
|
108
|
+
commas: true,
|
|
109
|
+
roundTo: 2
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
parameters: {
|
|
114
|
+
docs: {
|
|
115
|
+
description: {
|
|
116
|
+
story:
|
|
117
|
+
'Forcing 2 decimal places adds unnecessary zeros: 1000 becomes "1,000.00", 45.7 becomes "45.70". This can look cluttered for whole numbers.'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const With_Prefix_And_Suffix: Story = {
|
|
124
|
+
args: {
|
|
125
|
+
config: {
|
|
126
|
+
...baseConfig,
|
|
127
|
+
dataFormat: {
|
|
128
|
+
commas: true,
|
|
129
|
+
prefix: '$',
|
|
130
|
+
suffix: ' USD',
|
|
131
|
+
preserveOriginalDecimals: true
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
parameters: {
|
|
136
|
+
docs: {
|
|
137
|
+
description: {
|
|
138
|
+
story:
|
|
139
|
+
'Preserve Original Decimals works seamlessly with prefix and suffix formatting. Numbers show as "$1,000 USD", "$45.7 USD", etc.'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const Percentage_Data_Mixed_Precision: Story = {
|
|
146
|
+
args: {
|
|
147
|
+
config: {
|
|
148
|
+
...baseConfig,
|
|
149
|
+
data: [
|
|
150
|
+
{ Year: 'Region 1', Value: '25' },
|
|
151
|
+
{ Year: 'Region 2', Value: '33.3' },
|
|
152
|
+
{ Year: 'Region 3', Value: '50' },
|
|
153
|
+
{ Year: 'Region 4', Value: '12.75' },
|
|
154
|
+
{ Year: 'Region 5', Value: '8.5' }
|
|
155
|
+
],
|
|
156
|
+
dataFormat: {
|
|
157
|
+
suffix: '%',
|
|
158
|
+
preserveOriginalDecimals: true,
|
|
159
|
+
commas: false
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
parameters: {
|
|
164
|
+
docs: {
|
|
165
|
+
description: {
|
|
166
|
+
story:
|
|
167
|
+
'Perfect for percentage data where some values are whole (25%, 50%) and others need decimals (33.3%, 12.75%). Each value displays naturally without forced rounding.'
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const Line_Chart_With_Table: Story = {
|
|
174
|
+
args: {
|
|
175
|
+
config: {
|
|
176
|
+
...baseConfig,
|
|
177
|
+
visualizationType: 'Line',
|
|
178
|
+
dataFormat: {
|
|
179
|
+
commas: true,
|
|
180
|
+
preserveOriginalDecimals: true
|
|
181
|
+
},
|
|
182
|
+
table: {
|
|
183
|
+
show: true,
|
|
184
|
+
label: 'Data Table',
|
|
185
|
+
expanded: true
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
parameters: {
|
|
190
|
+
docs: {
|
|
191
|
+
description: {
|
|
192
|
+
story:
|
|
193
|
+
'When enabled, the preserve decimals setting applies to both the chart axis/tooltips AND the data table, ensuring consistency across all displays.'
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export const Editor_Mode: Story = {
|
|
200
|
+
args: {
|
|
201
|
+
config: {
|
|
202
|
+
...baseConfig,
|
|
203
|
+
dataFormat: {
|
|
204
|
+
commas: true,
|
|
205
|
+
roundTo: 1
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
isEditor: true
|
|
209
|
+
},
|
|
210
|
+
parameters: {
|
|
211
|
+
docs: {
|
|
212
|
+
description: {
|
|
213
|
+
story:
|
|
214
|
+
'In editor mode, look for the "Preserve Original Decimal Places" checkbox in the Number Formatting section, right below the "Round to decimal point" field. Toggle it to see the effect in real-time.'
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default meta
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChart'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Chart> = {
|
|
5
|
+
title: 'Components/Templates/Chart/Regions/Categorical',
|
|
6
|
+
component: Chart
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof Chart>
|
|
10
|
+
|
|
11
|
+
const categoricalData = [
|
|
12
|
+
{ category: 'Jan 1', value: 10 },
|
|
13
|
+
{ category: 'Jan 8', value: 25 },
|
|
14
|
+
{ category: 'Jan 15', value: 35 },
|
|
15
|
+
{ category: 'Jan 22', value: 45 },
|
|
16
|
+
{ category: 'Jan 29', value: 55 },
|
|
17
|
+
{ category: 'Feb 5', value: 40 },
|
|
18
|
+
{ category: 'Feb 12', value: 60 },
|
|
19
|
+
{ category: 'Feb 19', value: 75 },
|
|
20
|
+
{ category: 'Feb 26', value: 65 },
|
|
21
|
+
{ category: 'Mar 4', value: 80 }
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const baseCategoricalConfig = {
|
|
25
|
+
type: 'chart',
|
|
26
|
+
visualizationType: 'Line',
|
|
27
|
+
orientation: 'vertical',
|
|
28
|
+
showTitle: true,
|
|
29
|
+
theme: 'theme-blue',
|
|
30
|
+
animate: false,
|
|
31
|
+
xAxis: {
|
|
32
|
+
type: 'categorical',
|
|
33
|
+
dataKey: 'category',
|
|
34
|
+
size: '0',
|
|
35
|
+
hideAxis: false,
|
|
36
|
+
hideTicks: false
|
|
37
|
+
},
|
|
38
|
+
yAxis: {
|
|
39
|
+
size: '50',
|
|
40
|
+
hideAxis: false,
|
|
41
|
+
hideTicks: false,
|
|
42
|
+
gridLines: true,
|
|
43
|
+
min: '0',
|
|
44
|
+
max: '100'
|
|
45
|
+
},
|
|
46
|
+
series: [{ dataKey: 'value', type: 'Line', axis: 'Left', tooltip: true, name: 'Value' }],
|
|
47
|
+
legend: { hide: true },
|
|
48
|
+
data: categoricalData,
|
|
49
|
+
regions: []
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// LINE CHARTS
|
|
53
|
+
|
|
54
|
+
export const Line_Fixed_From_Fixed_To: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
config: {
|
|
57
|
+
...baseCategoricalConfig,
|
|
58
|
+
title: 'Categorical - Line: Fixed From + Fixed To',
|
|
59
|
+
regions: [
|
|
60
|
+
{
|
|
61
|
+
from: 'Jan 15',
|
|
62
|
+
to: 'Feb 12',
|
|
63
|
+
fromType: 'Fixed',
|
|
64
|
+
toType: 'Fixed',
|
|
65
|
+
label: 'Fixed Region',
|
|
66
|
+
background: '#0077cc',
|
|
67
|
+
color: '#000000',
|
|
68
|
+
range: 'Custom'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
isEditor: true
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const Line_Fixed_From_Last_Date: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
config: {
|
|
79
|
+
...baseCategoricalConfig,
|
|
80
|
+
title: 'Categorical - Line: Fixed From + Last Date',
|
|
81
|
+
regions: [
|
|
82
|
+
{
|
|
83
|
+
from: 'Feb 5',
|
|
84
|
+
to: '',
|
|
85
|
+
fromType: 'Fixed',
|
|
86
|
+
toType: 'Last Date',
|
|
87
|
+
label: 'To Last Date',
|
|
88
|
+
background: '#00aa55',
|
|
89
|
+
color: '#000000',
|
|
90
|
+
range: 'Custom'
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
isEditor: true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// BAR CHARTS
|
|
99
|
+
|
|
100
|
+
export const Bar_Fixed_From_Fixed_To: Story = {
|
|
101
|
+
args: {
|
|
102
|
+
config: {
|
|
103
|
+
...baseCategoricalConfig,
|
|
104
|
+
visualizationType: 'Bar',
|
|
105
|
+
barThickness: 0.7,
|
|
106
|
+
title: 'Categorical - Bar: Fixed From + Fixed To',
|
|
107
|
+
regions: [
|
|
108
|
+
{
|
|
109
|
+
from: 'Jan 15',
|
|
110
|
+
to: 'Feb 12',
|
|
111
|
+
fromType: 'Fixed',
|
|
112
|
+
toType: 'Fixed',
|
|
113
|
+
label: 'Fixed Region',
|
|
114
|
+
background: '#0077cc',
|
|
115
|
+
color: '#000000',
|
|
116
|
+
range: 'Custom'
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
isEditor: true
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const Bar_Fixed_From_Last_Date: Story = {
|
|
125
|
+
args: {
|
|
126
|
+
config: {
|
|
127
|
+
...baseCategoricalConfig,
|
|
128
|
+
visualizationType: 'Bar',
|
|
129
|
+
barThickness: 0.7,
|
|
130
|
+
title: 'Categorical - Bar: Fixed From + Last Date',
|
|
131
|
+
regions: [
|
|
132
|
+
{
|
|
133
|
+
from: 'Feb 5',
|
|
134
|
+
to: '',
|
|
135
|
+
fromType: 'Fixed',
|
|
136
|
+
toType: 'Last Date',
|
|
137
|
+
label: 'To Last Date',
|
|
138
|
+
background: '#00aa55',
|
|
139
|
+
color: '#000000',
|
|
140
|
+
range: 'Custom'
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
isEditor: true
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default meta
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChart'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Chart> = {
|
|
5
|
+
title: 'Components/Templates/Chart/Regions/Date Scale (Band)',
|
|
6
|
+
component: Chart
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type Story = StoryObj<typeof Chart>
|
|
10
|
+
|
|
11
|
+
const dateData = [
|
|
12
|
+
{ date: '2024-01-01', value: 10 },
|
|
13
|
+
{ date: '2024-01-08', value: 25 },
|
|
14
|
+
{ date: '2024-01-15', value: 35 },
|
|
15
|
+
{ date: '2024-01-22', value: 45 },
|
|
16
|
+
{ date: '2024-01-29', value: 55 },
|
|
17
|
+
{ date: '2024-02-05', value: 40 },
|
|
18
|
+
{ date: '2024-02-12', value: 60 },
|
|
19
|
+
{ date: '2024-02-19', value: 75 },
|
|
20
|
+
{ date: '2024-02-26', value: 65 },
|
|
21
|
+
{ date: '2024-03-04', value: 80 }
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const baseDateConfig = {
|
|
25
|
+
type: 'chart',
|
|
26
|
+
visualizationType: 'Line',
|
|
27
|
+
orientation: 'vertical',
|
|
28
|
+
showTitle: true,
|
|
29
|
+
theme: 'theme-blue',
|
|
30
|
+
animate: false,
|
|
31
|
+
xAxis: {
|
|
32
|
+
type: 'date',
|
|
33
|
+
dataKey: 'date',
|
|
34
|
+
dateParseFormat: '%Y-%m-%d',
|
|
35
|
+
dateDisplayFormat: '%b %-d',
|
|
36
|
+
size: '0',
|
|
37
|
+
hideAxis: false,
|
|
38
|
+
hideTicks: false,
|
|
39
|
+
numTicks: '6'
|
|
40
|
+
},
|
|
41
|
+
yAxis: {
|
|
42
|
+
size: '50',
|
|
43
|
+
hideAxis: false,
|
|
44
|
+
hideTicks: false,
|
|
45
|
+
gridLines: true,
|
|
46
|
+
min: '0',
|
|
47
|
+
max: '100'
|
|
48
|
+
},
|
|
49
|
+
series: [{ dataKey: 'value', type: 'Line', axis: 'Left', tooltip: true, name: 'Value' }],
|
|
50
|
+
legend: { hide: true },
|
|
51
|
+
data: dateData,
|
|
52
|
+
regions: []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// LINE CHARTS
|
|
56
|
+
|
|
57
|
+
export const Line_Fixed_From_Fixed_To: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
config: {
|
|
60
|
+
...baseDateConfig,
|
|
61
|
+
title: 'Date Scale - Line: Fixed From + Fixed To',
|
|
62
|
+
regions: [
|
|
63
|
+
{
|
|
64
|
+
from: '2024-01-15',
|
|
65
|
+
to: '2024-02-12',
|
|
66
|
+
fromType: 'Fixed',
|
|
67
|
+
toType: 'Fixed',
|
|
68
|
+
label: 'Fixed Region',
|
|
69
|
+
background: '#0077cc',
|
|
70
|
+
color: '#000000',
|
|
71
|
+
range: 'Custom'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
isEditor: true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const Line_Fixed_From_Last_Date: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
config: {
|
|
82
|
+
...baseDateConfig,
|
|
83
|
+
title: 'Date Scale - Line: Fixed From + Last Date',
|
|
84
|
+
regions: [
|
|
85
|
+
{
|
|
86
|
+
from: '2024-02-05',
|
|
87
|
+
to: '',
|
|
88
|
+
fromType: 'Fixed',
|
|
89
|
+
toType: 'Last Date',
|
|
90
|
+
label: 'To Last Date',
|
|
91
|
+
background: '#00aa55',
|
|
92
|
+
color: '#000000',
|
|
93
|
+
range: 'Custom'
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
isEditor: true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const Line_Previous_Days_Last_Date: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
config: {
|
|
104
|
+
...baseDateConfig,
|
|
105
|
+
title: 'Date Scale - Line: Previous Days + Last Date',
|
|
106
|
+
regions: [
|
|
107
|
+
{
|
|
108
|
+
from: '28',
|
|
109
|
+
to: '',
|
|
110
|
+
fromType: 'Previous Days',
|
|
111
|
+
toType: 'Last Date',
|
|
112
|
+
label: 'Last 28 Days',
|
|
113
|
+
background: '#aa0077',
|
|
114
|
+
color: '#000000',
|
|
115
|
+
range: 'Custom'
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
isEditor: true
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// BAR CHARTS
|
|
124
|
+
|
|
125
|
+
export const Bar_Fixed_From_Fixed_To: Story = {
|
|
126
|
+
args: {
|
|
127
|
+
config: {
|
|
128
|
+
...baseDateConfig,
|
|
129
|
+
visualizationType: 'Bar',
|
|
130
|
+
barThickness: 0.7,
|
|
131
|
+
title: 'Date Scale - Bar: Fixed From + Fixed To',
|
|
132
|
+
regions: [
|
|
133
|
+
{
|
|
134
|
+
from: '2024-01-15',
|
|
135
|
+
to: '2024-02-12',
|
|
136
|
+
fromType: 'Fixed',
|
|
137
|
+
toType: 'Fixed',
|
|
138
|
+
label: 'Fixed Region',
|
|
139
|
+
background: '#0077cc',
|
|
140
|
+
color: '#000000',
|
|
141
|
+
range: 'Custom'
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
isEditor: true
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const Bar_Fixed_From_Last_Date: Story = {
|
|
150
|
+
args: {
|
|
151
|
+
config: {
|
|
152
|
+
...baseDateConfig,
|
|
153
|
+
visualizationType: 'Bar',
|
|
154
|
+
barThickness: 0.7,
|
|
155
|
+
title: 'Date Scale - Bar: Fixed From + Last Date',
|
|
156
|
+
regions: [
|
|
157
|
+
{
|
|
158
|
+
from: '2024-02-05',
|
|
159
|
+
to: '',
|
|
160
|
+
fromType: 'Fixed',
|
|
161
|
+
toType: 'Last Date',
|
|
162
|
+
label: 'To Last Date',
|
|
163
|
+
background: '#00aa55',
|
|
164
|
+
color: '#000000',
|
|
165
|
+
range: 'Custom'
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
isEditor: true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const Bar_Previous_Days_Last_Date: Story = {
|
|
174
|
+
args: {
|
|
175
|
+
config: {
|
|
176
|
+
...baseDateConfig,
|
|
177
|
+
visualizationType: 'Bar',
|
|
178
|
+
barThickness: 0.7,
|
|
179
|
+
title: 'Date Scale - Bar: Previous Days + Last Date',
|
|
180
|
+
regions: [
|
|
181
|
+
{
|
|
182
|
+
from: '28',
|
|
183
|
+
to: '',
|
|
184
|
+
fromType: 'Previous Days',
|
|
185
|
+
toType: 'Last Date',
|
|
186
|
+
label: 'Last 28 Days',
|
|
187
|
+
background: '#aa0077',
|
|
188
|
+
color: '#000000',
|
|
189
|
+
range: 'Custom'
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
isEditor: true
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default meta
|