@cdc/chart 4.24.9-1 → 4.24.10
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 +37673 -36530
- package/index.html +1 -1
- package/package.json +2 -2
- package/src/CdcChart.tsx +128 -106
- package/src/_stories/Chart.Legend.Gradient.stories.tsx +33 -0
- package/src/_stories/Chart.stories.tsx +28 -0
- package/src/_stories/ChartAxisLabels.stories.tsx +20 -0
- package/src/_stories/ChartAxisTitles.stories.tsx +53 -0
- package/src/_stories/ChartPrefixSuffix.stories.tsx +151 -0
- package/src/_stories/_mock/horizontal_bar.json +257 -0
- package/src/_stories/_mock/large_x_axis_labels.json +261 -0
- package/src/_stories/_mock/paired-bar.json +262 -0
- package/src/_stories/_mock/pie_with_data.json +255 -0
- package/src/_stories/_mock/simplified_line.json +1510 -0
- package/src/components/Annotations/components/AnnotationDraggable.tsx +0 -3
- package/src/components/Annotations/components/AnnotationDropdown.tsx +1 -1
- package/src/components/Axis/Categorical.Axis.tsx +22 -4
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +95 -16
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +41 -17
- package/src/components/BarChart/components/BarChart.Vertical.tsx +78 -20
- package/src/components/BarChart/helpers/index.ts +23 -4
- package/src/components/BrushChart.tsx +3 -2
- package/src/components/DeviationBar.jsx +58 -8
- package/src/components/EditorPanel/EditorPanel.tsx +62 -39
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +6 -23
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +21 -4
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +297 -35
- package/src/components/EditorPanel/components/panels.scss +4 -6
- package/src/components/EditorPanel/editor-panel.scss +0 -8
- package/src/components/EditorPanel/helpers/tests/updateFieldRankByValue.test.ts +38 -0
- package/src/components/EditorPanel/helpers/updateFieldRankByValue.ts +42 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +1 -0
- package/src/components/ForestPlot/ForestPlot.tsx +2 -3
- package/src/components/ForestPlot/ForestPlotProps.ts +2 -0
- package/src/components/Legend/Legend.Component.tsx +16 -16
- package/src/components/Legend/Legend.Suppression.tsx +25 -20
- package/src/components/Legend/Legend.tsx +0 -2
- package/src/components/Legend/helpers/index.ts +16 -19
- package/src/components/LegendWrapper.tsx +3 -1
- package/src/components/LinearChart.tsx +740 -562
- package/src/components/PairedBarChart.jsx +50 -10
- package/src/components/PieChart/PieChart.tsx +1 -6
- package/src/components/Regions/components/Regions.tsx +33 -19
- package/src/components/ZoomBrush.tsx +25 -6
- package/src/coreStyles_chart.scss +3 -0
- package/src/data/initial-state.js +6 -2
- package/src/helpers/configHelpers.ts +28 -0
- package/src/helpers/handleRankByValue.ts +15 -0
- package/src/helpers/sizeHelpers.ts +25 -0
- package/src/helpers/tests/handleRankByValue.test.ts +37 -0
- package/src/helpers/tests/sizeHelpers.test.ts +80 -0
- package/src/hooks/useColorPalette.js +10 -2
- package/src/hooks/useLegendClasses.ts +4 -0
- package/src/hooks/useScales.ts +31 -3
- package/src/hooks/useTooltip.tsx +9 -5
- package/src/index.jsx +1 -0
- package/src/scss/DataTable.scss +5 -4
- package/src/scss/main.scss +57 -52
- package/src/types/ChartConfig.ts +38 -16
- package/src/types/ChartContext.ts +18 -14
- package/src/_stories/Chart.Legend.Gradient.tsx +0 -19
- package/src/_stories/ChartBrush.stories.tsx +0 -19
package/src/index.jsx
CHANGED
package/src/scss/DataTable.scss
CHANGED
package/src/scss/main.scss
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
-
@
|
|
2
|
-
@
|
|
3
|
-
@
|
|
1
|
+
@mixin breakpoint($class) {
|
|
2
|
+
@if $class == xs {
|
|
3
|
+
@media (max-width: 767px) {
|
|
4
|
+
@content;
|
|
5
|
+
}
|
|
6
|
+
} @else if $class == sm {
|
|
7
|
+
@media (min-width: 768px) {
|
|
8
|
+
@content;
|
|
9
|
+
}
|
|
10
|
+
} @else if $class == md {
|
|
11
|
+
@media (min-width: 960px) {
|
|
12
|
+
@content;
|
|
13
|
+
}
|
|
14
|
+
} @else if $class == lg {
|
|
15
|
+
@media (min-width: 1300px) {
|
|
16
|
+
@content;
|
|
17
|
+
}
|
|
18
|
+
} @else {
|
|
19
|
+
@warn "Breakpoint mixin supports: xs, sm, md, lg";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@mixin breakpointClass($class) {
|
|
24
|
+
@if $class == xs {
|
|
25
|
+
&.xs,
|
|
26
|
+
&.xxs {
|
|
27
|
+
@content;
|
|
28
|
+
}
|
|
29
|
+
} @else if $class == sm {
|
|
30
|
+
&.sm,
|
|
31
|
+
&.md,
|
|
32
|
+
&.lg {
|
|
33
|
+
@content;
|
|
34
|
+
}
|
|
35
|
+
} @else if $class == md {
|
|
36
|
+
&.md,
|
|
37
|
+
&.lg {
|
|
38
|
+
@content;
|
|
39
|
+
}
|
|
40
|
+
} @else if $class == lg {
|
|
41
|
+
&.lg {
|
|
42
|
+
@content;
|
|
43
|
+
}
|
|
44
|
+
} @else {
|
|
45
|
+
@warn "Breakpoint Class mixin supports: xs, sm, md, lg";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
4
48
|
|
|
5
49
|
.form-container {
|
|
6
50
|
overflow-y: auto;
|
|
@@ -129,11 +173,12 @@
|
|
|
129
173
|
padding: 15px;
|
|
130
174
|
vertical-align: top;
|
|
131
175
|
text-align: left;
|
|
132
|
-
border: 1px solid
|
|
176
|
+
border: 1px solid var(--lightGray);
|
|
133
177
|
position: relative;
|
|
134
178
|
|
|
135
179
|
&.no-border {
|
|
136
180
|
border: 1px solid transparent;
|
|
181
|
+
padding: 0;
|
|
137
182
|
}
|
|
138
183
|
|
|
139
184
|
&__inner {
|
|
@@ -147,7 +192,7 @@
|
|
|
147
192
|
&.vertical-sorted {
|
|
148
193
|
display: block;
|
|
149
194
|
|
|
150
|
-
@include breakpoint(
|
|
195
|
+
@include breakpoint(sm) {
|
|
151
196
|
column-count: 2;
|
|
152
197
|
column-width: 100%;
|
|
153
198
|
}
|
|
@@ -177,10 +222,6 @@
|
|
|
177
222
|
white-space: pre-wrap;
|
|
178
223
|
word-break: break-word;
|
|
179
224
|
}
|
|
180
|
-
|
|
181
|
-
& > :first-child {
|
|
182
|
-
margin-top: 3px;
|
|
183
|
-
}
|
|
184
225
|
}
|
|
185
226
|
|
|
186
227
|
.vertical-sorted:not(.single-row) .legend-item {
|
|
@@ -199,11 +240,11 @@
|
|
|
199
240
|
|
|
200
241
|
h3,
|
|
201
242
|
p {
|
|
202
|
-
margin-bottom: 0.
|
|
243
|
+
margin-bottom: 0.4em;
|
|
203
244
|
}
|
|
204
245
|
|
|
205
246
|
& div.legend-item {
|
|
206
|
-
margin-bottom: 0.
|
|
247
|
+
margin-bottom: 0.2em !important;
|
|
207
248
|
|
|
208
249
|
&:last-child {
|
|
209
250
|
margin: 0 !important;
|
|
@@ -456,46 +497,6 @@
|
|
|
456
497
|
}
|
|
457
498
|
}
|
|
458
499
|
|
|
459
|
-
.filters-section {
|
|
460
|
-
margin-left: 1rem;
|
|
461
|
-
margin-right: 1rem;
|
|
462
|
-
|
|
463
|
-
&__title {
|
|
464
|
-
margin: 15px 0;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
&__wrapper {
|
|
468
|
-
hr {
|
|
469
|
-
margin-bottom: 20px;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
label {
|
|
473
|
-
display: inherit;
|
|
474
|
-
margin-bottom: 5px;
|
|
475
|
-
font-weight: 600;
|
|
476
|
-
font-size: 16px;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
@include breakpoint(md) {
|
|
481
|
-
display: flex;
|
|
482
|
-
gap: 30px;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
label:not(:empty) {
|
|
486
|
-
margin-right: 0.4em;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
select {
|
|
490
|
-
font-size: 1em;
|
|
491
|
-
padding-right: 5px;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
.single-filter {
|
|
495
|
-
margin-bottom: 0.5em;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
500
|
@include breakpointClass(xs) {
|
|
500
501
|
&.font-small {
|
|
501
502
|
font-size: 0.8em;
|
|
@@ -522,7 +523,7 @@
|
|
|
522
523
|
}
|
|
523
524
|
}
|
|
524
525
|
|
|
525
|
-
@include breakpointClass(
|
|
526
|
+
@include breakpointClass(sm) {
|
|
526
527
|
.chart-container {
|
|
527
528
|
.no-wrap {
|
|
528
529
|
flex-wrap: nowrap;
|
|
@@ -544,7 +545,11 @@
|
|
|
544
545
|
margin-left: 0;
|
|
545
546
|
}
|
|
546
547
|
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
547
550
|
|
|
551
|
+
@include breakpointClass(md) {
|
|
552
|
+
.chart-container {
|
|
548
553
|
> svg {
|
|
549
554
|
font-size: 16px;
|
|
550
555
|
width: 75%;
|
package/src/types/ChartConfig.ts
CHANGED
|
@@ -10,13 +10,27 @@ import { General } from '@cdc/core/types/General'
|
|
|
10
10
|
import { type Link } from './../components/Sankey/types'
|
|
11
11
|
import { ConfidenceInterval } from '@cdc/core/types/ConfidenceInterval'
|
|
12
12
|
import { Region } from '@cdc/core/types/Region'
|
|
13
|
-
|
|
14
13
|
import { VizFilter } from '@cdc/core/types/VizFilter'
|
|
15
14
|
import { type Annotation } from '@cdc/core/types/Annotation'
|
|
16
15
|
|
|
17
16
|
export type ViewportSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
|
|
18
17
|
export type ChartColumns = Record<string, Column>
|
|
19
|
-
|
|
18
|
+
export type ChartOrientation = 'vertical' | 'horizontal'
|
|
19
|
+
export type VisualizationType =
|
|
20
|
+
| 'Area Chart'
|
|
21
|
+
| 'Bar'
|
|
22
|
+
| 'Box Plot'
|
|
23
|
+
| 'Deviation Bar'
|
|
24
|
+
| 'Forest Plot'
|
|
25
|
+
| 'Line'
|
|
26
|
+
| 'Paired Bar'
|
|
27
|
+
| 'Pie'
|
|
28
|
+
| 'Scatter Plot'
|
|
29
|
+
| 'Spark Line'
|
|
30
|
+
| 'Combo'
|
|
31
|
+
| 'Forecasting'
|
|
32
|
+
| 'Sankey'
|
|
33
|
+
| 'Bump Chart'
|
|
20
34
|
export interface PreliminaryDataItem {
|
|
21
35
|
column: string
|
|
22
36
|
displayLegend: boolean
|
|
@@ -51,6 +65,7 @@ type DataFormat = {
|
|
|
51
65
|
rightSuffix: string
|
|
52
66
|
roundTo: number
|
|
53
67
|
suffix: string
|
|
68
|
+
onlyShowTopPrefixSuffix?: boolean
|
|
54
69
|
}
|
|
55
70
|
|
|
56
71
|
type Exclusions = {
|
|
@@ -77,14 +92,14 @@ export type Legend = {
|
|
|
77
92
|
singleRow: boolean
|
|
78
93
|
type: string
|
|
79
94
|
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
|
|
95
|
+
hideSuppressionLink: boolean
|
|
96
|
+
style: 'circles' | 'boxes' | 'gradient' | 'lines'
|
|
97
|
+
subStyle: 'linear blocks' | 'smooth'
|
|
98
|
+
hideSuppressedLabels: boolean
|
|
99
|
+
tickRotation: string
|
|
100
|
+
hideBorder: {
|
|
101
|
+
side: boolean
|
|
102
|
+
topBottom: boolean
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
|
|
@@ -105,7 +120,7 @@ export type AllChartsConfig = {
|
|
|
105
120
|
barHasBorder: 'true' | 'false'
|
|
106
121
|
barHeight: number
|
|
107
122
|
barSpace: number
|
|
108
|
-
barStyle: 'lollipop'|'rounded'|'flat'
|
|
123
|
+
barStyle: 'lollipop' | 'rounded' | 'flat'
|
|
109
124
|
barThickness: number
|
|
110
125
|
boxplot: BoxPlot
|
|
111
126
|
brush: {
|
|
@@ -135,6 +150,7 @@ export type AllChartsConfig = {
|
|
|
135
150
|
formattedData: Object[] & { urlFiltered: boolean }
|
|
136
151
|
heights: {
|
|
137
152
|
vertical: number
|
|
153
|
+
horizontal: number
|
|
138
154
|
mobileVertical: number
|
|
139
155
|
}
|
|
140
156
|
highlightedBarValues: { value: any; color: string; borderWidth: number; legendLabel: string }[]
|
|
@@ -151,11 +167,12 @@ export type AllChartsConfig = {
|
|
|
151
167
|
lollipopShape: string
|
|
152
168
|
lollipopSize: 'small' | 'medium' | 'large'
|
|
153
169
|
newViz: Object
|
|
154
|
-
orientation:
|
|
170
|
+
orientation: ChartOrientation
|
|
155
171
|
palette: string
|
|
156
172
|
pieType?: string
|
|
157
173
|
preliminaryData: PreliminaryDataItem[]
|
|
158
174
|
primary?: DataFormat
|
|
175
|
+
rankByValue: 'asc' | 'desc'
|
|
159
176
|
roundingStyle: string
|
|
160
177
|
runtime: Runtime
|
|
161
178
|
runtimeDataUrl: string
|
|
@@ -180,8 +197,9 @@ export type AllChartsConfig = {
|
|
|
180
197
|
twoColor: { palette: string }
|
|
181
198
|
type: 'chart' | 'dashboard'
|
|
182
199
|
uid: string | number
|
|
200
|
+
version: string
|
|
183
201
|
visual: Visual
|
|
184
|
-
visualizationType:
|
|
202
|
+
visualizationType: VisualizationType
|
|
185
203
|
visualizationSubType: string
|
|
186
204
|
xAxis: Axis
|
|
187
205
|
yAxis: Axis
|
|
@@ -197,7 +215,12 @@ export type AllChartsConfig = {
|
|
|
197
215
|
}
|
|
198
216
|
margin: { margin_x: number; margin_y: number }
|
|
199
217
|
nodeColor: { default: boolean; inactive: boolean }
|
|
200
|
-
opacity: {
|
|
218
|
+
opacity: {
|
|
219
|
+
LinkOpacityInactive: string
|
|
220
|
+
LinkOpacityDefault: string
|
|
221
|
+
nodeOpacityInactive: boolean
|
|
222
|
+
nodeOpacityDefault: boolean
|
|
223
|
+
}
|
|
201
224
|
rxValue: number
|
|
202
225
|
nodeFontColor: string
|
|
203
226
|
nodeValueStyle: {
|
|
@@ -257,9 +280,8 @@ export type SankeyChartConfig = {
|
|
|
257
280
|
source: SankeyLink
|
|
258
281
|
target: SankeyLink
|
|
259
282
|
value: number
|
|
260
|
-
}[]
|
|
283
|
+
}[]
|
|
261
284
|
storyNodeText: StoryNode[]
|
|
262
|
-
:
|
|
263
285
|
}
|
|
264
286
|
]
|
|
265
287
|
visualizationType: 'Sankey'
|
|
@@ -3,7 +3,7 @@ import { PickD3Scale } from '@visx/scale'
|
|
|
3
3
|
import { type SharedFilter } from '@cdc/dashboard/src/types/SharedFilter'
|
|
4
4
|
import { type Annotation } from '@cdc/core/types/Annotation'
|
|
5
5
|
import { DimensionsType } from '@cdc/core/types/Dimensions'
|
|
6
|
-
|
|
6
|
+
import { type DashboardConfig } from '@cdc/dashboard/src/types/DashboardConfig'
|
|
7
7
|
export type ColorScale = PickD3Scale<'ordinal', any, any>
|
|
8
8
|
|
|
9
9
|
export type TransformedData = {
|
|
@@ -13,26 +13,30 @@ export type TransformedData = {
|
|
|
13
13
|
|
|
14
14
|
type SharedChartContext = {
|
|
15
15
|
animatedChart?: boolean
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
brushConfig: { data: []; isBrushing: boolean; isActive: boolean }
|
|
17
|
+
capitalize: (value: string) => string
|
|
18
|
+
clean: Function
|
|
18
19
|
colorScale?: ColorScale
|
|
19
20
|
config: ChartConfig
|
|
20
21
|
currentViewport?: 'lg' | 'md' | 'sm' | 'xs' | 'xxs'
|
|
22
|
+
dashboardConfig?: DashboardConfig
|
|
23
|
+
// process top level chart aria label for each chart type
|
|
24
|
+
handleChartAriaLabels: (config: any) => string
|
|
25
|
+
handleDragStateChange: (isDragging: any) => void
|
|
21
26
|
highlight?: Function
|
|
22
27
|
highlightReset?: Function
|
|
23
|
-
legendIsolateValues?: string[]
|
|
24
|
-
setLegendIsolateValues?: Function
|
|
25
|
-
getTextWidth?: (a: string, b: string) => string
|
|
26
|
-
brushConfig: { data: []; isBrushing: boolean; isActive: boolean }
|
|
27
|
-
setBrushConfig: Function
|
|
28
|
-
clean: Function
|
|
29
|
-
capitalize: (value: string) => string
|
|
30
28
|
// whether or not the legend is appearing below the chart
|
|
31
29
|
isLegendBottom?: boolean
|
|
32
30
|
// whether or not the chart is viewed within the editor screen
|
|
33
31
|
isEditor?: boolean
|
|
34
32
|
// whether or not the user is dragging an annotation
|
|
35
33
|
isDraggingAnnotation?: boolean
|
|
34
|
+
legendIsolateValues?: string[]
|
|
35
|
+
legendRef?: React.RefObject<HTMLDivElement>
|
|
36
|
+
parentRef?: React.RefObject<HTMLDivElement>
|
|
37
|
+
setBrushConfig: Function
|
|
38
|
+
setLegendIsolateValues?: Function
|
|
39
|
+
svgRef?: React.RefObject<SVGSVGElement>
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
// Line Chart Specific Context
|
|
@@ -60,6 +64,7 @@ export type ChartContext =
|
|
|
60
64
|
| LineChartContext
|
|
61
65
|
| (SharedChartContext & {
|
|
62
66
|
annotations: Annotation[]
|
|
67
|
+
colorPalettes: any
|
|
63
68
|
dimensions: DimensionsType
|
|
64
69
|
formatDate?: Function
|
|
65
70
|
formatTooltipsDate: Function
|
|
@@ -71,11 +76,10 @@ export type ChartContext =
|
|
|
71
76
|
parseDate?: Function
|
|
72
77
|
rawData?: Object[]
|
|
73
78
|
seriesHighlight?: string[]
|
|
74
|
-
tableData?: Object[]
|
|
75
|
-
transformedData?: TransformedData[]
|
|
76
79
|
setSharedFilter?: Function
|
|
77
80
|
sharedFilterValue?: string
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
tableData?: Object[]
|
|
82
|
+
transformedData?: TransformedData[]
|
|
80
83
|
twoColorPalette: any
|
|
84
|
+
updateConfig?: Function
|
|
81
85
|
})
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
import chartGradientConfig from './_mock/legend.gradient_mock.json'
|
|
3
|
-
|
|
4
|
-
import Chart from '../CdcChart'
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Chart> = {
|
|
7
|
-
title: 'Components/Templates/Chart/Legend',
|
|
8
|
-
component: Chart
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type Story = StoryObj<typeof Chart>
|
|
12
|
-
|
|
13
|
-
export const Legend_gradient: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
config: chartGradientConfig
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default meta
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
import chartBrushConfig from './_mock/brush_mock.json'
|
|
3
|
-
|
|
4
|
-
import Chart from '../CdcChart'
|
|
5
|
-
|
|
6
|
-
const meta: Meta<typeof Chart> = {
|
|
7
|
-
title: 'Components/Templates/Chart/Brush',
|
|
8
|
-
component: Chart
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type Story = StoryObj<typeof Chart>
|
|
12
|
-
|
|
13
|
-
export const Area_Brush: Story = {
|
|
14
|
-
args: {
|
|
15
|
-
config: chartBrushConfig
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default meta
|