@cdc/chart 4.25.10 → 4.25.11
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 +36258 -34658
- package/examples/feature/__data__/planet-example-data.json +1 -1
- package/examples/feature/boxplot/valid-boxplot.csv +38 -17
- package/examples/private/DEV-11825.json +573 -0
- package/examples/private/na.json +913 -0
- package/examples/private/test-data.csv +28 -0
- package/index.html +2 -121
- package/package.json +4 -4
- package/src/CdcChart.tsx +8 -11
- package/src/CdcChartComponent.tsx +256 -87
- 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.SmallMultiples.stories.tsx +47 -0
- package/src/_stories/ChartAnnotation.stories.tsx +6 -3
- package/src/_stories/ChartBar.Editor.stories.tsx +3580 -0
- package/src/_stories/ChartEditor.Editor.stories.tsx +658 -0
- package/src/_stories/ChartEditor.stories.tsx +1 -2
- 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/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 -6
- package/src/components/AreaChart/index.tsx +1 -2
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +4 -4
- package/src/components/BarChart/components/BarChart.Vertical.tsx +3 -2
- package/src/components/BoxPlot/helpers/index.ts +3 -3
- package/src/components/Brush/BrushChart.tsx +1 -1
- package/src/components/EditorPanel/EditorPanel.tsx +199 -190
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +96 -111
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +19 -1
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +102 -55
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +54 -49
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +422 -0
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +75 -21
- 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 +7 -15
- package/src/components/Forecasting/Forecasting.tsx +139 -21
- package/src/components/Legend/Legend.Component.tsx +16 -9
- package/src/components/Legend/helpers/createFormatLabels.tsx +181 -181
- package/src/components/Legend/helpers/getLegendClasses.ts +0 -1
- 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 +75 -80
- package/src/components/Regions/components/Regions.tsx +3 -24
- package/src/components/Sankey/types/index.ts +1 -1
- package/src/components/SmallMultiples/SmallMultipleTile.tsx +198 -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/data/initial-state.js +13 -1
- package/src/helpers/buildForecastPaletteOptions.ts +0 -38
- package/src/helpers/getColorScale.ts +10 -0
- package/src/{hooks/useMinMax.ts → helpers/getMinMax.ts} +14 -7
- package/src/helpers/getYAxisAutoPadding.ts +53 -0
- package/src/helpers/smallMultiplesHelpers.ts +529 -0
- package/src/hooks/useProgrammaticTooltip.ts +96 -0
- package/src/hooks/useScales.ts +88 -34
- package/src/hooks/useSmallMultipleSynchronization.ts +59 -0
- package/src/hooks/useTooltip.tsx +60 -15
- package/src/scss/main.scss +1 -80
- package/src/store/chart.actions.ts +2 -0
- package/src/store/chart.reducer.ts +4 -0
- package/src/types/ChartConfig.ts +24 -6
- package/src/types/ChartContext.ts +3 -0
- package/src/_stories/_mock/pie_data.json +0 -218
- package/src/components/AreaChart/components/AreaChart.jsx +0 -109
- 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,47 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import Chart from '../CdcChartComponent'
|
|
3
|
+
import smallMultiplesBars from './_mock/small_multiples/small_multiples_bars.json'
|
|
4
|
+
import smallMultiplesBigDataBars from './_mock/small_multiples/small_multiples_big_data_bars.json'
|
|
5
|
+
import smallMultiplesLinesColors from './_mock/small_multiples/small_multiples_lines_colors.json'
|
|
6
|
+
import smallMultiplesLines from './_mock/small_multiples/small_multiples_lines.json'
|
|
7
|
+
import smallMultiplesStackedBars from './_mock/small_multiples/small_multiples_stacked_bars.json'
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Chart> = {
|
|
10
|
+
title: 'Components/Templates/Chart/Small Multiples',
|
|
11
|
+
component: Chart
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Story = StoryObj<typeof Chart>
|
|
15
|
+
|
|
16
|
+
export const smallMultiples_Bars: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
config: smallMultiplesBars,
|
|
19
|
+
isEditor: false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const smallMultiples_BigDataBars: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
config: smallMultiplesBigDataBars,
|
|
26
|
+
isEditor: false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const smallMultiples_LinesColors: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
config: smallMultiplesLinesColors,
|
|
32
|
+
isEditor: false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const smallMultiples_Lines: Story = {
|
|
36
|
+
args: {
|
|
37
|
+
config: smallMultiplesLines,
|
|
38
|
+
isEditor: false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const smallMultiples_StackedBars: Story = {
|
|
42
|
+
args: {
|
|
43
|
+
config: smallMultiplesStackedBars,
|
|
44
|
+
isEditor: false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export default meta
|
|
@@ -13,19 +13,22 @@ type Story = StoryObj<typeof Chart>
|
|
|
13
13
|
|
|
14
14
|
export const Chart_Annotation_Categorical: Story = {
|
|
15
15
|
args: {
|
|
16
|
-
config: annotationConfig
|
|
16
|
+
config: annotationConfig,
|
|
17
|
+
isEditor: true
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const Chart_Annotation_Date_Linear: Story = {
|
|
21
22
|
args: {
|
|
22
|
-
config: annotationConfigDateLinear
|
|
23
|
+
config: annotationConfigDateLinear,
|
|
24
|
+
isEditor: true
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export const Chart_Annotation_Date_Time: Story = {
|
|
27
29
|
args: {
|
|
28
|
-
config: annotationConfigDateTime
|
|
30
|
+
config: annotationConfigDateTime,
|
|
31
|
+
isEditor: true
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|