@cdc/chart 4.24.2 → 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.
Files changed (57) hide show
  1. package/dist/cdcchart.js +47386 -36618
  2. package/examples/chart-regression-1.json +378 -0
  3. package/examples/chart-regression-2.json +2360 -0
  4. package/examples/feature/filters/url-filter.json +1076 -0
  5. package/examples/feature/line/line-chart.json +2 -1
  6. package/examples/feature/regions/index.json +50 -4
  7. package/examples/feature/sankey/sankey-example-data.json +1364 -0
  8. package/examples/feature/sankey/sankey_chart_data.csv +20 -0
  9. package/examples/gallery/bar-chart-vertical/vertical-bar-chart-stacked.json +306 -19
  10. package/examples/sparkline.json +868 -0
  11. package/index.html +128 -123
  12. package/package.json +4 -2
  13. package/src/CdcChart.tsx +40 -22
  14. package/src/_stories/ChartEditor.stories.tsx +14 -3
  15. package/src/_stories/_mock/url_filter.json +1076 -0
  16. package/src/components/AreaChart/components/AreaChart.Stacked.jsx +2 -1
  17. package/src/components/AreaChart/components/AreaChart.jsx +2 -1
  18. package/src/components/BarChart/components/BarChart.Horizontal.tsx +39 -49
  19. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +36 -56
  20. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +32 -39
  21. package/src/components/BarChart/components/BarChart.Vertical.tsx +40 -55
  22. package/src/components/BoxPlot/BoxPlot.jsx +2 -1
  23. package/src/components/DeviationBar.jsx +3 -3
  24. package/src/components/EditorPanel/EditorPanel.tsx +167 -15
  25. package/src/components/EditorPanel/components/Panels/Panel.Regions.tsx +1 -1
  26. package/src/components/EditorPanel/components/Panels/Panel.Sankey.tsx +108 -0
  27. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +48 -4
  28. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +41 -0
  29. package/src/components/EditorPanel/components/Panels/index.tsx +9 -7
  30. package/src/components/EditorPanel/components/panels.scss +11 -0
  31. package/src/components/EditorPanel/useEditorPermissions.js +40 -14
  32. package/src/components/Legend/Legend.Component.tsx +23 -15
  33. package/src/components/Legend/Legend.tsx +4 -4
  34. package/src/components/LineChart/LineChartProps.ts +1 -0
  35. package/src/components/LineChart/helpers.ts +2 -2
  36. package/src/components/LineChart/index.tsx +7 -7
  37. package/src/components/LinearChart.jsx +9 -30
  38. package/src/components/PairedBarChart.jsx +6 -10
  39. package/src/components/PieChart/PieChart.tsx +3 -3
  40. package/src/components/Regions/components/Regions.tsx +120 -78
  41. package/src/components/Sankey/index.tsx +434 -0
  42. package/src/components/Sankey/sankey.scss +153 -0
  43. package/src/components/Sankey/types/index.ts +16 -0
  44. package/src/components/ScatterPlot/ScatterPlot.jsx +1 -0
  45. package/src/components/Sparkline/{SparkLine.jsx → components/SparkLine.tsx} +14 -30
  46. package/src/components/Sparkline/index.scss +3 -0
  47. package/src/components/Sparkline/index.tsx +1 -1
  48. package/src/components/ZoomBrush.tsx +2 -1
  49. package/src/data/initial-state.js +46 -2
  50. package/src/helpers/computeMarginBottom.ts +2 -1
  51. package/src/helpers/tests/computeMarginBottom.test.ts +2 -1
  52. package/src/hooks/useBarChart.js +5 -2
  53. package/src/hooks/useScales.ts +15 -18
  54. package/src/hooks/useTooltip.tsx +9 -8
  55. package/src/scss/main.scss +8 -29
  56. package/src/types/ChartConfig.ts +32 -14
  57. package/src/types/ChartContext.ts +7 -0
@@ -7,20 +7,14 @@ import { FilterBehavior } from '@cdc/core/types/FilterBehavior'
7
7
  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
+ 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'
10
15
 
11
16
  export type ChartColumns = Record<string, Column>
12
17
 
13
- type Region = {
14
- from: string
15
- to: string
16
- fromType: 'Previous Days' | 'Fixed Date'
17
- toType: 'Last Date' | 'Fised Date'
18
- label: string
19
- color: string
20
- background: string
21
- range: 'Custom' | string
22
- }
23
-
24
18
  type DataFormat = {
25
19
  abbreviated: boolean
26
20
  bottomAbbreviated: boolean
@@ -58,9 +52,11 @@ type Filter = {
58
52
  }
59
53
 
60
54
  export type Legend = {
55
+ seriesHighlight: string[]
61
56
  additionalCategories: string[]
62
57
  // general legend onClick behavior
63
58
  behavior: 'highlight' | 'isolate' | string
59
+ axisAlign: boolean
64
60
  colorCode: string
65
61
  description: string
66
62
  // show or hide the legend
@@ -102,7 +98,7 @@ type AllChartsConfig = {
102
98
  color: string
103
99
  colorMatchLineSeriesLabels: boolean
104
100
  columns: ChartColumns
105
- confidenceKeys: Record<string, any>
101
+ confidenceKeys: ConfidenceInterval
106
102
  customColors: string[]
107
103
  data: Object[]
108
104
  dataUrl: string
@@ -139,6 +135,7 @@ type AllChartsConfig = {
139
135
  orientation: 'vertical' | 'horizontal'
140
136
  palette: string
141
137
  pieType?: string
138
+ preliminaryData: PreliminaryDataItem[]
142
139
  primary?: DataFormat
143
140
  roundingStyle: string
144
141
  runtime: Runtime
@@ -162,16 +159,37 @@ type AllChartsConfig = {
162
159
  }
163
160
  topAxis: { hasLine: boolean }
164
161
  twoColor: { palette: string }
165
- type: string
162
+ type: 'chart' | 'dashboard'
166
163
  useLogScale: boolean
167
164
  visual: Visual
168
- 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'
169
166
  visualizationSubType: string
170
167
  xAxis: Axis
171
168
  yAxis: Axis
172
169
  xScale: Function
173
170
  yScale: Function
174
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
+ }
175
193
  }
176
194
 
177
195
  export type ForestPlotConfig = {
@@ -1,5 +1,6 @@
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
5
  export type ColorScale = PickD3Scale<'ordinal', any, any>
5
6
 
@@ -9,11 +10,17 @@ export type TransformedData = {
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