@cdc/chart 4.24.5 → 4.24.9
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.js +44197 -38258
- package/examples/cases-year.json +13379 -0
- package/examples/feature/annotations/index.json +542 -0
- package/examples/gallery/bar-chart-vertical/combo-line-chart.json +76 -15
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +5 -5
- package/examples/xaxis.json +493 -0
- package/index.html +20 -10
- package/package.json +5 -4
- package/src/CdcChart.tsx +462 -172
- package/src/_stories/Chart.Legend.Gradient.tsx +19 -0
- package/src/_stories/Chart.stories.tsx +18 -171
- package/src/_stories/ChartAnnotation.stories.tsx +32 -0
- package/src/_stories/_mock/annotation_category_mock.json +473 -0
- package/src/_stories/_mock/annotation_date-linear_mock.json +530 -0
- package/{examples/feature/line/line-chart.json → src/_stories/_mock/annotation_date-time_mock.json} +150 -69
- package/src/_stories/_mock/legend.gradient_mock.json +236 -0
- package/src/_stories/_mock/line_chart_two_points_new_chart.json +128 -0
- package/src/_stories/_mock/line_chart_two_points_regression_test.json +127 -0
- package/src/_stories/_mock/lollipop.json +171 -0
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +31 -0
- package/src/components/Annotations/components/AnnotationDraggable.tsx +207 -0
- package/src/components/Annotations/components/AnnotationDropdown.styles.css +14 -0
- package/src/components/Annotations/components/AnnotationDropdown.tsx +72 -0
- package/src/components/Annotations/components/AnnotationList.styles.css +45 -0
- package/src/components/Annotations/components/AnnotationList.tsx +42 -0
- package/src/components/Annotations/components/findNearestDatum.ts +138 -0
- package/src/components/Annotations/components/helpers/index.tsx +46 -0
- package/src/components/Annotations/index.tsx +13 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -1
- package/src/components/AreaChart/components/AreaChart.jsx +1 -1
- package/src/components/Axis/Categorical.Axis.tsx +145 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +47 -44
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +0 -1
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +11 -14
- package/src/components/BarChart/components/BarChart.Vertical.tsx +67 -30
- package/src/components/BarChart/helpers/index.ts +91 -0
- package/src/components/BrushChart.tsx +205 -0
- package/src/components/EditorPanel/EditorPanel.tsx +1794 -403
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +320 -0
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +282 -18
- package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +43 -8
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +4 -4
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +4 -13
- package/src/components/EditorPanel/components/Panels/index.tsx +3 -1
- package/src/components/EditorPanel/components/panels.scss +4 -0
- package/src/components/EditorPanel/editor-panel.scss +35 -3
- package/src/components/EditorPanel/{useEditorPermissions.js → useEditorPermissions.ts} +105 -17
- package/src/components/Legend/Legend.Component.tsx +185 -194
- package/src/components/Legend/Legend.Suppression.tsx +146 -0
- package/src/components/Legend/Legend.tsx +21 -5
- package/src/components/Legend/helpers/createFormatLabels.tsx +1 -1
- package/src/components/Legend/helpers/index.ts +35 -0
- package/src/components/LegendWrapper.tsx +26 -0
- package/src/components/LineChart/LineChartProps.ts +1 -15
- package/src/components/LineChart/components/LineChart.BumpCircle.tsx +103 -0
- package/src/components/LineChart/components/LineChart.Circle.tsx +47 -8
- package/src/components/LineChart/helpers.ts +72 -14
- package/src/components/LineChart/index.tsx +117 -42
- package/src/components/LinearChart.jsx +179 -136
- package/src/components/LinearChart.tsx +1366 -0
- package/src/components/PairedBarChart.jsx +9 -9
- package/src/components/PieChart/PieChart.tsx +75 -18
- package/src/components/Sankey/index.tsx +89 -30
- package/src/components/ScatterPlot/ScatterPlot.jsx +22 -8
- package/src/components/Sparkline/components/SparkLine.tsx +2 -2
- package/src/components/ZoomBrush.tsx +90 -44
- package/src/data/initial-state.js +25 -7
- package/src/helpers/handleChartTabbing.ts +8 -0
- package/src/helpers/isConvertLineToBarGraph.ts +4 -0
- package/src/hooks/{useBarChart.js → useBarChart.ts} +2 -40
- package/src/hooks/useColorScale.ts +1 -1
- package/src/hooks/useLegendClasses.ts +68 -0
- package/src/hooks/useMinMax.ts +12 -7
- package/src/hooks/useScales.ts +58 -26
- package/src/hooks/useTooltip.tsx +135 -25
- package/src/scss/DataTable.scss +2 -1
- package/src/scss/main.scss +128 -28
- package/src/types/ChartConfig.ts +83 -10
- package/src/types/ChartContext.ts +14 -4
- package/tests-examples/helpers/testZeroValue.test.ts +30 -0
- package/LICENSE +0 -201
- package/src/components/BrushHandle.jsx +0 -17
- package/src/components/LineChart/index.scss +0 -1
- package/src/helpers/filterData.ts +0 -18
- package/src/helpers/tests/computeMarginBottom.test.ts +0 -21
- package/src/hooks/useLegendClasses.js +0 -31
- /package/src/hooks/{useReduceData.js → useReduceData.ts} +0 -0
package/src/scss/main.scss
CHANGED
|
@@ -24,6 +24,28 @@
|
|
|
24
24
|
.cdc-open-viz-module.type-chart {
|
|
25
25
|
@import 'DataTable';
|
|
26
26
|
|
|
27
|
+
.legend-top {
|
|
28
|
+
.legend-wrapper .tooltip-boundary {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-wrap: wrap;
|
|
31
|
+
order: 2;
|
|
32
|
+
aside {
|
|
33
|
+
width: 100%;
|
|
34
|
+
order: 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.legend-bottom {
|
|
40
|
+
.legend-wrapper {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-wrap: wrap;
|
|
43
|
+
aside {
|
|
44
|
+
width: 100%;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
&.isEditor .cdc-chart-inner-container {
|
|
28
50
|
background: white;
|
|
29
51
|
}
|
|
@@ -90,7 +112,15 @@
|
|
|
90
112
|
.subtext,
|
|
91
113
|
.subtext--responsive-ticks,
|
|
92
114
|
.section-subtext {
|
|
93
|
-
|
|
115
|
+
&--brush-active {
|
|
116
|
+
margin-top: 2.5em;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.type-pie {
|
|
121
|
+
svg.animated-pie {
|
|
122
|
+
width: auto !important;
|
|
123
|
+
}
|
|
94
124
|
}
|
|
95
125
|
|
|
96
126
|
.legend-container {
|
|
@@ -100,15 +130,20 @@
|
|
|
100
130
|
vertical-align: top;
|
|
101
131
|
text-align: left;
|
|
102
132
|
border: 1px solid $lightGray;
|
|
103
|
-
order: 1;
|
|
104
133
|
position: relative;
|
|
105
134
|
|
|
135
|
+
&.no-border {
|
|
136
|
+
border: 1px solid transparent;
|
|
137
|
+
}
|
|
138
|
+
|
|
106
139
|
&__inner {
|
|
107
|
-
&.
|
|
140
|
+
&.double-column,
|
|
141
|
+
&.single-row {
|
|
108
142
|
display: grid;
|
|
109
143
|
grid-template-columns: 1fr 1fr;
|
|
110
144
|
grid-column-gap: 1.5em;
|
|
111
145
|
}
|
|
146
|
+
|
|
112
147
|
&.vertical-sorted {
|
|
113
148
|
display: block;
|
|
114
149
|
|
|
@@ -141,9 +176,10 @@
|
|
|
141
176
|
word-wrap: break-word;
|
|
142
177
|
white-space: pre-wrap;
|
|
143
178
|
word-break: break-word;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
& > :first-child {
|
|
182
|
+
margin-top: 3px;
|
|
147
183
|
}
|
|
148
184
|
}
|
|
149
185
|
|
|
@@ -159,20 +195,13 @@
|
|
|
159
195
|
|
|
160
196
|
h3 {
|
|
161
197
|
font-size: 1.3rem;
|
|
162
|
-
@include breakpoint(xs) {
|
|
163
|
-
font-size: $font-small + 0.4em;
|
|
164
|
-
}
|
|
165
198
|
}
|
|
166
199
|
|
|
167
200
|
h3,
|
|
168
201
|
p {
|
|
169
202
|
margin-bottom: 0.8em;
|
|
170
203
|
}
|
|
171
|
-
|
|
172
|
-
@include breakpoint(xs) {
|
|
173
|
-
font-size: $font-small;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
204
|
+
|
|
176
205
|
& div.legend-item {
|
|
177
206
|
margin-bottom: 0.5em !important;
|
|
178
207
|
|
|
@@ -190,6 +219,23 @@
|
|
|
190
219
|
transition: 0.2s all;
|
|
191
220
|
}
|
|
192
221
|
}
|
|
222
|
+
|
|
223
|
+
&__outer {
|
|
224
|
+
&.definition-link {
|
|
225
|
+
display: flex;
|
|
226
|
+
flex-direction: row;
|
|
227
|
+
position: absolute;
|
|
228
|
+
left: 0%;
|
|
229
|
+
top: 108%;
|
|
230
|
+
& > * {
|
|
231
|
+
margin: 0;
|
|
232
|
+
}
|
|
233
|
+
& > p,
|
|
234
|
+
a {
|
|
235
|
+
margin-left: 5px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
193
239
|
}
|
|
194
240
|
|
|
195
241
|
.dynamic-legend-list {
|
|
@@ -226,9 +272,6 @@
|
|
|
226
272
|
vertical-align: middle;
|
|
227
273
|
margin-bottom: 0.5em;
|
|
228
274
|
|
|
229
|
-
@include breakpoint(xs) {
|
|
230
|
-
font-size: $font-small;
|
|
231
|
-
}
|
|
232
275
|
& > span {
|
|
233
276
|
display: flex;
|
|
234
277
|
justify-items: center;
|
|
@@ -276,7 +319,61 @@
|
|
|
276
319
|
display: flex;
|
|
277
320
|
align-items: flex-start;
|
|
278
321
|
flex-wrap: wrap;
|
|
322
|
+
justify-content: space-between;
|
|
323
|
+
|
|
324
|
+
&.legend-top:not(.legend-hidden) {
|
|
325
|
+
.legend-wrapper {
|
|
326
|
+
& > div {
|
|
327
|
+
order: 2;
|
|
328
|
+
width: 100%;
|
|
329
|
+
}
|
|
330
|
+
aside {
|
|
331
|
+
width: 100%;
|
|
332
|
+
order: 1;
|
|
333
|
+
height: fit-content;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
&.legend-left:not(.legend-hidden) {
|
|
339
|
+
.legend-wrapper {
|
|
340
|
+
& > div {
|
|
341
|
+
order: 2;
|
|
342
|
+
width: 75%;
|
|
343
|
+
}
|
|
344
|
+
aside {
|
|
345
|
+
width: 25%;
|
|
346
|
+
order: 1;
|
|
347
|
+
height: fit-content;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
&.legend-right:not(.legend-hidden) {
|
|
353
|
+
.legend-wrapper {
|
|
354
|
+
& > div {
|
|
355
|
+
order: 1;
|
|
356
|
+
width: 75%;
|
|
357
|
+
}
|
|
358
|
+
aside {
|
|
359
|
+
width: 25%;
|
|
360
|
+
height: fit-content;
|
|
361
|
+
order: 2;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
279
365
|
|
|
366
|
+
&.left {
|
|
367
|
+
display: flex;
|
|
368
|
+
flex-direction: row-reverse;
|
|
369
|
+
}
|
|
370
|
+
&.top {
|
|
371
|
+
flex-wrap: nowrap;
|
|
372
|
+
flex-direction: column-reverse;
|
|
373
|
+
& > div.tooltip-boundary {
|
|
374
|
+
margin-top: 1.5em;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
280
377
|
&.bottom {
|
|
281
378
|
flex-wrap: nowrap;
|
|
282
379
|
flex-direction: column;
|
|
@@ -284,6 +381,17 @@
|
|
|
284
381
|
&.legend-hidden > svg {
|
|
285
382
|
width: 100% !important;
|
|
286
383
|
}
|
|
384
|
+
&.dashboard-brush {
|
|
385
|
+
margin-bottom: 2.5em;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
svg.dragging-annotation * {
|
|
389
|
+
user-select: none;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
svg.dragging-annotation path {
|
|
393
|
+
pointer-events: none;
|
|
394
|
+
}
|
|
287
395
|
|
|
288
396
|
> svg {
|
|
289
397
|
overflow: visible;
|
|
@@ -415,15 +523,7 @@
|
|
|
415
523
|
}
|
|
416
524
|
|
|
417
525
|
@include breakpointClass(md) {
|
|
418
|
-
.filters-section,
|
|
419
|
-
.chart-container:not(.sparkline) {
|
|
420
|
-
margin-left: 1em;
|
|
421
|
-
margin-right: 1em;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
526
|
.chart-container {
|
|
425
|
-
flex-wrap: nowrap;
|
|
426
|
-
|
|
427
527
|
.no-wrap {
|
|
428
528
|
flex-wrap: nowrap;
|
|
429
529
|
}
|
|
@@ -431,14 +531,15 @@
|
|
|
431
531
|
.legend-container {
|
|
432
532
|
width: 25%;
|
|
433
533
|
margin-left: 1em;
|
|
434
|
-
|
|
534
|
+
height: fit-content;
|
|
435
535
|
|
|
436
536
|
&.left {
|
|
437
537
|
margin-left: 0;
|
|
438
538
|
margin-right: 1em;
|
|
439
539
|
order: 0;
|
|
440
540
|
}
|
|
441
|
-
&.bottom
|
|
541
|
+
&.bottom,
|
|
542
|
+
&.top {
|
|
442
543
|
width: 100%;
|
|
443
544
|
margin-left: 0;
|
|
444
545
|
}
|
|
@@ -702,7 +803,6 @@
|
|
|
702
803
|
.subtext,
|
|
703
804
|
.subtext--responsive-ticks {
|
|
704
805
|
margin-top: 0px;
|
|
705
|
-
padding: 0 1rem;
|
|
706
806
|
}
|
|
707
807
|
|
|
708
808
|
.isEditor {
|
package/src/types/ChartConfig.ts
CHANGED
|
@@ -8,14 +8,34 @@ import { Table } from '@cdc/core/types/Table'
|
|
|
8
8
|
import { BoxPlot } from '@cdc/core/types/BoxPlot'
|
|
9
9
|
import { General } from '@cdc/core/types/General'
|
|
10
10
|
import { type Link } from './../components/Sankey/types'
|
|
11
|
-
import { Legend } from '@cdc/core/types/Legend'
|
|
12
11
|
import { ConfidenceInterval } from '@cdc/core/types/ConfidenceInterval'
|
|
13
12
|
import { Region } from '@cdc/core/types/Region'
|
|
14
|
-
|
|
13
|
+
|
|
15
14
|
import { VizFilter } from '@cdc/core/types/VizFilter'
|
|
15
|
+
import { type Annotation } from '@cdc/core/types/Annotation'
|
|
16
16
|
|
|
17
|
+
export type ViewportSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
|
|
17
18
|
export type ChartColumns = Record<string, Column>
|
|
18
19
|
|
|
20
|
+
export interface PreliminaryDataItem {
|
|
21
|
+
column: string
|
|
22
|
+
displayLegend: boolean
|
|
23
|
+
displayTable: boolean
|
|
24
|
+
displayTooltip: boolean
|
|
25
|
+
iconCode: string
|
|
26
|
+
label: string
|
|
27
|
+
lineCode: string
|
|
28
|
+
seriesKey: string
|
|
29
|
+
style: string
|
|
30
|
+
symbol: string
|
|
31
|
+
type: 'effect' | 'suppression'
|
|
32
|
+
value: string
|
|
33
|
+
hideBarSymbol: boolean
|
|
34
|
+
hideLineStyle: boolean
|
|
35
|
+
circleSize: number
|
|
36
|
+
displayGray: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
type DataFormat = {
|
|
20
40
|
abbreviated: boolean
|
|
21
41
|
bottomAbbreviated: boolean
|
|
@@ -52,12 +72,20 @@ export type Legend = {
|
|
|
52
72
|
hide: boolean
|
|
53
73
|
highlightOnHover: boolean
|
|
54
74
|
label: string
|
|
55
|
-
|
|
56
|
-
position: string
|
|
75
|
+
position: 'left' | 'bottom' | 'top' | 'right'
|
|
57
76
|
reverseLabelOrder: boolean
|
|
58
77
|
singleRow: boolean
|
|
59
78
|
type: string
|
|
60
79
|
verticalSorted: boolean
|
|
80
|
+
hideSuppressionLink:boolean
|
|
81
|
+
style:'circles'|'boxes'|'gradient'|'lines'
|
|
82
|
+
subStyle:'linear blocks'|'smooth'
|
|
83
|
+
hideSuppressedLabels:boolean
|
|
84
|
+
tickRotation:string
|
|
85
|
+
hideBorder:{
|
|
86
|
+
side:boolean
|
|
87
|
+
topBottom:boolean
|
|
88
|
+
}
|
|
61
89
|
}
|
|
62
90
|
|
|
63
91
|
type Visual = {
|
|
@@ -70,13 +98,14 @@ type Visual = {
|
|
|
70
98
|
horizontalHoverLine?: boolean
|
|
71
99
|
}
|
|
72
100
|
|
|
73
|
-
type AllChartsConfig = {
|
|
101
|
+
export type AllChartsConfig = {
|
|
102
|
+
annotations: Annotation[]
|
|
74
103
|
animate: boolean
|
|
75
104
|
general: General
|
|
76
105
|
barHasBorder: 'true' | 'false'
|
|
77
106
|
barHeight: number
|
|
78
107
|
barSpace: number
|
|
79
|
-
barStyle:
|
|
108
|
+
barStyle: 'lollipop'|'rounded'|'flat'
|
|
80
109
|
barThickness: number
|
|
81
110
|
boxplot: BoxPlot
|
|
82
111
|
brush: {
|
|
@@ -106,6 +135,7 @@ type AllChartsConfig = {
|
|
|
106
135
|
formattedData: Object[] & { urlFiltered: boolean }
|
|
107
136
|
heights: {
|
|
108
137
|
vertical: number
|
|
138
|
+
mobileVertical: number
|
|
109
139
|
}
|
|
110
140
|
highlightedBarValues: { value: any; color: string; borderWidth: number; legendLabel: string }[]
|
|
111
141
|
introText: string
|
|
@@ -149,10 +179,9 @@ type AllChartsConfig = {
|
|
|
149
179
|
topAxis: { hasLine: boolean }
|
|
150
180
|
twoColor: { palette: string }
|
|
151
181
|
type: 'chart' | 'dashboard'
|
|
152
|
-
useLogScale: boolean
|
|
153
182
|
uid: string | number
|
|
154
183
|
visual: Visual
|
|
155
|
-
visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting' | 'Sankey'
|
|
184
|
+
visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting' | 'Sankey' | 'Bump Chart'
|
|
156
185
|
visualizationSubType: string
|
|
157
186
|
xAxis: Axis
|
|
158
187
|
yAxis: Axis
|
|
@@ -188,8 +217,52 @@ export type ForestPlotConfig = {
|
|
|
188
217
|
} & AllChartsConfig
|
|
189
218
|
|
|
190
219
|
export type LineChartConfig = {
|
|
191
|
-
|
|
220
|
+
allowLineToBarGraph: boolean
|
|
221
|
+
convertLineToBarGraph: boolean
|
|
192
222
|
lineDatapointStyle: 'hidden' | 'always show' | 'hover'
|
|
223
|
+
visualizationType: 'Line'
|
|
224
|
+
} & AllChartsConfig
|
|
225
|
+
|
|
226
|
+
export type SankeyLink = {
|
|
227
|
+
depth: number
|
|
228
|
+
height: number
|
|
229
|
+
id: string
|
|
230
|
+
index: number
|
|
231
|
+
layer: number
|
|
232
|
+
sourceLinks: SankeyLink[]
|
|
233
|
+
targetLinks: SankeyLink[]
|
|
234
|
+
value: number
|
|
235
|
+
x0: number
|
|
236
|
+
x1: number
|
|
237
|
+
y0: number
|
|
238
|
+
y1: number
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
type StoryNode = {
|
|
242
|
+
StoryNode: string
|
|
243
|
+
segmentTextAfter: string
|
|
244
|
+
segmentTextBefore: string
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export type SankeyChartConfig = {
|
|
248
|
+
enableTooltips: boolean
|
|
249
|
+
data: [
|
|
250
|
+
{
|
|
251
|
+
tooltips: Object[]
|
|
252
|
+
// data to display in the sankey chart tooltips
|
|
253
|
+
tooltipData: Object[]
|
|
254
|
+
// data to display in the data table, bypasses the default data table output
|
|
255
|
+
tableData: Object[]
|
|
256
|
+
links: {
|
|
257
|
+
source: SankeyLink
|
|
258
|
+
target: SankeyLink
|
|
259
|
+
value: number
|
|
260
|
+
}[],
|
|
261
|
+
storyNodeText: StoryNode[]
|
|
262
|
+
:
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
visualizationType: 'Sankey'
|
|
193
266
|
} & AllChartsConfig
|
|
194
267
|
|
|
195
|
-
export type ChartConfig = LineChartConfig | ForestPlotConfig | AllChartsConfig
|
|
268
|
+
export type ChartConfig = SankeyChartConfig | LineChartConfig | ForestPlotConfig | AllChartsConfig
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ChartConfig } from './ChartConfig'
|
|
2
2
|
import { PickD3Scale } from '@visx/scale'
|
|
3
3
|
import { type SharedFilter } from '@cdc/dashboard/src/types/SharedFilter'
|
|
4
|
+
import { type Annotation } from '@cdc/core/types/Annotation'
|
|
5
|
+
import { DimensionsType } from '@cdc/core/types/Dimensions'
|
|
4
6
|
|
|
5
7
|
export type ColorScale = PickD3Scale<'ordinal', any, any>
|
|
6
8
|
|
|
@@ -15,21 +17,28 @@ type SharedChartContext = {
|
|
|
15
17
|
handleChartAriaLabels: (config: any) => string
|
|
16
18
|
colorScale?: ColorScale
|
|
17
19
|
config: ChartConfig
|
|
18
|
-
currentViewport?:
|
|
20
|
+
currentViewport?: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
|
|
19
21
|
highlight?: Function
|
|
20
22
|
highlightReset?: Function
|
|
21
23
|
legendIsolateValues?: string[]
|
|
22
24
|
setLegendIsolateValues?: Function
|
|
23
|
-
getTextWidth?: () => string
|
|
25
|
+
getTextWidth?: (a: string, b: string) => string
|
|
24
26
|
brushConfig: { data: []; isBrushing: boolean; isActive: boolean }
|
|
25
27
|
setBrushConfig: Function
|
|
26
28
|
clean: Function
|
|
27
29
|
capitalize: (value: string) => string
|
|
30
|
+
// whether or not the legend is appearing below the chart
|
|
31
|
+
isLegendBottom?: boolean
|
|
32
|
+
// whether or not the chart is viewed within the editor screen
|
|
33
|
+
isEditor?: boolean
|
|
34
|
+
// whether or not the user is dragging an annotation
|
|
35
|
+
isDraggingAnnotation?: boolean
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
// Line Chart Specific Context
|
|
31
39
|
type LineChartContext = SharedChartContext & {
|
|
32
|
-
|
|
40
|
+
convertLineToBarGraph: boolean
|
|
41
|
+
dimensions: DimensionsType
|
|
33
42
|
formatDate: Function
|
|
34
43
|
formatTooltipsDate: Function
|
|
35
44
|
formatNumber: Function
|
|
@@ -50,7 +59,8 @@ type LineChartContext = SharedChartContext & {
|
|
|
50
59
|
export type ChartContext =
|
|
51
60
|
| LineChartContext
|
|
52
61
|
| (SharedChartContext & {
|
|
53
|
-
|
|
62
|
+
annotations: Annotation[]
|
|
63
|
+
dimensions: DimensionsType
|
|
54
64
|
formatDate?: Function
|
|
55
65
|
formatTooltipsDate: Function
|
|
56
66
|
formatNumber?: Function
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { testZeroValue } from '../../src/components/BarChart/helpers'
|
|
2
|
+
|
|
3
|
+
describe('testZeroValue', () => {
|
|
4
|
+
test('returns true for "0" as string', () => {
|
|
5
|
+
expect(testZeroValue('0')).toBe(true)
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
test('returns true for "0" as number', () => {
|
|
9
|
+
expect(testZeroValue(0)).toBe(true)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('returns true for 0.0 as number', () => {
|
|
13
|
+
expect(testZeroValue(0.0)).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// check false case
|
|
17
|
+
test('returns false for "ABC" as string', () => {
|
|
18
|
+
expect(testZeroValue('ABC')).toBe(false)
|
|
19
|
+
})
|
|
20
|
+
test('returns false for 999 as number', () => {
|
|
21
|
+
expect(testZeroValue(999)).toBe(false)
|
|
22
|
+
})
|
|
23
|
+
// test for null & undefined cases
|
|
24
|
+
test('returns undefined for a null', () => {
|
|
25
|
+
expect(testZeroValue(null)).toBe(undefined)
|
|
26
|
+
})
|
|
27
|
+
test('returns undefined for a undefined', () => {
|
|
28
|
+
expect(testZeroValue(undefined)).toBe(undefined)
|
|
29
|
+
})
|
|
30
|
+
})
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|