@cdc/chart 4.26.1 → 4.26.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 (173) hide show
  1. package/CLAUDE.local.md +79 -0
  2. package/LICENSE +201 -0
  3. package/dist/{cdcchart-dgT_1dIT.es.js → cdcchart-DQ00cQCm.es.js} +1 -20
  4. package/dist/cdcchart.js +54742 -49796
  5. package/examples/data/data-with-metadata.json +10 -0
  6. package/examples/default.json +378 -0
  7. package/examples/feature/__data__/horizon-chart-data.json +373 -0
  8. package/examples/feature/annotations/index.json +3 -6
  9. package/examples/feature/horizon/horizon-chart.json +395 -0
  10. package/examples/feature/pie/planet-pie-example-config.json +2 -1
  11. package/examples/line-chart-states.json +1085 -0
  12. package/examples/metadata-variables.json +58 -0
  13. package/examples/private/123.json +694 -0
  14. package/examples/private/anchor-issue.json +4094 -0
  15. package/examples/private/backwards-slider.json +10430 -0
  16. package/examples/private/georgia.csv +160 -0
  17. package/examples/private/timeline-data.json +1 -0
  18. package/examples/private/timeline.json +389 -0
  19. package/examples/radar-chart-simple.json +133 -0
  20. package/examples/radar-chart.json +148 -0
  21. package/index.html +1 -31
  22. package/package.json +57 -59
  23. package/src/CdcChart.tsx +8 -4
  24. package/src/CdcChartComponent.tsx +398 -284
  25. package/src/_stories/Chart.Anchors.stories.tsx +10 -0
  26. package/src/_stories/Chart.BoxPlot.stories.tsx +7 -0
  27. package/src/_stories/Chart.CI.stories.tsx +13 -0
  28. package/src/_stories/Chart.Combo.stories.tsx +17 -0
  29. package/src/_stories/Chart.CustomColors.stories.tsx +78 -0
  30. package/src/_stories/Chart.Defaults.stories.tsx +95 -0
  31. package/src/_stories/Chart.DynamicSeries.stories.tsx +19 -0
  32. package/src/_stories/Chart.Filters.stories.tsx +4 -0
  33. package/src/_stories/Chart.Forecast.stories.tsx +4 -0
  34. package/src/_stories/Chart.HTMLInDataTable.stories.tsx +22 -0
  35. package/src/_stories/Chart.Legend.Gradient.stories.tsx +28 -0
  36. package/src/_stories/Chart.Patterns.stories.tsx +4 -0
  37. package/src/_stories/Chart.PreserveDecimals.stories.tsx +25 -0
  38. package/src/_stories/Chart.Regions.Categorical.stories.tsx +13 -0
  39. package/src/_stories/Chart.Regions.DateScale.stories.tsx +19 -0
  40. package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +25 -10
  41. package/src/_stories/Chart.ScatterPlot.stories.tsx +4 -0
  42. package/src/_stories/Chart.SmallMultiples.stories.tsx +16 -0
  43. package/src/_stories/Chart.SmallestLeftAxisMax.stories.tsx +64 -0
  44. package/src/_stories/Chart.stories.tsx +72 -1
  45. package/src/_stories/Chart.tooltip.stories.tsx +7 -0
  46. package/src/_stories/ChartAnnotation.stories.tsx +10 -0
  47. package/src/_stories/ChartAxisLabels.stories.tsx +4 -0
  48. package/src/_stories/ChartAxisTitles.stories.tsx +10 -0
  49. package/src/_stories/ChartBar.Editor.stories.tsx +97 -38
  50. package/src/_stories/ChartBrush.Editor.stories.tsx +11 -25
  51. package/src/_stories/ChartBrush.Matrix.Continuous.stories.tsx +41 -0
  52. package/src/_stories/ChartBrush.Matrix.Date.stories.tsx +114 -0
  53. package/src/_stories/ChartBrush.Matrix.DateTime.stories.tsx +78 -0
  54. package/src/_stories/ChartBrush.stories.tsx +7 -0
  55. package/src/_stories/ChartEditor.Editor.stories.tsx +1 -1
  56. package/src/_stories/ChartEditor.stories.tsx +7 -0
  57. package/src/_stories/ChartLine.QuadrantAngles.stories.tsx +89 -0
  58. package/src/_stories/ChartLine.Suppression.stories.tsx +7 -0
  59. package/src/_stories/ChartLine.Symbols.stories.tsx +4 -0
  60. package/src/_stories/ChartPrefixSuffix.stories.tsx +46 -1
  61. package/src/_stories/TechAdoptionWithLinks.stories.tsx +7 -0
  62. package/src/_stories/_mock/brush_continuous.json +86 -0
  63. package/src/_stories/_mock/brush_date_large.json +176 -0
  64. package/src/_stories/_mock/line_chart_angle_near_zero_fall.json +195 -0
  65. package/src/_stories/_mock/line_chart_angle_near_zero_rise.json +195 -0
  66. package/src/_stories/_mock/line_chart_angle_q1_steep_upward.json +195 -0
  67. package/src/_stories/_mock/line_chart_angle_q2_gentle_downward.json +195 -0
  68. package/src/_stories/_mock/line_chart_angle_q3_steep_downward.json +195 -0
  69. package/src/_stories/_mock/line_chart_angle_q4_gentle_upward.json +195 -0
  70. package/src/_stories/_mock/line_chart_quadrant_angles.json +264 -0
  71. package/src/_stories/_mock/paired-bar-abbr.json +421 -0
  72. package/src/_stories/_mock/pie_custom_colors.json +268 -0
  73. package/src/_stories/_mock/smallest_left_axis_max.json +104 -0
  74. package/src/components/Annotations/components/AnnotationDraggable.styles.css +14 -20
  75. package/src/components/Annotations/components/AnnotationDraggable.tsx +240 -116
  76. package/src/components/Annotations/components/AnnotationDropdown.styles.css +1 -2
  77. package/src/components/Annotations/components/AnnotationDropdown.tsx +8 -12
  78. package/src/components/Annotations/components/AnnotationList.styles.css +12 -18
  79. package/src/components/Annotations/components/AnnotationList.tsx +5 -4
  80. package/src/components/Annotations/components/findNearestDatum.ts +75 -85
  81. package/src/components/Annotations/helpers/getVisibleAnnotations.ts +38 -0
  82. package/src/components/Axis/BottomAxis.tsx +277 -0
  83. package/src/components/Axis/LeftAxis.tsx +404 -0
  84. package/src/components/Axis/LeftAxisGridlines.tsx +77 -0
  85. package/src/components/Axis/PairedBarAxis.tsx +192 -0
  86. package/src/components/Axis/README.md +94 -0
  87. package/src/components/Axis/RightAxis.tsx +108 -0
  88. package/src/components/Axis/axis.constants.ts +21 -0
  89. package/src/components/Axis/index.ts +7 -0
  90. package/src/components/BarChart/components/BarChart.Horizontal.tsx +12 -28
  91. package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +12 -30
  92. package/src/components/BarChart/components/BarChart.StackedVertical.tsx +12 -31
  93. package/src/components/BarChart/components/BarChart.Vertical.tsx +12 -28
  94. package/src/components/BarChart/components/BarChart.tsx +7 -1
  95. package/src/components/BarChart/helpers/getPatternUrl.ts +94 -0
  96. package/src/components/BarChart/helpers/tests/getPatternUrl.test.ts +134 -0
  97. package/src/components/BarChart/helpers/useBarChart.ts +3 -0
  98. package/src/components/Brush/BrushSelector.tsx +155 -22
  99. package/src/components/Brush/MiniChartPreview.tsx +133 -21
  100. package/src/components/EditorPanel/EditorPanel.tsx +81 -54
  101. package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +67 -29
  102. package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +0 -78
  103. package/src/components/EditorPanel/components/Panels/Panel.General.tsx +120 -2
  104. package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +25 -43
  105. package/src/components/EditorPanel/components/Panels/Panel.Radar.tsx +353 -0
  106. package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +83 -3
  107. package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +66 -43
  108. package/src/components/EditorPanel/components/Panels/index.tsx +2 -0
  109. package/src/components/EditorPanel/editor-panel.scss +1 -1
  110. package/src/components/EditorPanel/useEditorPermissions.ts +55 -26
  111. package/src/components/ForestPlot/ForestPlot.tsx +26 -22
  112. package/src/components/HorizonChart/HorizonChart.tsx +131 -0
  113. package/src/components/HorizonChart/components/HorizonBand.tsx +160 -0
  114. package/src/components/HorizonChart/helpers/calculateHorizonBands.ts +27 -0
  115. package/src/components/HorizonChart/helpers/getHorizonLayerColors.ts +40 -0
  116. package/src/components/HorizonChart/index.tsx +3 -0
  117. package/src/components/Legend/Legend.Component.tsx +52 -4
  118. package/src/components/Legend/Legend.tsx +1 -1
  119. package/src/components/Legend/LegendGroup/LegendGroup.styles.css +4 -4
  120. package/src/components/Legend/LegendValueRange.tsx +77 -0
  121. package/src/components/Legend/helpers/createFormatLabels.tsx +16 -2
  122. package/src/components/Legend/helpers/generateValueRanges.ts +92 -0
  123. package/src/components/LineChart/helpers/README.md +292 -0
  124. package/src/components/LineChart/helpers/labelPositioning.test.ts +245 -0
  125. package/src/components/LineChart/helpers/labelPositioning.ts +304 -0
  126. package/src/components/LineChart/index.tsx +44 -8
  127. package/src/components/LinearChart/README.md +109 -0
  128. package/src/components/LinearChart/VisualizationRenderer.tsx +267 -0
  129. package/src/components/LinearChart/linearChart.constants.ts +84 -0
  130. package/src/components/LinearChart/tests/LinearChart.test.tsx +278 -0
  131. package/src/components/LinearChart/tests/mockConfigContext.ts +131 -0
  132. package/src/components/LinearChart/utils/tickFormatting.ts +146 -0
  133. package/src/components/LinearChart.tsx +268 -1057
  134. package/src/components/PieChart/PieChart.tsx +20 -5
  135. package/src/components/RadarChart/RadarAxis.tsx +78 -0
  136. package/src/components/RadarChart/RadarChart.tsx +298 -0
  137. package/src/components/RadarChart/RadarGrid.tsx +64 -0
  138. package/src/components/RadarChart/RadarPolygon.tsx +91 -0
  139. package/src/components/RadarChart/helpers.ts +83 -0
  140. package/src/components/RadarChart/index.tsx +3 -0
  141. package/src/components/Regions/components/Regions.tsx +6 -6
  142. package/src/components/Sankey/components/Sankey.tsx +3 -3
  143. package/src/components/Sankey/sankey.scss +1 -1
  144. package/src/components/SmallMultiples/SmallMultiples.css +5 -5
  145. package/src/components/Sparkline/index.scss +4 -2
  146. package/src/components/WarmingStripes/WarmingStripes.tsx +95 -25
  147. package/src/components/WarmingStripes/WarmingStripesGradientLegend.css +8 -8
  148. package/src/data/initial-state.js +37 -15
  149. package/src/data/legacy-defaults.ts +18 -0
  150. package/src/helpers/abbreviateNumber.ts +24 -17
  151. package/src/helpers/getChartPatternId.ts +17 -0
  152. package/src/helpers/getExcludedData.ts +4 -0
  153. package/src/helpers/getMinMax.ts +16 -2
  154. package/src/helpers/handleChartAriaLabels.ts +19 -19
  155. package/src/helpers/handleLineType.ts +22 -18
  156. package/src/helpers/seriesColumnSettings.ts +114 -0
  157. package/src/helpers/tests/countNumOfTicks.test.ts +77 -0
  158. package/src/helpers/tests/seriesColumnSettings.test.ts +84 -0
  159. package/src/hooks/useProgrammaticTooltip.ts +23 -2
  160. package/src/hooks/useRightAxis.ts +14 -0
  161. package/src/hooks/useScales.ts +99 -56
  162. package/src/hooks/useTooltip.tsx +23 -3
  163. package/src/scss/main.scss +157 -79
  164. package/src/selectors/README.md +68 -0
  165. package/src/store/chart.reducer.ts +2 -0
  166. package/src/test/CdcChart.test.jsx +2 -2
  167. package/src/types/ChartConfig.ts +22 -0
  168. package/src/types/ChartContext.ts +1 -0
  169. package/src/types/Horizon.ts +64 -0
  170. package/tests/fixtures/chart-config-with-metadata.json +29 -0
  171. package/tests/fixtures/data-with-metadata.json +10 -0
  172. package/preview.html +0 -1616
  173. package/src/components/Annotations/components/helpers/index.tsx +0 -46
@@ -0,0 +1,109 @@
1
+ # LinearChart
2
+
3
+ The main component for rendering linear visualizations (line charts, bar charts, area charts, etc.).
4
+
5
+ ## File Structure
6
+
7
+ ```
8
+ LinearChart/
9
+ ├── README.md # This file
10
+ ├── linearChart.constants.ts # Shared constants and visualization type definitions
11
+ ├── VisualizationRenderer.tsx # Renders the appropriate chart type
12
+ ├── utils/
13
+ │ └── tickFormatting.ts # Consolidated tick formatting logic (useTickFormatters hook)
14
+ └── tests/
15
+ ├── LinearChart.test.tsx # Component tests
16
+ └── mockConfigContext.ts # Test utilities
17
+ ```
18
+
19
+ ## Main Component
20
+
21
+ **File:** `../LinearChart.tsx` (parent directory)
22
+
23
+ The main LinearChart component orchestrates all the sub-components and handles:
24
+ - Scale calculations (via `useScales` hook)
25
+ - Tooltip management
26
+ - Brush/zoom functionality
27
+ - Animation state
28
+ - Small multiples delegation
29
+
30
+ ## Sub-Components
31
+
32
+ ### VisualizationRenderer
33
+ **File:** `VisualizationRenderer.tsx`
34
+
35
+ A switch component that renders the appropriate visualization based on `visualizationType`:
36
+ - Area Chart (stacked)
37
+ - Bar Chart
38
+ - Line Chart
39
+ - Combo Chart
40
+ - Scatter Plot
41
+ - Box Plot
42
+ - Deviation Bar
43
+ - Bump Chart
44
+ - Forest Plot
45
+ - Paired Bar
46
+ - Spark Line
47
+ - Warming Stripes
48
+
49
+ ### Tick Formatting
50
+ **File:** `utils/tickFormatting.ts`
51
+
52
+ The `useTickFormatters` hook provides consolidated tick formatting for both axes:
53
+ - `handleLeftTickFormatting` - Y-axis tick formatting
54
+ - `handleBottomTickFormatting` - X-axis tick formatting
55
+
56
+ Handles special cases:
57
+ - Logarithmic scales
58
+ - Forest plot data keys
59
+ - Date formatting
60
+ - Number abbreviation
61
+
62
+ ## Constants
63
+ **File:** `linearChart.constants.ts`
64
+
65
+ ```typescript
66
+ // Visualization type string constants
67
+ VISUALIZATION_TYPES
68
+
69
+ // Types that don't show grid lines
70
+ TYPES_WITHOUT_GRID: ['Spark Line', 'Forest Plot', 'Warming Stripes']
71
+
72
+ // Types excluded from standard line chart rendering
73
+ LINE_CHART_EXCLUDED_TYPES
74
+
75
+ // Types that show tooltip guide lines
76
+ TYPES_WITH_TOOLTIP_GUIDES
77
+ ```
78
+
79
+ ## Related Components
80
+
81
+ Axis components are in `../Axis/`:
82
+ - `LeftAxis` - Y-axis rendering
83
+ - `BottomAxis` - X-axis rendering
84
+ - `RightAxis` - Secondary Y-axis (dual-axis charts)
85
+ - `PairedBarAxis` - Specialized axis for paired bar charts
86
+
87
+ ## Context Dependencies
88
+
89
+ LinearChart uses `ConfigContext` for:
90
+ - `config` - Full chart configuration
91
+ - `formatDate`, `formatNumber` - Formatting functions
92
+ - `parseDate` - Date parsing
93
+ - `transformedData` - Processed chart data
94
+ - `currentViewport` - Responsive breakpoint
95
+
96
+ ## Testing
97
+
98
+ Run tests with:
99
+ ```bash
100
+ vitest packages/chart/src/components/LinearChart/tests/
101
+ ```
102
+
103
+ ## Refactoring History
104
+
105
+ This component was refactored from 1,704 lines to ~845 lines by extracting:
106
+ 1. Axis components to `../Axis/`
107
+ 2. VisualizationRenderer to handle chart type switching
108
+ 3. Tick formatting to `utils/tickFormatting.ts`
109
+ 4. Constants to `linearChart.constants.ts`
@@ -0,0 +1,267 @@
1
+ import React, { useContext } from 'react'
2
+ import ConfigContext from '../../ConfigContext'
3
+ import { VISUALIZATION_TYPES, LINE_CHART_EXCLUDED_TYPES } from './linearChart.constants'
4
+
5
+ // Visualization components
6
+ import { AreaChartStacked } from '../AreaChart'
7
+ import BarChart from '../BarChart'
8
+ import BoxPlotVertical from '../BoxPlot/BoxPlot.Vertical'
9
+ import BoxPlotHorizontal from '../BoxPlot/BoxPlot.Horizontal'
10
+ import DeviationBar from '../DeviationBar'
11
+ import Forecasting from '../Forecasting'
12
+ import ForestPlot from '../ForestPlot'
13
+ import { HorizonChart } from '../HorizonChart'
14
+ import LineChart from '../LineChart'
15
+ import PairedBarChart from '../PairedBarChart'
16
+ import ScatterPlot from '../ScatterPlot'
17
+ import WarmingStripes from '../WarmingStripes'
18
+
19
+ interface VisualizationRendererProps {
20
+ xScale: any
21
+ yScale: any
22
+ xMax: number
23
+ yMax: number
24
+ seriesScale: any
25
+ xScaleNoPadding: any
26
+ min: number
27
+ max: number
28
+ parentWidth: number
29
+ yAxisWidth: number
30
+ forestHeight: number
31
+ animatedChart: boolean
32
+ tooltipData: any
33
+ showTooltip: any
34
+ handleTooltipMouseOver: (e: any, additionalData?: any) => void
35
+ handleTooltipMouseOff: () => void
36
+ handleTooltipClick: (e: any) => void
37
+ getXAxisData: (d: any) => any
38
+ getYAxisData: (d: any, seriesKey: string) => any
39
+ svgRef: React.RefObject<any>
40
+ forestPlotRightLabelRef: React.RefObject<any>
41
+ synchronizedXValue?: any
42
+ }
43
+
44
+ const VisualizationRenderer: React.FC<VisualizationRendererProps> = ({
45
+ xScale,
46
+ yScale,
47
+ xMax,
48
+ yMax,
49
+ seriesScale,
50
+ xScaleNoPadding,
51
+ min,
52
+ max,
53
+ parentWidth,
54
+ yAxisWidth,
55
+ forestHeight,
56
+ animatedChart,
57
+ tooltipData,
58
+ showTooltip,
59
+ handleTooltipMouseOver,
60
+ handleTooltipMouseOff,
61
+ handleTooltipClick,
62
+ getXAxisData,
63
+ getYAxisData,
64
+ svgRef,
65
+ forestPlotRightLabelRef,
66
+ synchronizedXValue
67
+ }) => {
68
+ const { config, convertLineToBarGraph } = useContext(ConfigContext)
69
+ const { visualizationType, visualizationSubType } = config
70
+
71
+ return (
72
+ <>
73
+ {/* Deviation Bar */}
74
+ {visualizationType === 'Deviation Bar' && config.runtime.series?.length === 1 && (
75
+ <DeviationBar animatedChart={animatedChart} xScale={xScale} yScale={yScale} width={xMax} height={yMax} />
76
+ )}
77
+
78
+ {/* Paired Bar Chart */}
79
+ {visualizationType === 'Paired Bar' && <PairedBarChart originalWidth={parentWidth} width={xMax} height={yMax} />}
80
+
81
+ {/* Scatter Plot */}
82
+ {visualizationType === 'Scatter Plot' && (
83
+ <ScatterPlot
84
+ xScale={xScale}
85
+ yScale={yScale}
86
+ getXAxisData={getXAxisData}
87
+ getYAxisData={getYAxisData}
88
+ xMax={xMax}
89
+ yMax={yMax}
90
+ handleTooltipMouseOver={handleTooltipMouseOver}
91
+ handleTooltipMouseOff={handleTooltipMouseOff}
92
+ handleTooltipClick={handleTooltipClick}
93
+ tooltipData={tooltipData}
94
+ showTooltip={showTooltip}
95
+ />
96
+ )}
97
+
98
+ {/* Warming Stripes */}
99
+ {visualizationType === 'Warming Stripes' && (
100
+ <WarmingStripes
101
+ xScale={xScale}
102
+ yScale={yScale}
103
+ xMax={xMax}
104
+ yMax={yMax}
105
+ synchronizedXValue={synchronizedXValue}
106
+ showTooltip={showTooltip}
107
+ handleTooltipMouseOff={handleTooltipMouseOff}
108
+ />
109
+ )}
110
+
111
+ {/* Horizon Chart */}
112
+ {visualizationType === 'Horizon Chart' && (
113
+ <HorizonChart
114
+ xScale={xScale}
115
+ yScale={yScale}
116
+ xMax={xMax}
117
+ yMax={yMax}
118
+ handleTooltipMouseOver={handleTooltipMouseOver}
119
+ handleTooltipMouseOff={handleTooltipMouseOff}
120
+ tooltipData={tooltipData}
121
+ showTooltip={showTooltip}
122
+ />
123
+ )}
124
+
125
+ {/* Box Plot - Vertical */}
126
+ {visualizationType === 'Box Plot' && config.orientation === 'vertical' && (
127
+ <BoxPlotVertical
128
+ seriesScale={seriesScale}
129
+ xMax={xMax}
130
+ yMax={yMax}
131
+ min={min}
132
+ max={max}
133
+ xScale={xScale}
134
+ yScale={yScale}
135
+ />
136
+ )}
137
+
138
+ {/* Box Plot - Horizontal */}
139
+ {visualizationType === 'Box Plot' && config.orientation === 'horizontal' && (
140
+ <BoxPlotHorizontal
141
+ seriesScale={seriesScale}
142
+ xMax={xMax}
143
+ yMax={yMax}
144
+ min={min}
145
+ max={max}
146
+ xScale={xScale}
147
+ yScale={yScale}
148
+ />
149
+ )}
150
+
151
+ {/* Area Chart (Stacked) - also used by Combo */}
152
+ {((visualizationType === 'Area Chart' && visualizationSubType === 'stacked') ||
153
+ visualizationType === 'Combo') && (
154
+ <AreaChartStacked
155
+ xScale={xScale}
156
+ yScale={yScale}
157
+ yMax={yMax}
158
+ xMax={xMax}
159
+ chartRef={svgRef}
160
+ width={xMax}
161
+ height={yMax}
162
+ handleTooltipMouseOver={handleTooltipMouseOver}
163
+ handleTooltipMouseOff={handleTooltipMouseOff}
164
+ tooltipData={tooltipData}
165
+ showTooltip={showTooltip}
166
+ />
167
+ )}
168
+
169
+ {/* Bar Chart - also used by Combo and when line is converted to bar */}
170
+ {(visualizationType === 'Bar' || visualizationType === 'Combo' || convertLineToBarGraph) && (
171
+ <BarChart
172
+ xScale={xScale}
173
+ yScale={yScale}
174
+ seriesScale={seriesScale}
175
+ xMax={xMax}
176
+ yMax={yMax}
177
+ yAxisWidth={yAxisWidth}
178
+ getXAxisData={getXAxisData}
179
+ getYAxisData={getYAxisData}
180
+ animatedChart={animatedChart}
181
+ visible={animatedChart}
182
+ handleTooltipMouseOver={handleTooltipMouseOver}
183
+ handleTooltipMouseOff={handleTooltipMouseOff}
184
+ handleTooltipClick={handleTooltipClick}
185
+ tooltipData={tooltipData}
186
+ showTooltip={showTooltip}
187
+ chartRef={svgRef}
188
+ />
189
+ )}
190
+
191
+ {/* Line Chart for Combo and Bump Chart */}
192
+ {(visualizationType === 'Combo' || visualizationType === 'Bump Chart') && (
193
+ <LineChart
194
+ xScale={xScale}
195
+ yScale={yScale}
196
+ getXAxisData={getXAxisData}
197
+ getYAxisData={getYAxisData}
198
+ xMax={xMax}
199
+ yMax={yMax}
200
+ seriesStyle={config.runtime.series}
201
+ handleTooltipMouseOver={handleTooltipMouseOver}
202
+ handleTooltipMouseOff={handleTooltipMouseOff}
203
+ handleTooltipClick={handleTooltipClick}
204
+ tooltipData={tooltipData}
205
+ showTooltip={showTooltip}
206
+ />
207
+ )}
208
+
209
+ {/* Line Chart for other visualization types */}
210
+ {!LINE_CHART_EXCLUDED_TYPES.includes(visualizationType as any) && !convertLineToBarGraph && (
211
+ <LineChart
212
+ xScale={xScale}
213
+ yScale={yScale}
214
+ getXAxisData={getXAxisData}
215
+ getYAxisData={getYAxisData}
216
+ xMax={xMax}
217
+ yMax={yMax}
218
+ seriesStyle={config.runtime.series}
219
+ tooltipData={tooltipData}
220
+ handleTooltipMouseOver={handleTooltipMouseOver}
221
+ handleTooltipMouseOff={handleTooltipMouseOff}
222
+ />
223
+ )}
224
+
225
+ {/* Forecasting - also used by Combo */}
226
+ {(visualizationType === 'Forecasting' || visualizationType === 'Combo') && (
227
+ <Forecasting
228
+ showTooltip={showTooltip}
229
+ tooltipData={tooltipData}
230
+ xScale={xScale}
231
+ yScale={yScale}
232
+ width={xMax}
233
+ height={yMax}
234
+ xScaleNoPadding={xScaleNoPadding}
235
+ chartRef={svgRef}
236
+ handleTooltipMouseOver={handleTooltipMouseOver}
237
+ handleTooltipMouseOff={handleTooltipMouseOff}
238
+ />
239
+ )}
240
+
241
+ {/* Forest Plot */}
242
+ {visualizationType === 'Forest Plot' && (
243
+ <ForestPlot
244
+ xScale={xScale}
245
+ yScale={yScale}
246
+ seriesScale={seriesScale}
247
+ width={parentWidth}
248
+ height={forestHeight}
249
+ getXAxisData={getXAxisData}
250
+ getYAxisData={getYAxisData}
251
+ animatedChart={animatedChart}
252
+ visible={animatedChart}
253
+ handleTooltipMouseOver={handleTooltipMouseOver}
254
+ handleTooltipMouseOff={handleTooltipMouseOff}
255
+ handleTooltipClick={handleTooltipClick}
256
+ tooltipData={tooltipData}
257
+ showTooltip={showTooltip}
258
+ chartRef={svgRef}
259
+ config={config}
260
+ forestPlotRightLabelRef={forestPlotRightLabelRef}
261
+ />
262
+ )}
263
+ </>
264
+ )
265
+ }
266
+
267
+ export default VisualizationRenderer
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Visualization type constants for LinearChart
3
+ * Centralizes string literals to prevent typos and enable type safety
4
+ */
5
+
6
+ export const VISUALIZATION_TYPES = {
7
+ AREA_CHART: 'Area Chart',
8
+ BAR: 'Bar',
9
+ BOX_PLOT: 'Box Plot',
10
+ BUMP_CHART: 'Bump Chart',
11
+ COMBO: 'Combo',
12
+ DEVIATION_BAR: 'Deviation Bar',
13
+ FORECASTING: 'Forecasting',
14
+ FOREST_PLOT: 'Forest Plot',
15
+ HORIZON_CHART: 'Horizon Chart',
16
+ LINE: 'Line',
17
+ PAIRED_BAR: 'Paired Bar',
18
+ RADAR: 'Radar',
19
+ SCATTER_PLOT: 'Scatter Plot',
20
+ SPARK_LINE: 'Spark Line',
21
+ WARMING_STRIPES: 'Warming Stripes'
22
+ } as const
23
+
24
+ export type VisualizationType = (typeof VISUALIZATION_TYPES)[keyof typeof VISUALIZATION_TYPES]
25
+
26
+ /**
27
+ * Visualization types that don't display grid lines or standard axes
28
+ */
29
+ export const TYPES_WITHOUT_GRID = [
30
+ VISUALIZATION_TYPES.FOREST_PLOT,
31
+ VISUALIZATION_TYPES.HORIZON_CHART,
32
+ VISUALIZATION_TYPES.SPARK_LINE,
33
+ VISUALIZATION_TYPES.WARMING_STRIPES
34
+ ] as const
35
+
36
+ /**
37
+ * Visualization types excluded from the generic LineChart rendering
38
+ * These types have their own dedicated rendering logic
39
+ */
40
+ export const LINE_CHART_EXCLUDED_TYPES = [
41
+ VISUALIZATION_TYPES.AREA_CHART,
42
+ VISUALIZATION_TYPES.BAR,
43
+ VISUALIZATION_TYPES.BOX_PLOT,
44
+ VISUALIZATION_TYPES.DEVIATION_BAR,
45
+ VISUALIZATION_TYPES.FORECASTING,
46
+ VISUALIZATION_TYPES.HORIZON_CHART,
47
+ VISUALIZATION_TYPES.PAIRED_BAR,
48
+ VISUALIZATION_TYPES.SCATTER_PLOT,
49
+ VISUALIZATION_TYPES.WARMING_STRIPES
50
+ ] as const
51
+
52
+ /**
53
+ * Line-based visualization types (render with LineChart component)
54
+ */
55
+ export const LINE_BASED_TYPES = [
56
+ VISUALIZATION_TYPES.AREA_CHART,
57
+ VISUALIZATION_TYPES.BUMP_CHART,
58
+ VISUALIZATION_TYPES.COMBO,
59
+ VISUALIZATION_TYPES.LINE
60
+ ] as const
61
+
62
+ /**
63
+ * Visualization types that support tooltip guides (hover lines)
64
+ */
65
+ export const TYPES_WITH_TOOLTIP_GUIDES = [
66
+ VISUALIZATION_TYPES.AREA_CHART,
67
+ VISUALIZATION_TYPES.BAR,
68
+ VISUALIZATION_TYPES.COMBO,
69
+ VISUALIZATION_TYPES.LINE
70
+ ] as const
71
+
72
+ /**
73
+ * Check if a visualization type should show grid lines
74
+ */
75
+ export const shouldShowGrid = (visualizationType: string): boolean => {
76
+ return !TYPES_WITHOUT_GRID.includes(visualizationType as any)
77
+ }
78
+
79
+ /**
80
+ * Check if a visualization type uses the generic LineChart renderer
81
+ */
82
+ export const usesLineChartRenderer = (visualizationType: string): boolean => {
83
+ return !LINE_CHART_EXCLUDED_TYPES.includes(visualizationType as any)
84
+ }