Commit c945047
committed
Consolidate functionality after weird charts
Chart file line counts (before → after):
- StackedBarChart: 243 → 198 (-45)
- GroupedBarChart: 241 → 196 (-45)
- PieChart: 226 → 181 (-45)
- DonutChart: 232 → 187 (-45)
- SwimlaneChart: 280 → 237 (-43)
- LikertChart: 669 → 432 (-237)
- BoxPlot: 204 → 184 (-20)
- ViolinPlot: 230 → 198 (-32)
- RidgelinePlot: 203 → 193 (-10, but gained forwardRef + push API)
- Histogram: 229 → 230 (+1, gained legendInteraction)
New shared files:
- useOrdinalStreaming.ts: 110 lines
- statsTooltip.tsx: 74 lines
- useLikertAggregation.ts: 257 lines
Net reduction across ordinal charts: ~567 lines removed, 441 lines added to shared =
~126 fewer total lines, but more importantly the code is now DRY and consistent.
Here's the complete summary of all 7 items:
#1 — useOrdinalStreaming hook: Extracted streaming legend + push API + margin merge
into shared hook. Used by 5 charts (StackedBar, GroupedBar, Pie, Donut, Swimlane). Each
lost ~45 lines of boilerplate.
#2 — buildStatsTooltip: Extracted shared stats tooltip for distribution charts.
BoxPlot, ViolinPlot, RidgelinePlot now all use the same function. ViolinPlot's fallback
computation from raw data is also shared via the valueAccessor option.
#3 — useLikertAggregation hook: Extracted all aggregation logic (aggregateData,
toDivergingValues, orderForDiverging, defaultDivergingScheme, resolveAccessorFn,
sentinels) into a dedicated hook. LikertChart dropped from 669 → 432 lines.
#4 — Selection hook fix: Changed activeSelectionHook → effectiveSelectionHook in
Histogram, ViolinPlot, and RidgelinePlot.
#5 — Naming standardization: Renamed actualColorBy → effectiveColorBy across all 6
charts that used it.
#6 — legendInteraction consistency: Added to Histogram, ViolinPlot, and RidgelinePlot
prop interfaces and wired to useChartSetup.
#7 — RidgelinePlot forwardRef: Converted to forwardRef with push API (push, pushMany,
clear, getData). Also made data optional for push mode consistency.1 parent 36f8b88 commit c945047
13 files changed
Lines changed: 586 additions & 656 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 137 | + | |
157 | 138 | | |
158 | 139 | | |
159 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 83 | | |
111 | 84 | | |
112 | 85 | | |
113 | | - | |
| 86 | + | |
114 | 87 | | |
115 | 88 | | |
116 | 89 | | |
117 | 90 | | |
118 | 91 | | |
119 | | - | |
| 92 | + | |
120 | 93 | | |
121 | 94 | | |
122 | 95 | | |
| |||
137 | 110 | | |
138 | 111 | | |
139 | 112 | | |
140 | | - | |
141 | | - | |
| 113 | + | |
| 114 | + | |
142 | 115 | | |
143 | 116 | | |
144 | 117 | | |
145 | 118 | | |
146 | | - | |
| 119 | + | |
147 | 120 | | |
148 | 121 | | |
149 | 122 | | |
| |||
166 | 139 | | |
167 | 140 | | |
168 | 141 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
193 | 149 | | |
194 | 150 | | |
195 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | 91 | | |
119 | 92 | | |
120 | 93 | | |
121 | | - | |
| 94 | + | |
122 | 95 | | |
123 | 96 | | |
124 | 97 | | |
125 | 98 | | |
126 | 99 | | |
127 | | - | |
| 100 | + | |
128 | 101 | | |
129 | 102 | | |
130 | 103 | | |
| |||
145 | 118 | | |
146 | 119 | | |
147 | 120 | | |
148 | | - | |
149 | | - | |
| 121 | + | |
| 122 | + | |
150 | 123 | | |
151 | 124 | | |
152 | 125 | | |
153 | 126 | | |
154 | | - | |
| 127 | + | |
155 | 128 | | |
156 | 129 | | |
157 | 130 | | |
| |||
172 | 145 | | |
173 | 146 | | |
174 | 147 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
199 | 155 | | |
200 | 156 | | |
201 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
107 | | - | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | | - | |
157 | | - | |
| 158 | + | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
0 commit comments