@cdc/chart 4.25.8 → 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/.claude/settings.local.json +9 -0
- package/dist/{cdcchart-1a1724a1.es.js → cdcchart-dgT_1dIT.es.js} +136 -151
- package/dist/cdcchart.js +44236 -40355
- package/examples/feature/__data__/planet-example-data.json +0 -30
- package/examples/feature/boxplot/valid-boxplot.csv +38 -17
- package/examples/grouped-bar-test.json +400 -0
- package/examples/private/DEV-11825.json +573 -0
- package/examples/private/d.json +382 -0
- package/examples/private/example-2.json +49784 -0
- package/examples/private/f2.json +1 -0
- package/examples/private/f4.json +1577 -0
- package/examples/private/forecast.json +1180 -0
- package/examples/private/lollipop.json +468 -0
- package/examples/private/na.json +913 -0
- package/examples/private/new.json +48756 -0
- package/examples/private/pie-chart-legend.json +904 -0
- package/examples/private/test-data.csv +28 -0
- package/examples/suppressed_tooltip.json +480 -0
- package/index.html +2 -133
- package/package.json +25 -7
- package/src/CdcChart.tsx +9 -13
- package/src/CdcChartComponent.tsx +403 -92
- package/src/_stories/Chart.Anchors.stories.tsx +2 -2
- package/src/_stories/Chart.BoxPlot.stories.tsx +1 -1
- package/src/_stories/Chart.CI.stories.tsx +1 -1
- package/src/_stories/Chart.Combo.stories.tsx +18 -0
- package/src/_stories/Chart.CustomColors.stories.tsx +1 -1
- package/src/_stories/Chart.DynamicSeries.stories.tsx +2 -2
- package/src/_stories/Chart.Filters.stories.tsx +2 -2
- package/src/_stories/Chart.Forecast.stories.tsx +36 -0
- package/src/_stories/Chart.HTMLInDataTable.stories.tsx +520 -0
- package/src/_stories/Chart.Legend.Gradient.stories.tsx +2 -2
- package/src/_stories/Chart.Patterns.stories.tsx +20 -0
- package/src/_stories/Chart.PreserveDecimals.stories.tsx +220 -0
- package/src/_stories/Chart.ScatterPlot.stories.tsx +1 -1
- package/src/_stories/Chart.SmallMultiples.stories.tsx +47 -0
- package/src/_stories/Chart.stories.tsx +8 -5
- package/src/_stories/Chart.tooltip.stories.tsx +1 -1
- package/src/_stories/ChartAnnotation.stories.tsx +7 -4
- package/src/_stories/ChartAxisLabels.stories.tsx +2 -2
- package/src/_stories/ChartAxisTitles.stories.tsx +2 -2
- package/src/_stories/ChartBar.Editor.stories.tsx +3580 -0
- package/src/_stories/ChartEditor.Editor.stories.tsx +658 -0
- package/src/_stories/ChartEditor.stories.tsx +59 -60
- package/src/_stories/ChartLine.Suppression.stories.tsx +1 -1
- package/src/_stories/ChartLine.Symbols.stories.tsx +1 -1
- package/src/_stories/ChartPrefixSuffix.stories.tsx +2 -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/_stories/_mock/stacked-pattern-test.json +520 -0
- package/src/components/Annotations/components/AnnotationDraggable.tsx +1 -0
- package/src/components/Annotations/components/AnnotationDropdown.tsx +1 -1
- 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 +161 -22
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +138 -5
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +215 -73
- package/src/components/BarChart/components/BarChart.Vertical.tsx +155 -22
- package/src/components/BarChart/helpers/index.ts +43 -4
- package/src/components/BarChart/helpers/lollipopColors.ts +27 -0
- package/src/components/BarChart/helpers/useBarChart.ts +25 -3
- package/src/components/BoxPlot/BoxPlot.Vertical.tsx +2 -1
- package/src/components/BoxPlot/helpers/index.ts +3 -3
- package/src/components/Brush/BrushChart.tsx +1 -1
- package/src/components/DeviationBar.jsx +9 -6
- package/src/components/EditorPanel/EditorPanel.tsx +563 -229
- package/src/components/EditorPanel/EditorPanelContext.ts +3 -0
- 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 +461 -0
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +80 -67
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +422 -0
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +188 -139
- package/src/components/EditorPanel/components/Panels/index.tsx +5 -1
- package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +0 -8
- package/src/components/EditorPanel/editor-panel.scss +0 -20
- package/src/components/EditorPanel/helpers/updateFieldRankByValue.ts +49 -48
- package/src/components/EditorPanel/useEditorPermissions.ts +7 -15
- package/src/components/Forecasting/Forecasting.tsx +175 -27
- package/src/components/ForestPlot/ForestPlot.tsx +11 -7
- package/src/components/ForestPlot/ForestPlotProps.ts +1 -1
- package/src/components/Legend/Legend.Component.tsx +114 -14
- package/src/components/Legend/helpers/createFormatLabels.tsx +230 -171
- package/src/components/Legend/helpers/getLegendClasses.ts +0 -1
- package/src/components/LegendWrapper.tsx +1 -1
- package/src/components/LineChart/LineChartProps.ts +0 -3
- package/src/components/LineChart/components/LineChart.Circle.tsx +2 -2
- package/src/components/LineChart/helpers.ts +1 -1
- package/src/components/LineChart/index.tsx +38 -15
- package/src/components/LinearChart.tsx +96 -84
- package/src/components/PairedBarChart.jsx +6 -4
- package/src/components/PieChart/PieChart.tsx +170 -54
- package/src/components/Regions/components/Regions.tsx +3 -24
- package/src/components/Sankey/components/Sankey.tsx +7 -1
- package/src/components/Sankey/types/index.ts +1 -1
- package/src/components/ScatterPlot/ScatterPlot.jsx +32 -4
- 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 +327 -293
- package/src/helpers/buildForecastPaletteMappings.ts +112 -0
- package/src/helpers/buildForecastPaletteOptions.ts +71 -0
- package/src/helpers/getColorScale.ts +82 -8
- package/src/{hooks/useMinMax.ts → helpers/getMinMax.ts} +14 -7
- package/src/helpers/getNewRuntime.ts +1 -1
- package/src/helpers/getTransformedData.ts +1 -1
- package/src/helpers/getYAxisAutoPadding.ts +53 -0
- package/src/helpers/smallMultiplesHelpers.ts +529 -0
- package/src/hooks/useChartHoverAnalytics.tsx +44 -0
- package/src/hooks/useProgrammaticTooltip.ts +96 -0
- package/src/hooks/useReduceData.ts +105 -70
- package/src/hooks/useScales.ts +88 -34
- package/src/hooks/useSmallMultipleSynchronization.ts +59 -0
- package/src/hooks/useTooltip.tsx +116 -29
- package/src/index.jsx +0 -2
- package/src/scss/main.scss +13 -80
- package/src/store/chart.actions.ts +2 -0
- package/src/store/chart.reducer.ts +5 -1
- package/src/test/CdcChart.test.jsx +8 -3
- package/src/types/ChartConfig.ts +53 -11
- package/src/types/ChartContext.ts +4 -0
- package/vite.config.js +1 -1
- package/vitest.config.ts +16 -0
- package/src/_stories/_mock/pie_data.json +0 -218
- package/src/components/AreaChart/components/AreaChart.jsx +0 -109
- package/src/coreStyles_chart.scss +0 -3
- package/src/helpers/configHelpers.ts +0 -28
- package/src/helpers/generateColorsArray.ts +0 -8
- package/src/helpers/sort.ts +0 -7
- package/src/hooks/useActiveElement.js +0 -19
- package/src/hooks/useChartClasses.js +0 -41
- package/src/hooks/useColorPalette.js +0 -76
|
@@ -23,6 +23,9 @@ export type EditorPanelContext = {
|
|
|
23
23
|
isPaletteReversed?: boolean
|
|
24
24
|
handleRemoveHighlightedBar?: Function
|
|
25
25
|
setLollipopShape?: Function
|
|
26
|
+
handlePaletteSelection?: (palette: string) => void
|
|
27
|
+
handleTwoColorPaletteSelection?: (palette: string) => void
|
|
28
|
+
handleForecastPaletteSelection?: (palette: string, seriesIndex: number, stageIndex: number) => void
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
const EditorPanelContext = createContext<EditorPanelContext>(null)
|
|
@@ -4,6 +4,7 @@ import ConfigContext from '../../../../ConfigContext.js'
|
|
|
4
4
|
// CDC Core
|
|
5
5
|
import Accordion from '@cdc/core/components/ui/Accordion'
|
|
6
6
|
import Button from '@cdc/core/components/elements/Button'
|
|
7
|
+
import { CheckBox, Select } from '@cdc/core/components/EditorPanel/Inputs'
|
|
7
8
|
import _ from 'lodash'
|
|
8
9
|
|
|
9
10
|
// types
|
|
@@ -14,6 +15,29 @@ import './../panels.scss'
|
|
|
14
15
|
const PanelAnnotate: React.FC<PanelProps> = props => {
|
|
15
16
|
const { updateConfig, config, svgRef } = useContext(ConfigContext)
|
|
16
17
|
|
|
18
|
+
const updateField = (section, subsection, fieldName, value) => {
|
|
19
|
+
if (subsection) {
|
|
20
|
+
updateConfig({
|
|
21
|
+
...config,
|
|
22
|
+
[section]: {
|
|
23
|
+
...config[section],
|
|
24
|
+
[subsection]: {
|
|
25
|
+
...config[section][subsection],
|
|
26
|
+
[fieldName]: value
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
} else {
|
|
31
|
+
updateConfig({
|
|
32
|
+
...config,
|
|
33
|
+
[section]: {
|
|
34
|
+
...config[section],
|
|
35
|
+
[fieldName]: value
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
const handleAnnotationUpdate = (value, property, index) => {
|
|
18
42
|
const svgContainer = document.querySelector('.chart-container > svg')?.getBoundingClientRect()
|
|
19
43
|
const newSvgDims = [svgContainer?.width, svgContainer?.height]
|
|
@@ -67,8 +91,8 @@ const PanelAnnotate: React.FC<PanelProps> = props => {
|
|
|
67
91
|
config.xAxis.type === 'date'
|
|
68
92
|
? new Date(config?.data?.[0]?.[config.xAxis.dataKey]).getTime()
|
|
69
93
|
: config.xAxis.type === 'categorical'
|
|
70
|
-
|
|
71
|
-
|
|
94
|
+
? '1/15/2016'
|
|
95
|
+
: '',
|
|
72
96
|
yKey: '',
|
|
73
97
|
dx: 20,
|
|
74
98
|
dy: -20,
|
|
@@ -96,22 +120,14 @@ const PanelAnnotate: React.FC<PanelProps> = props => {
|
|
|
96
120
|
return (
|
|
97
121
|
<Accordion key={props.name}>
|
|
98
122
|
<Accordion.Section title={props.name} key={props.name}>
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
general: {
|
|
108
|
-
...config.general,
|
|
109
|
-
showAnnotationDropdown: e.target.checked
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
}}
|
|
113
|
-
/>
|
|
114
|
-
</label>
|
|
123
|
+
<CheckBox
|
|
124
|
+
value={config?.general?.showAnnotationDropdown || false}
|
|
125
|
+
section='general'
|
|
126
|
+
subsection={null}
|
|
127
|
+
fieldName='showAnnotationDropdown'
|
|
128
|
+
label='Show Annotation Dropdown'
|
|
129
|
+
updateField={updateField}
|
|
130
|
+
/>
|
|
115
131
|
|
|
116
132
|
{config.general.showAnnotationDropdown && (
|
|
117
133
|
<label key={`key-2`}>
|
|
@@ -164,61 +180,53 @@ const PanelAnnotate: React.FC<PanelProps> = props => {
|
|
|
164
180
|
/>
|
|
165
181
|
</label>
|
|
166
182
|
|
|
167
|
-
<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
<CheckBox
|
|
184
|
+
value={config?.annotations[index]?.edit?.subject || false}
|
|
185
|
+
section='annotations'
|
|
186
|
+
subsection={null}
|
|
187
|
+
fieldName={`${index}.edit.subject`}
|
|
188
|
+
label='Edit Subject'
|
|
189
|
+
updateField={(section, subsection, fieldName, value) => {
|
|
190
|
+
const updatedAnnotations = _.cloneDeep(config?.annotations)
|
|
191
|
+
updatedAnnotations[index].edit.subject = value
|
|
192
|
+
updateConfig({
|
|
193
|
+
...config,
|
|
194
|
+
annotations: updatedAnnotations
|
|
195
|
+
})
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
<CheckBox
|
|
199
|
+
value={config?.annotations[index]?.edit?.label || false}
|
|
200
|
+
section='annotations'
|
|
201
|
+
subsection={null}
|
|
202
|
+
fieldName={`${index}.edit.label`}
|
|
203
|
+
label='Edit Label'
|
|
204
|
+
updateField={(section, subsection, fieldName, value) => {
|
|
205
|
+
const updatedAnnotations = _.cloneDeep(config?.annotations)
|
|
206
|
+
updatedAnnotations[index].edit.label = value
|
|
207
|
+
updateConfig({
|
|
208
|
+
...config,
|
|
209
|
+
annotations: updatedAnnotations
|
|
210
|
+
})
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
197
213
|
|
|
198
|
-
<
|
|
199
|
-
Connection Type:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
</option>
|
|
215
|
-
{['curve', 'line', 'elbow', 'none'].map((side, index) => (
|
|
216
|
-
<option key={side} value={side}>
|
|
217
|
-
{side}
|
|
218
|
-
</option>
|
|
219
|
-
))}
|
|
220
|
-
</select>
|
|
221
|
-
</label>
|
|
214
|
+
<Select
|
|
215
|
+
label='Connection Type:'
|
|
216
|
+
value={config?.annotations[index]?.connectionType}
|
|
217
|
+
options={['Select', 'curve', 'line', 'elbow', 'none']}
|
|
218
|
+
section='annotations'
|
|
219
|
+
subsection={null}
|
|
220
|
+
fieldName='connectionType'
|
|
221
|
+
updateField={(section, subsection, fieldName, value) => {
|
|
222
|
+
const updatedAnnotations = _.cloneDeep(config?.annotations)
|
|
223
|
+
updatedAnnotations[index].connectionType = value
|
|
224
|
+
updateConfig({
|
|
225
|
+
...config,
|
|
226
|
+
annotations: updatedAnnotations
|
|
227
|
+
})
|
|
228
|
+
}}
|
|
229
|
+
/>
|
|
222
230
|
|
|
223
231
|
{annotation.connectionType === 'curve' && (
|
|
224
232
|
<>
|
|
@@ -243,45 +251,22 @@ const PanelAnnotate: React.FC<PanelProps> = props => {
|
|
|
243
251
|
</>
|
|
244
252
|
)}
|
|
245
253
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
))}
|
|
263
|
-
</select>
|
|
264
|
-
</label> */}
|
|
265
|
-
|
|
266
|
-
<label>
|
|
267
|
-
Marker
|
|
268
|
-
<select
|
|
269
|
-
key='annotation-marker'
|
|
270
|
-
value={annotation.marker}
|
|
271
|
-
onChange={e => {
|
|
272
|
-
const updatedAnnotations = _.cloneDeep(config?.annotations)
|
|
273
|
-
updatedAnnotations[index].marker = e.target.value
|
|
274
|
-
updateConfig({
|
|
275
|
-
...config,
|
|
276
|
-
annotations: updatedAnnotations
|
|
277
|
-
})
|
|
278
|
-
}}
|
|
279
|
-
>
|
|
280
|
-
{['arrow', 'circle'].map((column, columnIndex) => {
|
|
281
|
-
return <option key={`col-${columnIndex}`}>{column}</option>
|
|
282
|
-
})}
|
|
283
|
-
</select>
|
|
284
|
-
</label>
|
|
254
|
+
<Select
|
|
255
|
+
label='Marker'
|
|
256
|
+
value={annotation.marker}
|
|
257
|
+
options={['arrow', 'circle']}
|
|
258
|
+
section='annotations'
|
|
259
|
+
subsection={null}
|
|
260
|
+
fieldName='marker'
|
|
261
|
+
updateField={(section, subsection, fieldName, value) => {
|
|
262
|
+
const updatedAnnotations = _.cloneDeep(config?.annotations)
|
|
263
|
+
updatedAnnotations[index].marker = value
|
|
264
|
+
updateConfig({
|
|
265
|
+
...config,
|
|
266
|
+
annotations: updatedAnnotations
|
|
267
|
+
})
|
|
268
|
+
}}
|
|
269
|
+
/>
|
|
285
270
|
|
|
286
271
|
<Button className='btn btn-danger full-width' onClick={() => handleRemoveAnnotation(index)}>
|
|
287
272
|
Delete Annotation
|
|
@@ -21,7 +21,7 @@ import ConfigContext from '../../../../ConfigContext.js'
|
|
|
21
21
|
import { PanelProps } from '../PanelProps'
|
|
22
22
|
|
|
23
23
|
const PanelGeneral: FC<PanelProps> = props => {
|
|
24
|
-
const { config } = useContext(ConfigContext)
|
|
24
|
+
const { config, updateConfig } = useContext(ConfigContext)
|
|
25
25
|
const { updateField } = useEditorPanelContext()
|
|
26
26
|
const {
|
|
27
27
|
enabledChartTypes,
|
|
@@ -62,6 +62,24 @@ const PanelGeneral: FC<PanelProps> = props => {
|
|
|
62
62
|
label='Chart Type'
|
|
63
63
|
updateField={updateField}
|
|
64
64
|
options={enabledChartTypes}
|
|
65
|
+
onChange={event => {
|
|
66
|
+
const newVisType = event.target.value
|
|
67
|
+
|
|
68
|
+
updateField(null, null, 'visualizationType', newVisType)
|
|
69
|
+
|
|
70
|
+
if (newVisType === 'Forecasting' && config.xAxis.type === 'categorical') {
|
|
71
|
+
updateConfig({
|
|
72
|
+
...config,
|
|
73
|
+
visualizationType: newVisType,
|
|
74
|
+
xAxis: {
|
|
75
|
+
...config.xAxis,
|
|
76
|
+
type: 'date',
|
|
77
|
+
dateParseFormat: config.xAxis.dateParseFormat || '%Y-%m-%d',
|
|
78
|
+
dateDisplayFormat: config.xAxis.dateDisplayFormat || '%Y-%m-%d'
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
}}
|
|
65
83
|
/>
|
|
66
84
|
)}
|
|
67
85
|
{visSupportsChartHeight() && config.orientation === 'vertical' && (
|