@cdc/chart 4.24.1 → 4.24.3
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 +48948 -37923
- package/examples/{private/combo.json → chart-regression-1.json} +40 -31
- package/examples/chart-regression-2.json +2360 -0
- package/examples/feature/filters/url-filter.json +1076 -0
- package/examples/feature/line/line-chart-preliminary.json +84 -37
- package/examples/feature/line/line-chart.json +2 -1
- package/examples/feature/regions/index.json +55 -5
- package/examples/feature/sankey/sankey-example-data.json +1364 -0
- package/examples/feature/sankey/sankey_chart_data.csv +20 -0
- package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +306 -19
- package/examples/sparkline.json +868 -0
- package/index.html +128 -121
- package/package.json +4 -2
- package/src/CdcChart.tsx +73 -38
- package/src/_stories/ChartEditor.stories.tsx +15 -4
- package/src/_stories/_mock/pie_config.json +4 -3
- package/src/_stories/_mock/url_filter.json +1076 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +2 -1
- package/src/components/AreaChart/components/AreaChart.jsx +2 -25
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +39 -49
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +36 -56
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +36 -41
- package/src/components/BarChart/components/BarChart.Vertical.tsx +48 -64
- package/src/components/BoxPlot/BoxPlot.jsx +11 -9
- package/src/components/DeviationBar.jsx +3 -3
- package/src/components/EditorPanel/EditorPanel.tsx +1717 -1961
- package/src/components/EditorPanel/EditorPanelContext.ts +40 -0
- package/src/components/EditorPanel/components/Panels/Panel.BoxPlot.tsx +148 -0
- package/src/components/EditorPanel/components/{Panel.ForestPlotSettings.tsx → Panels/Panel.ForestPlotSettings.tsx} +16 -7
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +160 -0
- package/src/components/EditorPanel/components/{Panel.Regions.tsx → Panels/Panel.Regions.tsx} +6 -6
- package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +108 -0
- package/src/components/EditorPanel/components/{Panel.Series.tsx → Panels/Panel.Series.tsx} +50 -6
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +338 -0
- package/src/components/EditorPanel/components/Panels/index.tsx +19 -0
- package/src/components/EditorPanel/components/panels.scss +11 -0
- package/src/components/EditorPanel/editor-panel.scss +1 -13
- package/src/components/EditorPanel/useEditorPermissions.js +44 -13
- package/src/components/Legend/Legend.Component.tsx +207 -0
- package/src/components/Legend/Legend.tsx +8 -327
- package/src/components/Legend/helpers/createFormatLabels.tsx +140 -0
- package/src/components/LineChart/LineChartProps.ts +2 -1
- package/src/components/LineChart/components/LineChart.Circle.tsx +85 -52
- package/src/components/LineChart/helpers.ts +3 -3
- package/src/components/LineChart/index.tsx +99 -23
- package/src/components/LinearChart.jsx +12 -33
- package/src/components/PairedBarChart.jsx +10 -12
- package/src/components/PieChart/PieChart.tsx +80 -27
- package/src/components/Regions/components/Regions.tsx +120 -69
- package/src/components/Sankey/index.tsx +434 -0
- package/src/components/Sankey/sankey.scss +153 -0
- package/src/components/Sankey/types/index.ts +16 -0
- package/src/components/ScatterPlot/ScatterPlot.jsx +1 -0
- package/src/components/Sparkline/{SparkLine.jsx → components/SparkLine.tsx} +14 -30
- package/src/components/Sparkline/index.scss +3 -0
- package/src/components/Sparkline/index.tsx +1 -1
- package/src/components/ZoomBrush.tsx +2 -1
- package/src/data/initial-state.js +51 -4
- package/src/helpers/computeMarginBottom.ts +4 -3
- package/src/helpers/tests/computeMarginBottom.test.ts +2 -1
- package/src/hooks/useBarChart.js +5 -2
- package/src/hooks/useHighlightedBars.js +1 -1
- package/src/hooks/useMinMax.ts +3 -3
- package/src/hooks/useScales.ts +28 -18
- package/src/hooks/useTooltip.tsx +19 -14
- package/src/scss/main.scss +8 -96
- package/src/types/ChartConfig.ts +47 -20
- package/src/types/ChartContext.ts +17 -4
- package/src/types/Label.ts +7 -0
- package/examples/private/chart-t.json +0 -3740
- package/examples/private/epi-data.csv +0 -13
- package/examples/private/epi-data.json +0 -62
- package/examples/private/epi.json +0 -403
- package/examples/private/occupancy.json +0 -109283
- package/examples/private/prod-line-config.json +0 -401
- package/examples/private/region-data.json +0 -822
- package/examples/private/region-testing.json +0 -312
- package/examples/private/scaling.json +0 -45325
- package/examples/private/testing-data.json +0 -1739
- package/examples/private/testing.json +0 -816
- package/src/components/EditorPanel/components/Panel.DateHighlighting.tsx +0 -109
- package/src/components/EditorPanel/components/Panels.tsx +0 -13
package/src/types/ChartConfig.ts
CHANGED
|
@@ -5,23 +5,16 @@ import { type Series } from '@cdc/core/types/Series'
|
|
|
5
5
|
import { Runtime } from '@cdc/core/types/Runtime'
|
|
6
6
|
import { FilterBehavior } from '@cdc/core/types/FilterBehavior'
|
|
7
7
|
import { Table } from '@cdc/core/types/Table'
|
|
8
|
+
import { BoxPlot } from '@cdc/core/types/BoxPlot'
|
|
9
|
+
import { General } from '@cdc/core/types/General'
|
|
10
|
+
import { type Link } from './../components/Sankey/types'
|
|
11
|
+
import { Legend } from '@cdc/core/types/Legend'
|
|
12
|
+
import { ConfidenceInterval } from '@cdc/core/types/ConfidenceInterval'
|
|
13
|
+
import { Region } from '@cdc/core/types/Region'
|
|
14
|
+
import { type PreliminaryDataItem } from '../components/LineChart/LineChartProps'
|
|
8
15
|
|
|
9
16
|
export type ChartColumns = Record<string, Column>
|
|
10
17
|
|
|
11
|
-
type Region = {
|
|
12
|
-
from: string
|
|
13
|
-
to: string
|
|
14
|
-
label: string
|
|
15
|
-
color: string
|
|
16
|
-
background: string
|
|
17
|
-
range: 'Custom' | string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type BoxPlot = {
|
|
21
|
-
firstQuartilePercentage: number
|
|
22
|
-
[key: string]: any
|
|
23
|
-
}
|
|
24
|
-
|
|
25
18
|
type DataFormat = {
|
|
26
19
|
abbreviated: boolean
|
|
27
20
|
bottomAbbreviated: boolean
|
|
@@ -47,6 +40,7 @@ type Exclusions = {
|
|
|
47
40
|
}
|
|
48
41
|
|
|
49
42
|
type Filter = {
|
|
43
|
+
active: string
|
|
50
44
|
type: 'url'
|
|
51
45
|
columnName: string
|
|
52
46
|
showDropdown: boolean
|
|
@@ -54,12 +48,15 @@ type Filter = {
|
|
|
54
48
|
label: string
|
|
55
49
|
order: 'asc' | 'desc' | 'cust'
|
|
56
50
|
values: string[]
|
|
51
|
+
queryParameter: string
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
export type Legend = {
|
|
55
|
+
seriesHighlight: string[]
|
|
60
56
|
additionalCategories: string[]
|
|
61
57
|
// general legend onClick behavior
|
|
62
58
|
behavior: 'highlight' | 'isolate' | string
|
|
59
|
+
axisAlign: boolean
|
|
63
60
|
colorCode: string
|
|
64
61
|
description: string
|
|
65
62
|
// show or hide the legend
|
|
@@ -86,9 +83,7 @@ type Visual = {
|
|
|
86
83
|
|
|
87
84
|
type AllChartsConfig = {
|
|
88
85
|
animate: boolean
|
|
89
|
-
general:
|
|
90
|
-
boxplot: BoxPlot
|
|
91
|
-
}
|
|
86
|
+
general: General
|
|
92
87
|
barHasBorder: 'true' | 'false'
|
|
93
88
|
barHeight: number
|
|
94
89
|
barSpace: number
|
|
@@ -100,11 +95,15 @@ type AllChartsConfig = {
|
|
|
100
95
|
height: number
|
|
101
96
|
}
|
|
102
97
|
chartMessage: { noData?: string }
|
|
98
|
+
color: string
|
|
103
99
|
colorMatchLineSeriesLabels: boolean
|
|
104
100
|
columns: ChartColumns
|
|
105
|
-
confidenceKeys:
|
|
101
|
+
confidenceKeys: ConfidenceInterval
|
|
102
|
+
customColors: string[]
|
|
106
103
|
data: Object[]
|
|
104
|
+
dataUrl: string
|
|
107
105
|
dataCutoff: number
|
|
106
|
+
dataDescription: string
|
|
108
107
|
dataFormat: DataFormat
|
|
109
108
|
dataKey: string
|
|
110
109
|
description: string
|
|
@@ -115,6 +114,7 @@ type AllChartsConfig = {
|
|
|
115
114
|
fontSize: 'small' | 'medium' | 'large'
|
|
116
115
|
footnotes: string
|
|
117
116
|
forestPlot: ForestPlotConfigSettings
|
|
117
|
+
formattedData: Object[] & { urlFiltered: boolean }
|
|
118
118
|
heights: {
|
|
119
119
|
vertical: number
|
|
120
120
|
}
|
|
@@ -135,11 +135,16 @@ type AllChartsConfig = {
|
|
|
135
135
|
orientation: 'vertical' | 'horizontal'
|
|
136
136
|
palette: string
|
|
137
137
|
pieType?: string
|
|
138
|
+
preliminaryData: PreliminaryDataItem[]
|
|
139
|
+
primary?: DataFormat
|
|
138
140
|
roundingStyle: string
|
|
139
141
|
runtime: Runtime
|
|
142
|
+
runtimeDataUrl: string
|
|
140
143
|
series: Series
|
|
141
144
|
showLineSeriesLabels: boolean
|
|
145
|
+
showSidebar: boolean
|
|
142
146
|
showTitle: boolean
|
|
147
|
+
sortData: 'ascending' | 'descending'
|
|
143
148
|
stackedAreaChartLineType: string
|
|
144
149
|
suppressedData?: { label: string; icon: string; value: string }[]
|
|
145
150
|
superTitle: string
|
|
@@ -150,19 +155,41 @@ type AllChartsConfig = {
|
|
|
150
155
|
tooltips: {
|
|
151
156
|
singleSeries: boolean
|
|
152
157
|
opacity: number
|
|
158
|
+
dateDisplayFormat: string
|
|
153
159
|
}
|
|
154
160
|
topAxis: { hasLine: boolean }
|
|
155
161
|
twoColor: { palette: string }
|
|
156
|
-
type:
|
|
162
|
+
type: 'chart' | 'dashboard'
|
|
157
163
|
useLogScale: boolean
|
|
158
164
|
visual: Visual
|
|
159
|
-
visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting'
|
|
165
|
+
visualizationType: 'Area Chart' | 'Bar' | 'Box Plot' | 'Deviation Bar' | 'Forest Plot' | 'Line' | 'Paired Bar' | 'Pie' | 'Scatter Plot' | 'Spark Line' | 'Combo' | 'Forecasting' | 'Sankey'
|
|
160
166
|
visualizationSubType: string
|
|
161
167
|
xAxis: Axis
|
|
162
168
|
yAxis: Axis
|
|
163
169
|
xScale: Function
|
|
164
170
|
yScale: Function
|
|
165
171
|
regions: Region[]
|
|
172
|
+
sankey: {
|
|
173
|
+
data: { links: Link[]; storyNodeText: Object[]; tooltips: Object[] }[]
|
|
174
|
+
nodePadding: number
|
|
175
|
+
iterations: number
|
|
176
|
+
nodeSize: {
|
|
177
|
+
nodeWidth: number
|
|
178
|
+
}
|
|
179
|
+
margin: { margin_x: number; margin_y: number }
|
|
180
|
+
nodeColor: { default: boolean; inactive: boolean }
|
|
181
|
+
opacity: { LinkOpacityInactive: string; LinkOpacityDefault: string; nodeOpacityInactive: boolean; nodeOpacityDefault: boolean }
|
|
182
|
+
rxValue: number
|
|
183
|
+
nodeFontColor: string
|
|
184
|
+
nodeValueStyle: {
|
|
185
|
+
textBefore: string
|
|
186
|
+
textAfter: string
|
|
187
|
+
}
|
|
188
|
+
linkColor: {
|
|
189
|
+
inactive: string
|
|
190
|
+
default: string
|
|
191
|
+
}
|
|
192
|
+
}
|
|
166
193
|
}
|
|
167
194
|
|
|
168
195
|
export type ForestPlotConfig = {
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
import { type ChartConfig } from './ChartConfig'
|
|
2
2
|
import { PickD3Scale } from '@visx/scale'
|
|
3
|
+
import { type SharedFilter } from '@cdc/dashboard/src/types/SharedFilter'
|
|
3
4
|
|
|
4
|
-
type ColorScale = PickD3Scale<'ordinal', any, any>
|
|
5
|
+
export type ColorScale = PickD3Scale<'ordinal', any, any>
|
|
5
6
|
|
|
6
|
-
type TransformedData = {
|
|
7
|
+
export type TransformedData = {
|
|
7
8
|
dataKey?: string
|
|
8
9
|
[key: string]: any
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
type SharedChartContext = {
|
|
13
|
+
animatedChart?: boolean
|
|
14
|
+
// process top level chart aria label for each chart type
|
|
15
|
+
handleChartAriaLabels: (config: any) => string
|
|
12
16
|
colorScale?: ColorScale
|
|
13
17
|
config: ChartConfig
|
|
14
18
|
currentViewport?: string
|
|
15
19
|
highlight?: Function
|
|
16
20
|
highlightReset?: Function
|
|
21
|
+
legendIsolateValues?: string[]
|
|
22
|
+
setLegendIsolateValues?: Function
|
|
23
|
+
getTextWidth?: () => string | number
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
// Line Chart Specific Context
|
|
20
27
|
type LineChartContext = SharedChartContext & {
|
|
21
28
|
dimensions: [screenWidth: number, screenHeight: number]
|
|
22
29
|
formatDate: Function
|
|
30
|
+
formatTooltipsDate: Function
|
|
23
31
|
formatNumber: Function
|
|
24
32
|
handleLineType: Function
|
|
25
33
|
isNumber: unknown
|
|
26
34
|
isDebug?: boolean
|
|
27
35
|
parseDate: Function
|
|
28
36
|
rawData: Object[]
|
|
29
|
-
seriesHighlight:
|
|
37
|
+
seriesHighlight: string[]
|
|
30
38
|
tableData: Object[]
|
|
31
39
|
transformedData: TransformedData[]
|
|
32
40
|
updateConfig: Function
|
|
33
41
|
visualizationType: 'Line'
|
|
42
|
+
colorPalettes: Record<string, string[]>
|
|
43
|
+
twoColorPalette: Record<string, string[]>
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
export type ChartContext =
|
|
@@ -38,6 +48,7 @@ export type ChartContext =
|
|
|
38
48
|
| (SharedChartContext & {
|
|
39
49
|
dimensions: [screenWidth: number, screenHeight: number]
|
|
40
50
|
formatDate?: Function
|
|
51
|
+
formatTooltipsDate: Function
|
|
41
52
|
formatNumber?: Function
|
|
42
53
|
handleLineType?: Function
|
|
43
54
|
isNumber?: boolean
|
|
@@ -45,10 +56,12 @@ export type ChartContext =
|
|
|
45
56
|
isDebug?: boolean
|
|
46
57
|
parseDate?: Function
|
|
47
58
|
rawData?: Object[]
|
|
48
|
-
seriesHighlight?:
|
|
59
|
+
seriesHighlight?: string[]
|
|
49
60
|
tableData?: Object[]
|
|
50
61
|
transformedData?: TransformedData[]
|
|
51
62
|
setSharedFilter?: Function
|
|
52
63
|
sharedFilterValue?: string
|
|
53
64
|
updateConfig?: Function
|
|
65
|
+
colorPalettes: any
|
|
66
|
+
twoColorPalette: any
|
|
54
67
|
})
|