@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,455 @@
|
|
|
1
|
+
{
|
|
2
|
+
"annotations": [],
|
|
3
|
+
"type": "chart",
|
|
4
|
+
"debugSvg": false,
|
|
5
|
+
"chartMessage": {
|
|
6
|
+
"noData": "No Data Available"
|
|
7
|
+
},
|
|
8
|
+
"title": "Example Bar Chart",
|
|
9
|
+
"showTitle": false,
|
|
10
|
+
"showDownloadMediaButton": false,
|
|
11
|
+
"theme": "theme-blue",
|
|
12
|
+
"animate": false,
|
|
13
|
+
"lineDatapointStyle": "hover",
|
|
14
|
+
"lineDatapointColor": "Same as Line",
|
|
15
|
+
"barHasBorder": "true",
|
|
16
|
+
"isLollipopChart": false,
|
|
17
|
+
"lollipopShape": "circle",
|
|
18
|
+
"lollipopColorStyle": "two-tone",
|
|
19
|
+
"visualizationSubType": "regular",
|
|
20
|
+
"barStyle": "",
|
|
21
|
+
"roundingStyle": "standard",
|
|
22
|
+
"tipRounding": "top",
|
|
23
|
+
"isResponsiveTicks": true,
|
|
24
|
+
"general": {
|
|
25
|
+
"annotationDropdownText": "Annotations",
|
|
26
|
+
"showMissingDataLabel": true,
|
|
27
|
+
"showSuppressedSymbol": true,
|
|
28
|
+
"showZeroValueData": true,
|
|
29
|
+
"hideNullValue": true,
|
|
30
|
+
"showZeroValueDataLabel": true,
|
|
31
|
+
"palette": {
|
|
32
|
+
"name": "divergent_blue_cyan",
|
|
33
|
+
"version": "2.0",
|
|
34
|
+
"backups": [
|
|
35
|
+
{
|
|
36
|
+
"name": "qualitative_bold",
|
|
37
|
+
"version": "1.0"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"padding": {
|
|
43
|
+
"left": 5,
|
|
44
|
+
"right": 5
|
|
45
|
+
},
|
|
46
|
+
"preliminaryData": [],
|
|
47
|
+
"yAxis": {
|
|
48
|
+
"hideAxis": false,
|
|
49
|
+
"displayNumbersOnBar": false,
|
|
50
|
+
"hideLabel": false,
|
|
51
|
+
"hideTicks": false,
|
|
52
|
+
"size": "118",
|
|
53
|
+
"gridLines": false,
|
|
54
|
+
"enablePadding": false,
|
|
55
|
+
"min": "",
|
|
56
|
+
"max": "400",
|
|
57
|
+
"labelColor": "#1c1d1f",
|
|
58
|
+
"tickLabelColor": "#1c1d1f",
|
|
59
|
+
"tickColor": "#1c1d1f",
|
|
60
|
+
"rightHideAxis": true,
|
|
61
|
+
"rightAxisSize": 50,
|
|
62
|
+
"rightLabel": "",
|
|
63
|
+
"rightLabelOffsetSize": 0,
|
|
64
|
+
"rightAxisLabelColor": "#1c1d1f",
|
|
65
|
+
"rightAxisTickLabelColor": "#1c1d1f",
|
|
66
|
+
"rightAxisTickColor": "#1c1d1f",
|
|
67
|
+
"numTicks": "",
|
|
68
|
+
"axisPadding": 0,
|
|
69
|
+
"scalePadding": 10,
|
|
70
|
+
"tickRotation": 0,
|
|
71
|
+
"anchors": [],
|
|
72
|
+
"shoMissingDataLabel": true,
|
|
73
|
+
"showMissingDataLine": true,
|
|
74
|
+
"categories": [],
|
|
75
|
+
"label": "Y Axis Example Label",
|
|
76
|
+
"maxValue": "400"
|
|
77
|
+
},
|
|
78
|
+
"boxplot": [],
|
|
79
|
+
"topAxis": {
|
|
80
|
+
"hasLine": false
|
|
81
|
+
},
|
|
82
|
+
"isLegendValue": false,
|
|
83
|
+
"barThickness": "0.6",
|
|
84
|
+
"barHeight": 25,
|
|
85
|
+
"barSpace": 15,
|
|
86
|
+
"heights": {
|
|
87
|
+
"vertical": "250",
|
|
88
|
+
"horizontal": 750
|
|
89
|
+
},
|
|
90
|
+
"xAxis": {
|
|
91
|
+
"sortDates": false,
|
|
92
|
+
"anchors": [],
|
|
93
|
+
"type": "categorical",
|
|
94
|
+
"showTargetLabel": true,
|
|
95
|
+
"targetLabel": "Target",
|
|
96
|
+
"hideAxis": false,
|
|
97
|
+
"hideLabel": false,
|
|
98
|
+
"hideTicks": false,
|
|
99
|
+
"size": "0",
|
|
100
|
+
"tickRotation": 0,
|
|
101
|
+
"min": "",
|
|
102
|
+
"max": "",
|
|
103
|
+
"labelColor": "#1c1d1f",
|
|
104
|
+
"tickLabelColor": "#1c1d1f",
|
|
105
|
+
"tickColor": "#1c1d1f",
|
|
106
|
+
"numTicks": "",
|
|
107
|
+
"labelOffset": 0,
|
|
108
|
+
"axisPadding": 0,
|
|
109
|
+
"target": 0,
|
|
110
|
+
"maxTickRotation": "45",
|
|
111
|
+
"padding": 5,
|
|
112
|
+
"showYearsOnce": false,
|
|
113
|
+
"sortByRecentDate": false,
|
|
114
|
+
"brushActive": false,
|
|
115
|
+
"dataKey": "Date",
|
|
116
|
+
"label": "X Axis Example Label",
|
|
117
|
+
"tickWidthMax": 77,
|
|
118
|
+
"axisBBox": 110.040283203125
|
|
119
|
+
},
|
|
120
|
+
"table": {
|
|
121
|
+
"label": "Data Type by Date",
|
|
122
|
+
"expanded": false,
|
|
123
|
+
"limitHeight": false,
|
|
124
|
+
"height": "",
|
|
125
|
+
"caption": "",
|
|
126
|
+
"showDownloadUrl": false,
|
|
127
|
+
"showDataTableLink": true,
|
|
128
|
+
"showDownloadLinkBelow": true,
|
|
129
|
+
"indexLabel": "Date",
|
|
130
|
+
"download": true,
|
|
131
|
+
"showVertical": true,
|
|
132
|
+
"dateDisplayFormat": "",
|
|
133
|
+
"showMissingDataLabel": true,
|
|
134
|
+
"showSuppressedSymbol": true,
|
|
135
|
+
"collapsible": true,
|
|
136
|
+
"show": true
|
|
137
|
+
},
|
|
138
|
+
"orientation": "vertical",
|
|
139
|
+
"columns": {},
|
|
140
|
+
"legend": {
|
|
141
|
+
"hide": false,
|
|
142
|
+
"behavior": "isolate",
|
|
143
|
+
"axisAlign": true,
|
|
144
|
+
"singleRow": true,
|
|
145
|
+
"colorCode": "",
|
|
146
|
+
"reverseLabelOrder": false,
|
|
147
|
+
"description": "",
|
|
148
|
+
"dynamicLegend": false,
|
|
149
|
+
"dynamicLegendDefaultText": "Show All",
|
|
150
|
+
"dynamicLegendItemLimit": 5,
|
|
151
|
+
"dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
|
|
152
|
+
"dynamicLegendChartMessage": "Select Options from the Legend",
|
|
153
|
+
"label": "Type of Data",
|
|
154
|
+
"lineMode": false,
|
|
155
|
+
"verticalSorted": false,
|
|
156
|
+
"highlightOnHover": false,
|
|
157
|
+
"hideSuppressedLabels": false,
|
|
158
|
+
"hideSuppressionLink": false,
|
|
159
|
+
"seriesHighlight": [],
|
|
160
|
+
"style": "circles",
|
|
161
|
+
"subStyle": "linear blocks",
|
|
162
|
+
"groupBy": "",
|
|
163
|
+
"shape": "circle",
|
|
164
|
+
"tickRotation": "",
|
|
165
|
+
"order": "dataColumn",
|
|
166
|
+
"hideBorder": {
|
|
167
|
+
"side": false,
|
|
168
|
+
"topBottom": true
|
|
169
|
+
},
|
|
170
|
+
"position": "right",
|
|
171
|
+
"orderedValues": [],
|
|
172
|
+
"patterns": {},
|
|
173
|
+
"patternField": "",
|
|
174
|
+
"unified": true
|
|
175
|
+
},
|
|
176
|
+
"exclusions": {
|
|
177
|
+
"active": false,
|
|
178
|
+
"keys": []
|
|
179
|
+
},
|
|
180
|
+
"twoColor": {
|
|
181
|
+
"palette": "monochrome-1",
|
|
182
|
+
"isPaletteReversed": false
|
|
183
|
+
},
|
|
184
|
+
"labels": false,
|
|
185
|
+
"dataFormat": {
|
|
186
|
+
"commas": false,
|
|
187
|
+
"prefix": "",
|
|
188
|
+
"suffix": " units",
|
|
189
|
+
"abbreviated": false,
|
|
190
|
+
"bottomSuffix": "",
|
|
191
|
+
"bottomPrefix": "",
|
|
192
|
+
"bottomAbbreviated": false,
|
|
193
|
+
"useCommas": false,
|
|
194
|
+
"roundToPlace": ""
|
|
195
|
+
},
|
|
196
|
+
"filters": [],
|
|
197
|
+
"confidenceKeys": {},
|
|
198
|
+
"visual": {
|
|
199
|
+
"border": true,
|
|
200
|
+
"accent": true,
|
|
201
|
+
"background": true,
|
|
202
|
+
"verticalHoverLine": false,
|
|
203
|
+
"horizontalHoverLine": false,
|
|
204
|
+
"lineDatapointSymbol": "none",
|
|
205
|
+
"maximumShapeAmount": 7
|
|
206
|
+
},
|
|
207
|
+
"useLogScale": false,
|
|
208
|
+
"filterBehavior": "Filter Change",
|
|
209
|
+
"highlightedBarValues": [],
|
|
210
|
+
"series": [
|
|
211
|
+
{
|
|
212
|
+
"dataKey": "Data 1",
|
|
213
|
+
"type": "Bar",
|
|
214
|
+
"tooltip": true,
|
|
215
|
+
"axis": "Left"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"dataKey": "Data 2",
|
|
219
|
+
"type": "Bar",
|
|
220
|
+
"tooltip": true,
|
|
221
|
+
"axis": "Left"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"dataKey": "Data 3",
|
|
225
|
+
"type": "Bar",
|
|
226
|
+
"tooltip": true,
|
|
227
|
+
"axis": "Left"
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"tooltips": {
|
|
231
|
+
"opacity": 90,
|
|
232
|
+
"singleSeries": false,
|
|
233
|
+
"dateDisplayFormat": ""
|
|
234
|
+
},
|
|
235
|
+
"forestPlot": {
|
|
236
|
+
"startAt": 0,
|
|
237
|
+
"colors": {
|
|
238
|
+
"line": "",
|
|
239
|
+
"shape": ""
|
|
240
|
+
},
|
|
241
|
+
"lineOfNoEffect": {
|
|
242
|
+
"show": true
|
|
243
|
+
},
|
|
244
|
+
"type": "",
|
|
245
|
+
"pooledResult": {
|
|
246
|
+
"diamondHeight": 5,
|
|
247
|
+
"column": ""
|
|
248
|
+
},
|
|
249
|
+
"estimateField": "",
|
|
250
|
+
"estimateRadius": "",
|
|
251
|
+
"shape": "square",
|
|
252
|
+
"rowHeight": 20,
|
|
253
|
+
"description": {
|
|
254
|
+
"show": true,
|
|
255
|
+
"text": "description",
|
|
256
|
+
"location": 0
|
|
257
|
+
},
|
|
258
|
+
"result": {
|
|
259
|
+
"show": true,
|
|
260
|
+
"text": "result",
|
|
261
|
+
"location": 100
|
|
262
|
+
},
|
|
263
|
+
"radius": {
|
|
264
|
+
"min": 2,
|
|
265
|
+
"max": 10,
|
|
266
|
+
"scalingColumn": ""
|
|
267
|
+
},
|
|
268
|
+
"regression": {
|
|
269
|
+
"lower": 0,
|
|
270
|
+
"upper": 0,
|
|
271
|
+
"estimateField": 0
|
|
272
|
+
},
|
|
273
|
+
"leftWidthOffset": 0,
|
|
274
|
+
"rightWidthOffset": 0,
|
|
275
|
+
"showZeroLine": false,
|
|
276
|
+
"leftLabel": "",
|
|
277
|
+
"rightLabel": ""
|
|
278
|
+
},
|
|
279
|
+
"area": {
|
|
280
|
+
"isStacked": false
|
|
281
|
+
},
|
|
282
|
+
"sankey": {
|
|
283
|
+
"title": {
|
|
284
|
+
"defaultColor": "black"
|
|
285
|
+
},
|
|
286
|
+
"iterations": 1,
|
|
287
|
+
"rxValue": 0.9,
|
|
288
|
+
"overallSize": {
|
|
289
|
+
"width": 900,
|
|
290
|
+
"height": 700
|
|
291
|
+
},
|
|
292
|
+
"margin": {
|
|
293
|
+
"margin_y": 25,
|
|
294
|
+
"margin_x": 0
|
|
295
|
+
},
|
|
296
|
+
"nodeSize": {
|
|
297
|
+
"nodeWidth": 26,
|
|
298
|
+
"nodeHeight": 40
|
|
299
|
+
},
|
|
300
|
+
"nodePadding": 55,
|
|
301
|
+
"nodeFontColor": "black",
|
|
302
|
+
"nodeColor": {
|
|
303
|
+
"default": "#ff8500",
|
|
304
|
+
"inactive": "#808080"
|
|
305
|
+
},
|
|
306
|
+
"linkColor": {
|
|
307
|
+
"default": "#ffc900",
|
|
308
|
+
"inactive": "#D3D3D3"
|
|
309
|
+
},
|
|
310
|
+
"opacity": {
|
|
311
|
+
"nodeOpacityDefault": 1,
|
|
312
|
+
"nodeOpacityInactive": 0.1,
|
|
313
|
+
"LinkOpacityDefault": 1,
|
|
314
|
+
"LinkOpacityInactive": 0.1
|
|
315
|
+
},
|
|
316
|
+
"storyNodeFontColor": "#006778",
|
|
317
|
+
"storyNodeText": [],
|
|
318
|
+
"nodeValueStyle": {
|
|
319
|
+
"textBefore": "(",
|
|
320
|
+
"textAfter": ")"
|
|
321
|
+
},
|
|
322
|
+
"data": []
|
|
323
|
+
},
|
|
324
|
+
"markupVariables": [],
|
|
325
|
+
"enableMarkupVariables": false,
|
|
326
|
+
"fontSize": "medium",
|
|
327
|
+
"brush": {
|
|
328
|
+
"height": 25,
|
|
329
|
+
"active": false,
|
|
330
|
+
"data": [
|
|
331
|
+
{
|
|
332
|
+
"Date": "1/15/2016",
|
|
333
|
+
"Data 1": "90",
|
|
334
|
+
"Data 2": "135",
|
|
335
|
+
"Data 3": "300",
|
|
336
|
+
"Data 4": "95",
|
|
337
|
+
"Data 5": "120",
|
|
338
|
+
"Data 6": "310"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"Date": "2/15/2016",
|
|
342
|
+
"Data 1": "40",
|
|
343
|
+
"Data 2": "90",
|
|
344
|
+
"Data 3": "240",
|
|
345
|
+
"Data 4": "60",
|
|
346
|
+
"Data 5": "160",
|
|
347
|
+
"Data 6": "200"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"Date": "3/15/2016",
|
|
351
|
+
"Data 1": "50",
|
|
352
|
+
"Data 2": "300",
|
|
353
|
+
"Data 3": "290",
|
|
354
|
+
"Data 4": "100",
|
|
355
|
+
"Data 5": "200",
|
|
356
|
+
"Data 6": "250"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"Date": "4/15/2016",
|
|
360
|
+
"Data 1": "120",
|
|
361
|
+
"Data 2": "160",
|
|
362
|
+
"Data 3": "230",
|
|
363
|
+
"Data 4": "180",
|
|
364
|
+
"Data 5": "160",
|
|
365
|
+
"Data 6": "220"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"Date": "5/15/2016",
|
|
369
|
+
"Data 1": "80",
|
|
370
|
+
"Data 2": "350",
|
|
371
|
+
"Data 3": "300",
|
|
372
|
+
"Data 4": "150",
|
|
373
|
+
"Data 5": "130",
|
|
374
|
+
"Data 6": "100"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"Date": "6/15/2016",
|
|
378
|
+
"Data 1": "90",
|
|
379
|
+
"Data 2": "220",
|
|
380
|
+
"Data 3": "320",
|
|
381
|
+
"Data 4": "100",
|
|
382
|
+
"Data 5": "220",
|
|
383
|
+
"Data 6": "300"
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
},
|
|
387
|
+
"isPaletteReversed": false,
|
|
388
|
+
"suppressedData": [],
|
|
389
|
+
"height": 300,
|
|
390
|
+
"visualizationType": "Bar",
|
|
391
|
+
"description": "",
|
|
392
|
+
"dataCutoff": "0",
|
|
393
|
+
"validated": 4.23,
|
|
394
|
+
"dynamicMarginTop": 105,
|
|
395
|
+
"version": "4.25.10",
|
|
396
|
+
"migrations": {
|
|
397
|
+
"addColorMigration": true
|
|
398
|
+
},
|
|
399
|
+
"data": [
|
|
400
|
+
{
|
|
401
|
+
"Date": "1/15/2016",
|
|
402
|
+
"Data 1": "90",
|
|
403
|
+
"Data 2": "135",
|
|
404
|
+
"Data 3": "300",
|
|
405
|
+
"Data 4": "95",
|
|
406
|
+
"Data 5": "120",
|
|
407
|
+
"Data 6": "310"
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
"Date": "2/15/2016",
|
|
411
|
+
"Data 1": "40",
|
|
412
|
+
"Data 2": "90",
|
|
413
|
+
"Data 3": "240",
|
|
414
|
+
"Data 4": "60",
|
|
415
|
+
"Data 5": "160",
|
|
416
|
+
"Data 6": "200"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"Date": "3/15/2016",
|
|
420
|
+
"Data 1": "50",
|
|
421
|
+
"Data 2": "300",
|
|
422
|
+
"Data 3": "290",
|
|
423
|
+
"Data 4": "100",
|
|
424
|
+
"Data 5": "200",
|
|
425
|
+
"Data 6": "250"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
"Date": "4/15/2016",
|
|
429
|
+
"Data 1": "120",
|
|
430
|
+
"Data 2": "160",
|
|
431
|
+
"Data 3": "230",
|
|
432
|
+
"Data 4": "180",
|
|
433
|
+
"Data 5": "160",
|
|
434
|
+
"Data 6": "220"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"Date": "5/15/2016",
|
|
438
|
+
"Data 1": "80",
|
|
439
|
+
"Data 2": "350",
|
|
440
|
+
"Data 3": "300",
|
|
441
|
+
"Data 4": "150",
|
|
442
|
+
"Data 5": "130",
|
|
443
|
+
"Data 6": "100"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"Date": "6/15/2016",
|
|
447
|
+
"Data 1": "90",
|
|
448
|
+
"Data 2": "220",
|
|
449
|
+
"Data 3": "320",
|
|
450
|
+
"Data 4": "100",
|
|
451
|
+
"Data 5": "220",
|
|
452
|
+
"Data 6": "300"
|
|
453
|
+
}
|
|
454
|
+
]
|
|
455
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/chart",
|
|
3
|
-
"version": "4.26.
|
|
3
|
+
"version": "4.26.6",
|
|
4
4
|
"description": "React component for visualizing tabular data in various types of charts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Matthew Pallansch <mpallansch@adittech.com>",
|
|
7
7
|
"bugs": "https://github.com/CDCgov/cdc-open-viz/issues",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@cdc/core": "^4.26.
|
|
9
|
+
"@cdc/core": "^4.26.6",
|
|
10
10
|
"@hello-pangea/dnd": "^16.2.0",
|
|
11
11
|
"@react-spring/web": "^9.7.5",
|
|
12
12
|
"@rollup/plugin-dsv": "^3.0.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/d3-sankey": "^0.12.4",
|
|
58
58
|
"@types/d3-time-format": "^4.0.3"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "f4a2a0d4a631a1b60fcf9534589697780e480b58",
|
|
61
61
|
"main": "dist/cdcchart",
|
|
62
62
|
"moduleName": "CdcChart",
|
|
63
63
|
"peerDependencies": {
|
package/src/CdcChart.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { ChartConfig } from './types/ChartConfig'
|
|
|
4
4
|
import { getFileExtension } from '@cdc/core/helpers/getFileExtension'
|
|
5
5
|
import { isSolrCsv, isSolrJson } from '@cdc/core/helpers/isSolr'
|
|
6
6
|
import { parseCsvWithQuotes } from '@cdc/core/helpers/parseCsvWithQuotes'
|
|
7
|
-
import
|
|
7
|
+
import { addCsvCacheBuster } from '@cdc/core/helpers/csvCacheBuster'
|
|
8
8
|
import { extractDataAndMetadata } from '@cdc/core/helpers/extractDataAndMetadata'
|
|
9
9
|
import Loading from '@cdc/core/components/Loading'
|
|
10
10
|
import _ from 'lodash'
|
|
@@ -112,11 +112,12 @@ const parseCsv = (responseText: string, delimiter = '|') => {
|
|
|
112
112
|
|
|
113
113
|
const fetchAndParseData = async (url: string, ext: string) => {
|
|
114
114
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
if (ext?.toLowerCase() === 'csv' || isSolrCsv(url)) {
|
|
116
|
+
const response = await fetch(addCsvCacheBuster(url))
|
|
117
117
|
const responseText = await response.text()
|
|
118
118
|
return { data: parseCsv(responseText), dataMetadata: {} }
|
|
119
|
-
} else if (ext === 'json' || isSolrJson(url)) {
|
|
119
|
+
} else if (ext?.toLowerCase() === 'json' || isSolrJson(url)) {
|
|
120
|
+
const response = await fetch(url)
|
|
120
121
|
const json = await response.json()
|
|
121
122
|
return extractDataAndMetadata(json)
|
|
122
123
|
}
|
|
@@ -246,6 +246,10 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
246
246
|
const processedIntroText = processedTextFields.introText
|
|
247
247
|
const processedLegacyFootnotes = processedTextFields.legacyFootnotes
|
|
248
248
|
const processedDescription = processedTextFields.description
|
|
249
|
+
const chartDataTableIsRendered =
|
|
250
|
+
Boolean(config.table?.show) &&
|
|
251
|
+
config.visualizationType !== 'Spark Line' &&
|
|
252
|
+
((Boolean(config.xAxis?.dataKey) && config.visualizationType !== 'Sankey') || config.visualizationType === 'Sankey')
|
|
249
253
|
// Note: Axis labels are processed within updateConfig to ensure they use the correct data
|
|
250
254
|
|
|
251
255
|
// set defaults on titles if blank AND only in editor
|
|
@@ -480,7 +484,9 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
480
484
|
lineType: series.lineType,
|
|
481
485
|
originalDataKey: series.dataKey,
|
|
482
486
|
dynamicCategory: series.dynamicCategory,
|
|
483
|
-
tooltip: true
|
|
487
|
+
tooltip: true,
|
|
488
|
+
weight: series.weight,
|
|
489
|
+
axis: series.axis
|
|
484
490
|
})
|
|
485
491
|
})
|
|
486
492
|
// return the series keys
|
|
@@ -565,7 +571,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
565
571
|
...newConfig.legend,
|
|
566
572
|
position: newConfig.legend?.position || 'top',
|
|
567
573
|
style: newConfig.legend?.style || 'gradient',
|
|
568
|
-
subStyle:
|
|
574
|
+
subStyle:
|
|
575
|
+
newConfig.legend?.subStyle === 'smooth' ? 'linear blocks' : newConfig.legend?.subStyle || 'linear blocks'
|
|
569
576
|
}
|
|
570
577
|
newConfig.yAxis = {
|
|
571
578
|
...newConfig.yAxis,
|
|
@@ -769,6 +776,16 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
769
776
|
return newConfig
|
|
770
777
|
}
|
|
771
778
|
|
|
779
|
+
const configDataDependency = configObj?.data?.length ? configObj.data : null
|
|
780
|
+
const configExclusionsDependency = [
|
|
781
|
+
configObj?.xAxis?.type,
|
|
782
|
+
configObj?.xAxis?.dataKey,
|
|
783
|
+
configObj?.exclusions?.active,
|
|
784
|
+
configObj?.exclusions?.dateStart,
|
|
785
|
+
configObj?.exclusions?.dateEnd,
|
|
786
|
+
...(configObj?.exclusions?.keys || [])
|
|
787
|
+
].join('|')
|
|
788
|
+
|
|
772
789
|
useEffect(() => {
|
|
773
790
|
const load = async () => {
|
|
774
791
|
try {
|
|
@@ -790,7 +807,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
790
807
|
}
|
|
791
808
|
|
|
792
809
|
load()
|
|
793
|
-
}, [
|
|
810
|
+
}, [configDataDependency, configExclusionsDependency])
|
|
794
811
|
|
|
795
812
|
/**
|
|
796
813
|
* When cove has a config and container ref publish the cove_loaded event.
|
|
@@ -1255,6 +1272,14 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1255
1272
|
|
|
1256
1273
|
// Transform and clean data for chart rendering
|
|
1257
1274
|
const transformedData = getTransformedData({ brushData: state.brushData, filteredData, excludedData, clean })
|
|
1275
|
+
const configYAxisDomainData = (config as ChartConfig).yAxisDomainData
|
|
1276
|
+
const yAxisDomainData = useMemo(() => {
|
|
1277
|
+
if (Array.isArray(configYAxisDomainData) && configYAxisDomainData.length > 0) {
|
|
1278
|
+
return clean(getExcludedData(config, configYAxisDomainData))
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
return clean(excludedData)
|
|
1282
|
+
}, [config, configYAxisDomainData, excludedData])
|
|
1258
1283
|
|
|
1259
1284
|
// Filter annotations to only those visible in current data view
|
|
1260
1285
|
const visibleAnnotations = getVisibleAnnotations(config.annotations, transformedData, config.xAxis?.dataKey)
|
|
@@ -1403,11 +1428,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1403
1428
|
{isDashboard && config.table && config.table.show && config.table.showDataTableLink
|
|
1404
1429
|
? tableLink
|
|
1405
1430
|
: link && link}
|
|
1406
|
-
{
|
|
1407
|
-
config.table.show &&
|
|
1408
|
-
config.visualizationType !== 'Spark Line' &&
|
|
1409
|
-
config.visualizationType !== 'Sankey') ||
|
|
1410
|
-
(config.visualizationType === 'Sankey' && config.table.show)
|
|
1431
|
+
{chartDataTableIsRendered
|
|
1411
1432
|
? (() => {
|
|
1412
1433
|
let dataTableConfig = pivotDynamicSeries(config)
|
|
1413
1434
|
let dataTableColumns = config.columns
|
|
@@ -1433,6 +1454,7 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1433
1454
|
<DataTable
|
|
1434
1455
|
key={config.table?.defaultSort?.column || ''}
|
|
1435
1456
|
config={dataTableConfig}
|
|
1457
|
+
dataConfig={config.dataKey ? datasets?.[config.dataKey] : undefined}
|
|
1436
1458
|
rawData={dataTableRawData}
|
|
1437
1459
|
runtimeData={dataTableRuntimeData}
|
|
1438
1460
|
expandDataTable={config.table.expanded}
|
|
@@ -1706,7 +1728,8 @@ const CdcChart: React.FC<CdcChartProps> = ({
|
|
|
1706
1728
|
twoColorPalette,
|
|
1707
1729
|
unfilteredData: stateData,
|
|
1708
1730
|
updateConfig,
|
|
1709
|
-
visibleAnnotations
|
|
1731
|
+
visibleAnnotations,
|
|
1732
|
+
yAxisDomainData
|
|
1710
1733
|
}
|
|
1711
1734
|
|
|
1712
1735
|
return (
|