@cdc/chart 4.25.5-1 → 4.25.6-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/LICENSE +201 -0
- package/dist/cdcchart.js +31118 -27459
- package/examples/private/0527.json +1 -0
- package/examples/private/DEV-8850-2.json +493 -0
- package/examples/private/DEV-9822.json +574 -0
- package/examples/private/DEV-9840.json +553 -0
- package/examples/private/DEV-9850-3.json +461 -0
- package/examples/private/chart.json +1084 -0
- package/examples/private/ci_formatted.json +202 -0
- package/examples/private/ci_issue.json +3016 -0
- package/examples/private/completed.json +634 -0
- package/examples/private/dem-data-long.csv +20 -0
- package/examples/private/dem-data-long.json +36 -0
- package/examples/private/demographic_data.csv +157 -0
- package/examples/private/demographic_data.json +2654 -0
- package/examples/private/demographic_dynamic.json +443 -0
- package/examples/private/demographic_standard.json +560 -0
- package/examples/private/ehdi.json +29939 -0
- package/examples/private/line-issue.json +497 -0
- package/examples/private/not-loading.json +360 -0
- package/examples/private/test.json +493 -0
- package/examples/private/testing-pie.json +436 -0
- package/index.html +130 -130
- package/package.json +2 -2
- package/src/CdcChartComponent.tsx +66 -26
- package/src/_stories/Chart.stories.tsx +99 -93
- package/src/_stories/ChartPrefixSuffix.stories.tsx +29 -32
- package/src/_stories/_mock/pie_calculated_area.json +417 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +4 -13
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +3 -14
- package/src/components/BarChart/components/BarChart.Vertical.tsx +2 -8
- package/src/components/Brush/BrushChart.tsx +73 -0
- package/src/components/Brush/BrushController..tsx +39 -0
- package/src/components/DeviationBar.jsx +0 -1
- package/src/components/EditorPanel/EditorPanel.tsx +246 -156
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +2 -2
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +3 -2
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +2 -1
- package/src/components/EditorPanel/components/Panels/panelVisual.styles.css +8 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +7 -4
- package/src/components/HoverLine/HoverLine.tsx +74 -0
- package/src/components/Legend/Legend.Suppression.tsx +47 -3
- package/src/components/Legend/helpers/index.ts +1 -1
- package/src/components/LineChart/helpers.ts +7 -7
- package/src/components/LineChart/index.tsx +3 -6
- package/src/components/LinearChart.tsx +108 -72
- package/src/components/PieChart/PieChart.tsx +58 -13
- package/src/data/initial-state.js +8 -5
- package/src/helpers/countNumOfTicks.ts +4 -19
- package/src/helpers/getNewRuntime.ts +35 -0
- package/src/helpers/getPiePercent.ts +22 -0
- package/src/helpers/getTransformedData.ts +22 -0
- package/src/helpers/tests/getNewRuntime.test.ts +82 -0
- package/src/helpers/tests/getPiePercent.test.ts +38 -0
- package/src/hooks/useRightAxis.ts +1 -1
- package/src/hooks/useScales.ts +8 -3
- package/src/hooks/useTooltip.tsx +24 -10
- package/src/scss/main.scss +8 -4
- package/src/store/chart.actions.ts +2 -6
- package/src/store/chart.reducer.ts +23 -23
- package/src/types/ChartConfig.ts +7 -4
- package/src/types/ChartContext.ts +0 -2
- package/src/components/ZoomBrush.tsx +0 -251
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
{
|
|
2
|
+
"annotations": [],
|
|
3
|
+
"type": "chart",
|
|
4
|
+
"debugSvg": false,
|
|
5
|
+
"chartMessage": {
|
|
6
|
+
"noData": "No Data Available"
|
|
7
|
+
},
|
|
8
|
+
"title": "",
|
|
9
|
+
"showTitle": false,
|
|
10
|
+
"showDownloadMediaButton": false,
|
|
11
|
+
"theme": "theme-blue",
|
|
12
|
+
"animate": false,
|
|
13
|
+
"fontSize": "medium",
|
|
14
|
+
"lineDatapointStyle": "hover",
|
|
15
|
+
"lineDatapointColor": "Same as Line",
|
|
16
|
+
"barHasBorder": "false",
|
|
17
|
+
"isLollipopChart": false,
|
|
18
|
+
"lollipopShape": "circle",
|
|
19
|
+
"lollipopColorStyle": "two-tone",
|
|
20
|
+
"visualizationSubType": "regular",
|
|
21
|
+
"barStyle": "flat",
|
|
22
|
+
"roundingStyle": "standard",
|
|
23
|
+
"tipRounding": "top",
|
|
24
|
+
"isResponsiveTicks": true,
|
|
25
|
+
"general": {
|
|
26
|
+
"annotationDropdownText": "Annotations",
|
|
27
|
+
"showMissingDataLabel": false,
|
|
28
|
+
"showSuppressedSymbol": true,
|
|
29
|
+
"showZeroValueData": false,
|
|
30
|
+
"hideNullValue": true
|
|
31
|
+
},
|
|
32
|
+
"padding": {
|
|
33
|
+
"left": 5,
|
|
34
|
+
"right": 5
|
|
35
|
+
},
|
|
36
|
+
"preliminaryData": [],
|
|
37
|
+
"yAxis": {
|
|
38
|
+
"hideAxis": false,
|
|
39
|
+
"displayNumbersOnBar": false,
|
|
40
|
+
"hideLabel": false,
|
|
41
|
+
"hideTicks": false,
|
|
42
|
+
"size": "75",
|
|
43
|
+
"gridLines": false,
|
|
44
|
+
"enablePadding": false,
|
|
45
|
+
"min": "0.1",
|
|
46
|
+
"max": "3",
|
|
47
|
+
"labelColor": "#333",
|
|
48
|
+
"tickLabelColor": "#333",
|
|
49
|
+
"tickColor": "#333",
|
|
50
|
+
"rightHideAxis": true,
|
|
51
|
+
"rightAxisSize": 0,
|
|
52
|
+
"rightLabel": "",
|
|
53
|
+
"rightLabelOffsetSize": 0,
|
|
54
|
+
"rightAxisLabelColor": "#333",
|
|
55
|
+
"rightAxisTickLabelColor": "#333",
|
|
56
|
+
"rightAxisTickColor": "#333",
|
|
57
|
+
"numTicks": "6",
|
|
58
|
+
"axisPadding": 0,
|
|
59
|
+
"scalePadding": 10,
|
|
60
|
+
"tickRotation": 0,
|
|
61
|
+
"anchors": [],
|
|
62
|
+
"shoMissingDataLabel": true,
|
|
63
|
+
"showMissingDataLine": true,
|
|
64
|
+
"categories": [],
|
|
65
|
+
"label": "Reported cases per 100,000 Population",
|
|
66
|
+
"type": "linear",
|
|
67
|
+
"dataKey": "Hispanic"
|
|
68
|
+
},
|
|
69
|
+
"boxplot": {
|
|
70
|
+
"plots": [],
|
|
71
|
+
"borders": "true",
|
|
72
|
+
"plotOutlierValues": false,
|
|
73
|
+
"plotNonOutlierValues": true,
|
|
74
|
+
"labels": {
|
|
75
|
+
"q1": "Lower Quartile",
|
|
76
|
+
"q2": "q2",
|
|
77
|
+
"q3": "Upper Quartile",
|
|
78
|
+
"q4": "q4",
|
|
79
|
+
"minimum": "Minimum",
|
|
80
|
+
"maximum": "Maximum",
|
|
81
|
+
"mean": "Mean",
|
|
82
|
+
"median": "Median",
|
|
83
|
+
"sd": "Standard Deviation",
|
|
84
|
+
"iqr": "Interquartile Range",
|
|
85
|
+
"count": "Count",
|
|
86
|
+
"outliers": "Outliers",
|
|
87
|
+
"values": "Values",
|
|
88
|
+
"lowerBounds": "Lower Bounds",
|
|
89
|
+
"upperBounds": "Upper Bounds"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"topAxis": {
|
|
93
|
+
"hasLine": false
|
|
94
|
+
},
|
|
95
|
+
"isLegendValue": false,
|
|
96
|
+
"barThickness": 0.35,
|
|
97
|
+
"barHeight": 25,
|
|
98
|
+
"barSpace": 15,
|
|
99
|
+
"heights": {
|
|
100
|
+
"vertical": 300,
|
|
101
|
+
"horizontal": 750
|
|
102
|
+
},
|
|
103
|
+
"xAxis": {
|
|
104
|
+
"sortDates": false,
|
|
105
|
+
"anchors": [],
|
|
106
|
+
"type": "categorical",
|
|
107
|
+
"showTargetLabel": true,
|
|
108
|
+
"targetLabel": "Target",
|
|
109
|
+
"hideAxis": false,
|
|
110
|
+
"hideLabel": false,
|
|
111
|
+
"hideTicks": false,
|
|
112
|
+
"size": 75,
|
|
113
|
+
"tickRotation": 0,
|
|
114
|
+
"min": "",
|
|
115
|
+
"max": "",
|
|
116
|
+
"labelColor": "#333",
|
|
117
|
+
"tickLabelColor": "#333",
|
|
118
|
+
"tickColor": "#333",
|
|
119
|
+
"numTicks": "",
|
|
120
|
+
"labelOffset": 0,
|
|
121
|
+
"axisPadding": 200,
|
|
122
|
+
"target": 0,
|
|
123
|
+
"maxTickRotation": 0,
|
|
124
|
+
"padding": 5,
|
|
125
|
+
"showYearsOnce": false,
|
|
126
|
+
"sortByRecentDate": false,
|
|
127
|
+
"dataKey": "Year",
|
|
128
|
+
"label": "Year",
|
|
129
|
+
"manual": true,
|
|
130
|
+
"axisBBox": 63.41333770751953,
|
|
131
|
+
"tickWidthMax": 39
|
|
132
|
+
},
|
|
133
|
+
"table": {
|
|
134
|
+
"label": "Data Table",
|
|
135
|
+
"expanded": true,
|
|
136
|
+
"limitHeight": false,
|
|
137
|
+
"height": "",
|
|
138
|
+
"caption": "",
|
|
139
|
+
"showDownloadUrl": false,
|
|
140
|
+
"showDataTableLink": true,
|
|
141
|
+
"showDownloadLinkBelow": true,
|
|
142
|
+
"indexLabel": "",
|
|
143
|
+
"download": true,
|
|
144
|
+
"showVertical": false,
|
|
145
|
+
"dateDisplayFormat": "",
|
|
146
|
+
"showMissingDataLabel": true,
|
|
147
|
+
"showSuppressedSymbol": true,
|
|
148
|
+
"show": true
|
|
149
|
+
},
|
|
150
|
+
"orientation": "vertical",
|
|
151
|
+
"color": "pinkpurple",
|
|
152
|
+
"columns": {},
|
|
153
|
+
"legend": {
|
|
154
|
+
"hide": false,
|
|
155
|
+
"behavior": "isolate",
|
|
156
|
+
"axisAlign": true,
|
|
157
|
+
"singleRow": true,
|
|
158
|
+
"colorCode": "",
|
|
159
|
+
"reverseLabelOrder": false,
|
|
160
|
+
"description": "",
|
|
161
|
+
"dynamicLegend": false,
|
|
162
|
+
"dynamicLegendDefaultText": "Show All",
|
|
163
|
+
"dynamicLegendItemLimit": 5,
|
|
164
|
+
"dynamicLegendItemLimitMessage": "Dynamic Legend Item Limit Hit.",
|
|
165
|
+
"dynamicLegendChartMessage": "Select Options from the Legend",
|
|
166
|
+
"label": "",
|
|
167
|
+
"lineMode": false,
|
|
168
|
+
"verticalSorted": false,
|
|
169
|
+
"highlightOnHover": false,
|
|
170
|
+
"hideSuppressedLabels": false,
|
|
171
|
+
"hideSuppressionLink": false,
|
|
172
|
+
"seriesHighlight": [],
|
|
173
|
+
"style": "boxes",
|
|
174
|
+
"subStyle": "linear blocks",
|
|
175
|
+
"groupBy": "",
|
|
176
|
+
"shape": "circle",
|
|
177
|
+
"tickRotation": "",
|
|
178
|
+
"order": "dataColumn",
|
|
179
|
+
"hideBorder": {
|
|
180
|
+
"side": false,
|
|
181
|
+
"topBottom": true
|
|
182
|
+
},
|
|
183
|
+
"position": "right",
|
|
184
|
+
"orderedValues": [],
|
|
185
|
+
"unified": true
|
|
186
|
+
},
|
|
187
|
+
"brush": {
|
|
188
|
+
"height": 25,
|
|
189
|
+
"active": false
|
|
190
|
+
},
|
|
191
|
+
"exclusions": {
|
|
192
|
+
"active": false,
|
|
193
|
+
"keys": []
|
|
194
|
+
},
|
|
195
|
+
"palette": "qualitative-bold",
|
|
196
|
+
"isPaletteReversed": false,
|
|
197
|
+
"twoColor": {
|
|
198
|
+
"palette": "monochrome-1",
|
|
199
|
+
"isPaletteReversed": false
|
|
200
|
+
},
|
|
201
|
+
"labels": false,
|
|
202
|
+
"dataFormat": {
|
|
203
|
+
"commas": false,
|
|
204
|
+
"prefix": "",
|
|
205
|
+
"suffix": "",
|
|
206
|
+
"abbreviated": false,
|
|
207
|
+
"bottomSuffix": "",
|
|
208
|
+
"bottomPrefix": "",
|
|
209
|
+
"bottomAbbreviated": false,
|
|
210
|
+
"roundTo": "1",
|
|
211
|
+
"showPiePercent": true
|
|
212
|
+
},
|
|
213
|
+
"confidenceKeys": {},
|
|
214
|
+
"visual": {
|
|
215
|
+
"border": true,
|
|
216
|
+
"accent": true,
|
|
217
|
+
"background": true,
|
|
218
|
+
"verticalHoverLine": false,
|
|
219
|
+
"horizontalHoverLine": false,
|
|
220
|
+
"lineDatapointSymbol": "none",
|
|
221
|
+
"maximumShapeAmount": 7
|
|
222
|
+
},
|
|
223
|
+
"useLogScale": false,
|
|
224
|
+
"filterBehavior": "Filter Change",
|
|
225
|
+
"highlightedBarValues": [],
|
|
226
|
+
"series": [
|
|
227
|
+
{
|
|
228
|
+
"dataKey": "American Indian/Alaska Native",
|
|
229
|
+
"type": "Line",
|
|
230
|
+
"axis": "Left",
|
|
231
|
+
"tooltip": true
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"dataKey": "Asian/Pacific Islander",
|
|
235
|
+
"type": "Line",
|
|
236
|
+
"axis": "Left",
|
|
237
|
+
"tooltip": true
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"dataKey": "Black, non-Hispanic",
|
|
241
|
+
"type": "Line",
|
|
242
|
+
"axis": "Left",
|
|
243
|
+
"tooltip": true
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"dataKey": "White, non-Hispanic",
|
|
247
|
+
"type": "Line",
|
|
248
|
+
"axis": "Left",
|
|
249
|
+
"tooltip": true
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"dataKey": "Hispanic",
|
|
253
|
+
"type": "Line",
|
|
254
|
+
"axis": "Left",
|
|
255
|
+
"tooltip": true
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
"tooltips": {
|
|
259
|
+
"opacity": 90,
|
|
260
|
+
"singleSeries": false,
|
|
261
|
+
"dateDisplayFormat": ""
|
|
262
|
+
},
|
|
263
|
+
"forestPlot": {
|
|
264
|
+
"startAt": 0,
|
|
265
|
+
"colors": {
|
|
266
|
+
"line": "",
|
|
267
|
+
"shape": ""
|
|
268
|
+
},
|
|
269
|
+
"lineOfNoEffect": {
|
|
270
|
+
"show": true
|
|
271
|
+
},
|
|
272
|
+
"type": "",
|
|
273
|
+
"pooledResult": {
|
|
274
|
+
"diamondHeight": 5,
|
|
275
|
+
"column": ""
|
|
276
|
+
},
|
|
277
|
+
"estimateField": "",
|
|
278
|
+
"estimateRadius": "",
|
|
279
|
+
"shape": "square",
|
|
280
|
+
"rowHeight": 20,
|
|
281
|
+
"description": {
|
|
282
|
+
"show": true,
|
|
283
|
+
"text": "description",
|
|
284
|
+
"location": 0
|
|
285
|
+
},
|
|
286
|
+
"result": {
|
|
287
|
+
"show": true,
|
|
288
|
+
"text": "result",
|
|
289
|
+
"location": 100
|
|
290
|
+
},
|
|
291
|
+
"radius": {
|
|
292
|
+
"min": 2,
|
|
293
|
+
"max": 10,
|
|
294
|
+
"scalingColumn": ""
|
|
295
|
+
},
|
|
296
|
+
"regression": {
|
|
297
|
+
"lower": 0,
|
|
298
|
+
"upper": 0,
|
|
299
|
+
"estimateField": 0
|
|
300
|
+
},
|
|
301
|
+
"leftWidthOffset": 0,
|
|
302
|
+
"rightWidthOffset": 0,
|
|
303
|
+
"showZeroLine": false,
|
|
304
|
+
"leftLabel": "",
|
|
305
|
+
"rightLabel": ""
|
|
306
|
+
},
|
|
307
|
+
"area": {
|
|
308
|
+
"isStacked": false
|
|
309
|
+
},
|
|
310
|
+
"sankey": {
|
|
311
|
+
"title": {
|
|
312
|
+
"defaultColor": "black"
|
|
313
|
+
},
|
|
314
|
+
"iterations": 1,
|
|
315
|
+
"rxValue": 0.9,
|
|
316
|
+
"overallSize": {
|
|
317
|
+
"width": 900,
|
|
318
|
+
"height": 700
|
|
319
|
+
},
|
|
320
|
+
"margin": {
|
|
321
|
+
"margin_y": 25,
|
|
322
|
+
"margin_x": 0
|
|
323
|
+
},
|
|
324
|
+
"nodeSize": {
|
|
325
|
+
"nodeWidth": 26,
|
|
326
|
+
"nodeHeight": 40
|
|
327
|
+
},
|
|
328
|
+
"nodePadding": 55,
|
|
329
|
+
"nodeFontColor": "black",
|
|
330
|
+
"nodeColor": {
|
|
331
|
+
"default": "#ff8500",
|
|
332
|
+
"inactive": "#808080"
|
|
333
|
+
},
|
|
334
|
+
"linkColor": {
|
|
335
|
+
"default": "#ffc900",
|
|
336
|
+
"inactive": "#D3D3D3"
|
|
337
|
+
},
|
|
338
|
+
"opacity": {
|
|
339
|
+
"nodeOpacityDefault": 1,
|
|
340
|
+
"nodeOpacityInactive": 0.1,
|
|
341
|
+
"LinkOpacityDefault": 1,
|
|
342
|
+
"LinkOpacityInactive": 0.1
|
|
343
|
+
},
|
|
344
|
+
"storyNodeFontColor": "#006778",
|
|
345
|
+
"storyNodeText": [],
|
|
346
|
+
"nodeValueStyle": {
|
|
347
|
+
"textBefore": "(",
|
|
348
|
+
"textAfter": ")"
|
|
349
|
+
},
|
|
350
|
+
"data": []
|
|
351
|
+
},
|
|
352
|
+
"errors": [],
|
|
353
|
+
"currentViewport": "lg",
|
|
354
|
+
"id": 4,
|
|
355
|
+
"category": "Charts",
|
|
356
|
+
"label": "Line",
|
|
357
|
+
"subType": "Line",
|
|
358
|
+
"icon": {
|
|
359
|
+
"key": null,
|
|
360
|
+
"ref": null,
|
|
361
|
+
"props": {},
|
|
362
|
+
"_owner": null
|
|
363
|
+
},
|
|
364
|
+
"content": "Present one or more data trends over time.",
|
|
365
|
+
"visualizationType": "Pie",
|
|
366
|
+
"datasets": {},
|
|
367
|
+
"activeVizButtonID": 4,
|
|
368
|
+
"data": [
|
|
369
|
+
{
|
|
370
|
+
"Year": "2007",
|
|
371
|
+
"American Indian/Alaska Native": "1.4",
|
|
372
|
+
"Asian/Pacific Islander": "0.9",
|
|
373
|
+
"Black, non-Hispanic": "2.3",
|
|
374
|
+
"White, non-Hispanic": "1",
|
|
375
|
+
"Hispanic": "50"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"Year": "2008",
|
|
379
|
+
"American Indian/Alaska Native": "1.8",
|
|
380
|
+
"Asian/Pacific Islander": "0.8",
|
|
381
|
+
"Black, non-Hispanic": "2.2",
|
|
382
|
+
"White, non-Hispanic": "0.9",
|
|
383
|
+
"Hispanic": "40"
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
"dataFileName": "chart_data 2-6.csv",
|
|
387
|
+
"dataFileSourceType": "file",
|
|
388
|
+
"dataDescription": {
|
|
389
|
+
"horizontal": false,
|
|
390
|
+
"series": false
|
|
391
|
+
},
|
|
392
|
+
"version": "4.25.6",
|
|
393
|
+
"dynamicMarginTop": 0,
|
|
394
|
+
"formattedData": [
|
|
395
|
+
{
|
|
396
|
+
"Year": "2007",
|
|
397
|
+
"American Indian/Alaska Native": "1.4",
|
|
398
|
+
"Asian/Pacific Islander": "0.9",
|
|
399
|
+
"Black, non-Hispanic": "2.3",
|
|
400
|
+
"White, non-Hispanic": "1",
|
|
401
|
+
"Hispanic": "50"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"Year": "2008",
|
|
405
|
+
"American Indian/Alaska Native": "1.8",
|
|
406
|
+
"Asian/Pacific Islander": "0.8",
|
|
407
|
+
"Black, non-Hispanic": "2.2",
|
|
408
|
+
"White, non-Hispanic": "0.9",
|
|
409
|
+
"Hispanic": "40"
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
"filters": [],
|
|
413
|
+
"migrations": {
|
|
414
|
+
"addColorMigration": true
|
|
415
|
+
},
|
|
416
|
+
"allowLineToBarGraph": "__undefined__"
|
|
417
|
+
}
|
|
@@ -59,11 +59,7 @@ export const BarChartHorizontal = () => {
|
|
|
59
59
|
|
|
60
60
|
const { HighLightedBarUtils } = useHighlightedBars(config)
|
|
61
61
|
|
|
62
|
-
const hasConfidenceInterval =
|
|
63
|
-
config.confidenceKeys.upper &&
|
|
64
|
-
config.confidenceKeys.lower &&
|
|
65
|
-
config.confidenceKeys.upper !== '' &&
|
|
66
|
-
config.confidenceKeys.lower !== ''
|
|
62
|
+
const hasConfidenceInterval = Object.keys(config.confidenceKeys).length > 0
|
|
67
63
|
|
|
68
64
|
const _data = getBarData(config, data, hasConfidenceInterval)
|
|
69
65
|
|
|
@@ -232,8 +228,6 @@ export const BarChartHorizontal = () => {
|
|
|
232
228
|
const d = datum[config.confidenceKeys[position]]
|
|
233
229
|
return xScale(d)
|
|
234
230
|
})
|
|
235
|
-
const labelX = bar.y
|
|
236
|
-
const overlapWithCI = hasConfidenceInterval && labelX >= lowerPos && labelX <= upperPos
|
|
237
231
|
|
|
238
232
|
return (
|
|
239
233
|
<Group display={hideGroup} key={`${barGroup.index}--${index}`}>
|
|
@@ -267,6 +261,7 @@ export const BarChartHorizontal = () => {
|
|
|
267
261
|
display: displayBar ? 'block' : 'none'
|
|
268
262
|
}
|
|
269
263
|
})}
|
|
264
|
+
|
|
270
265
|
{config.preliminaryData?.map((pd, index) => {
|
|
271
266
|
// check if user selected column
|
|
272
267
|
const selectedSuppressionColumn = !pd.column || pd.column === bar.key
|
|
@@ -311,12 +306,8 @@ export const BarChartHorizontal = () => {
|
|
|
311
306
|
display={displayBar ? 'block' : 'none'}
|
|
312
307
|
x={bar.y}
|
|
313
308
|
opacity={transparentBar ? 0.5 : 1}
|
|
314
|
-
y={
|
|
315
|
-
|
|
316
|
-
? config.barHeight * bar.index
|
|
317
|
-
: config.barHeight / 2 + config.barHeight * bar.index
|
|
318
|
-
}
|
|
319
|
-
fill={hasConfidenceInterval && overlapWithCI ? '#000' : labelColor}
|
|
309
|
+
y={config.barHeight / 2 + config.barHeight * bar.index}
|
|
310
|
+
fill={labelColor}
|
|
320
311
|
dx={textPadding}
|
|
321
312
|
verticalAnchor='middle'
|
|
322
313
|
textAnchor={textAnchor}
|
|
@@ -21,24 +21,13 @@ const BarChartStackedVertical = () => {
|
|
|
21
21
|
onMouseOverBar,
|
|
22
22
|
barStackedSeriesKeys
|
|
23
23
|
} = barChart
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
colorScale,
|
|
27
|
-
seriesHighlight,
|
|
28
|
-
config,
|
|
29
|
-
formatNumber,
|
|
30
|
-
formatDate,
|
|
31
|
-
parseDate,
|
|
32
|
-
setSharedFilter,
|
|
33
|
-
brushConfig
|
|
34
|
-
} = useContext(ConfigContext)
|
|
24
|
+
const { transformedData, colorScale, seriesHighlight, config, formatNumber, formatDate, parseDate, setSharedFilter } =
|
|
25
|
+
useContext(ConfigContext)
|
|
35
26
|
|
|
36
27
|
const { orientation } = config
|
|
37
28
|
|
|
38
29
|
let data = transformedData
|
|
39
|
-
|
|
40
|
-
data = brushConfig.data
|
|
41
|
-
}
|
|
30
|
+
|
|
42
31
|
const isDateAxisType = config.runtime.xAxis.type === 'date-time' || config.runtime.xAxis.type === 'date'
|
|
43
32
|
const isDateTimeScaleAxisType = config.runtime.xAxis.type === 'date-time'
|
|
44
33
|
|
|
@@ -52,8 +52,7 @@ export const BarChartVertical = () => {
|
|
|
52
52
|
parseDate,
|
|
53
53
|
seriesHighlight,
|
|
54
54
|
setSharedFilter,
|
|
55
|
-
transformedData
|
|
56
|
-
brushConfig
|
|
55
|
+
transformedData
|
|
57
56
|
} = useContext<ChartContext>(ConfigContext)
|
|
58
57
|
|
|
59
58
|
const { HighLightedBarUtils } = useHighlightedBars(config)
|
|
@@ -67,10 +66,6 @@ export const BarChartVertical = () => {
|
|
|
67
66
|
if (isSuppressionActive) {
|
|
68
67
|
data = tableData
|
|
69
68
|
}
|
|
70
|
-
// if brush active use brush data (filtered|excluded) not cleaned
|
|
71
|
-
if (brushConfig.data.length) {
|
|
72
|
-
data = brushConfig.data
|
|
73
|
-
}
|
|
74
69
|
|
|
75
70
|
const hasConfidenceInterval =
|
|
76
71
|
config.confidenceKeys.upper &&
|
|
@@ -292,6 +287,7 @@ export const BarChartVertical = () => {
|
|
|
292
287
|
cursor: dashboardConfig ? 'pointer' : 'default'
|
|
293
288
|
}
|
|
294
289
|
})}
|
|
290
|
+
|
|
295
291
|
{config.preliminaryData.map((pd, index) => {
|
|
296
292
|
// check if user selected column
|
|
297
293
|
const selectedSuppressionColumn = !pd.column || pd.column === bar.key
|
|
@@ -335,7 +331,6 @@ export const BarChartVertical = () => {
|
|
|
335
331
|
</Text>
|
|
336
332
|
)
|
|
337
333
|
})}
|
|
338
|
-
|
|
339
334
|
<Text // prettier-ignore
|
|
340
335
|
display={displayBar ? 'block' : 'none'}
|
|
341
336
|
opacity={transparentBar ? 0.5 : 1}
|
|
@@ -357,7 +352,6 @@ export const BarChartVertical = () => {
|
|
|
357
352
|
>
|
|
358
353
|
{absentDataLabel}
|
|
359
354
|
</Text>
|
|
360
|
-
|
|
361
355
|
{config.isLollipopChart && config.lollipopShape === 'circle' && (
|
|
362
356
|
<circle
|
|
363
357
|
display={displaylollipopShape}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { FC, useContext, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { Brush } from '@visx/brush'
|
|
3
|
+
import { Group } from '@visx/group'
|
|
4
|
+
import { scaleBand, scaleLinear } from '@visx/scale'
|
|
5
|
+
import ConfigContext from '../../ConfigContext'
|
|
6
|
+
import { Text } from '@visx/text'
|
|
7
|
+
import { APP_FONT_SIZE } from '@cdc/core/helpers/constants'
|
|
8
|
+
import { getTextWidth } from '@cdc/core/helpers/getTextWidth'
|
|
9
|
+
import { isDateScale } from '@cdc/core/helpers/cove/date'
|
|
10
|
+
export interface ZoomBrushProps {
|
|
11
|
+
xMax: number
|
|
12
|
+
yMax: number
|
|
13
|
+
brushPosition: { start: { x: number }; end: { x: number } }
|
|
14
|
+
onBrushChange: (bounds: any) => void
|
|
15
|
+
brushKey: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ZoomBrush: FC<ZoomBrushProps> = ({ xMax, yMax, brushPosition, onBrushChange, brushKey }) => {
|
|
19
|
+
const { tableData, config, parseDate, dashboardConfig } = useContext(ConfigContext)
|
|
20
|
+
const brushRef = useRef(null)
|
|
21
|
+
const dataKey = config.xAxis.dataKey
|
|
22
|
+
const borderRadius = 15
|
|
23
|
+
const mappedDates: string[] = tableData.map(row => row[dataKey])
|
|
24
|
+
const brushheight = 25
|
|
25
|
+
const DASHBOARD_MARGIN = 50
|
|
26
|
+
const BRUSH_HEIGHT_MULTIPLIER = 1.5
|
|
27
|
+
|
|
28
|
+
const xScale = scaleBand<string>({
|
|
29
|
+
domain: mappedDates,
|
|
30
|
+
range: [0, xMax],
|
|
31
|
+
paddingInner: 0.1,
|
|
32
|
+
paddingOuter: 0.1
|
|
33
|
+
})
|
|
34
|
+
const yScale = scaleLinear({ domain: [0, yMax], range: [0, yMax] })
|
|
35
|
+
|
|
36
|
+
const calculateGroupTop = (): number => {
|
|
37
|
+
if (dashboardConfig?.type === 'dashboard') {
|
|
38
|
+
return Number(yMax) + config.xAxis.axisBBox + brushheight * BRUSH_HEIGHT_MULTIPLIER + DASHBOARD_MARGIN
|
|
39
|
+
} else {
|
|
40
|
+
return Number(yMax) + config.xAxis.axisBBox + brushheight * BRUSH_HEIGHT_MULTIPLIER
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const style = {
|
|
45
|
+
fill: '#474747',
|
|
46
|
+
stroke: 'blue',
|
|
47
|
+
strokeOpacity: 0,
|
|
48
|
+
rx: borderRadius
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Group left={config.yAxis.size} top={calculateGroupTop()}>
|
|
53
|
+
<rect fill='#949494' width={xMax} height={25} rx={borderRadius} pointerEvents='none' />
|
|
54
|
+
<Brush
|
|
55
|
+
innerRef={brushRef}
|
|
56
|
+
key={brushKey}
|
|
57
|
+
xScale={xScale}
|
|
58
|
+
yScale={yScale}
|
|
59
|
+
width={xMax}
|
|
60
|
+
height={25}
|
|
61
|
+
brushDirection='horizontal'
|
|
62
|
+
handleSize={8}
|
|
63
|
+
resizeTriggerAreas={['left', 'right']}
|
|
64
|
+
initialBrushPosition={brushPosition}
|
|
65
|
+
selectedBoxStyle={style}
|
|
66
|
+
onChange={onBrushChange}
|
|
67
|
+
disableDraggingOverlay={true}
|
|
68
|
+
/>
|
|
69
|
+
</Group>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default ZoomBrush
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useState, useEffect, useContext } from 'react'
|
|
2
|
+
import ConfigContext, { ChartDispatchContext } from '../../ConfigContext'
|
|
3
|
+
import ZoomBrush from './BrushChart'
|
|
4
|
+
const BrushController = ({ yMax, xMax }) => {
|
|
5
|
+
const { tableData, config, parseDate, dashboardConfig } = useContext(ConfigContext)
|
|
6
|
+
const dataKey = config.xAxis.dataKey
|
|
7
|
+
const [brushKey, setBrushKey] = useState(0)
|
|
8
|
+
const dispatch = useContext(ChartDispatchContext)
|
|
9
|
+
const sharedFilters = dashboardConfig?.dashboard?.sharedFilters ?? []
|
|
10
|
+
const isDashboardFilters = sharedFilters?.length > 0
|
|
11
|
+
const [brushPosition, setBrushPosition] = useState({
|
|
12
|
+
start: { x: 0 },
|
|
13
|
+
end: { x: xMax }
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const handleBrushChange = (bounds: any) => {
|
|
17
|
+
const selected = bounds.xValues || []
|
|
18
|
+
const filteredData = tableData.filter(row => selected.includes(row[dataKey]))
|
|
19
|
+
dispatch({ type: 'SET_BRUSH_DATA', payload: filteredData })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// whenever your other filters change:
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setBrushPosition({ start: { x: 0 }, end: { x: xMax } })
|
|
25
|
+
dispatch({ type: 'SET_BRUSH_DATA', payload: [] })
|
|
26
|
+
setBrushKey(k => k + 1)
|
|
27
|
+
}, [config.filters, config.exclusions, config.brush?.active, isDashboardFilters])
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ZoomBrush
|
|
31
|
+
xMax={xMax}
|
|
32
|
+
yMax={yMax}
|
|
33
|
+
brushPosition={brushPosition}
|
|
34
|
+
onBrushChange={handleBrushChange}
|
|
35
|
+
brushKey={brushKey}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
export default BrushController
|