Commit e420564
refactor(trends): extract buildDerivedConfigs + computeDashedFromIndex
Move the per-feature derived-config construction out of the four
`useMemo` blocks in TrendsLineChart.tsx and into a pure
buildDerivedConfigs(results, opts) helper in trendsChartTransforms.ts.
Component shrinks; the helper is testable without rendering.
New shared helper computeDashedFromIndex(r, opts) keeps the in-progress
dashed-tail boundary in one place — read by both buildMainTrendsSeries
(for stroke.partial.fromIndex) and buildDerivedConfigs (for the
trendline fitUpTo). Earlier they each computed it independently and
could drift.
buildMainTrendsSeries simplifies: it now returns Series<M> directly
instead of a BuiltTrendsSeries<M> wrapper, and stops dimming
compare-prev colours — the library's applyComparisonDimming pass picks
that up via the new comparisonOf entries that buildDerivedConfigs
emits. The wrapper shape only existed to feed the now-deleted
buildDerivedTrendsSeries.
TrendsLineChart polish:
- Hoist TOOLTIP_CONFIG to module scope; the chartConfig memo no longer
re-creates the tooltip object every render.
- Replace O(n²) indexOf-per-call in TrendsAlertOverlays' getYAxisId
callback with a precomputed Map lookup.
Tests:
- 25 new trendsChartTransforms.test.ts cases for buildDerivedConfigs
(composition, MA-trendline gating, fitUpTo derivation, compare-prev
mapping) and computeDashedFromIndex.
- buildTrendsYAxisConfig log10/showGrid/format-passthrough tests.
- schemaGoalLinesToConfigs null/empty/non-empty tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0e024ca commit e420564
5 files changed
Lines changed: 435 additions & 143 deletions
File tree
- frontend/src/scenes/trends/viz/trends-line-chart
Lines changed: 45 additions & 79 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 7 | + | |
17 | 8 | | |
18 | 9 | | |
19 | 10 | | |
| |||
33 | 24 | | |
34 | 25 | | |
35 | 26 | | |
36 | | - | |
| 27 | + | |
37 | 28 | | |
38 | 29 | | |
39 | 30 | | |
| |||
42 | 33 | | |
43 | 34 | | |
44 | 35 | | |
| 36 | + | |
| 37 | + | |
45 | 38 | | |
46 | 39 | | |
47 | 40 | | |
| |||
130 | 123 | | |
131 | 124 | | |
132 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
133 | 129 | | |
134 | 130 | | |
135 | 131 | | |
| |||
156 | 152 | | |
157 | 153 | | |
158 | 154 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
212 | 179 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 180 | | |
217 | 181 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 182 | + | |
221 | 183 | | |
222 | 184 | | |
223 | 185 | | |
224 | | - | |
225 | | - | |
226 | | - | |
| 186 | + | |
227 | 187 | | |
228 | 188 | | |
229 | | - | |
| 189 | + | |
230 | 190 | | |
231 | 191 | | |
232 | 192 | | |
233 | 193 | | |
234 | 194 | | |
235 | 195 | | |
236 | 196 | | |
237 | | - | |
238 | | - | |
239 | | - | |
| 197 | + | |
240 | 198 | | |
241 | 199 | | |
242 | 200 | | |
243 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
244 | 210 | | |
245 | 211 | | |
246 | | - | |
| 212 | + | |
247 | 213 | | |
248 | 214 | | |
249 | | - | |
| 215 | + | |
250 | 216 | | |
251 | 217 | | |
252 | 218 | | |
| |||
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
120 | 124 | | |
121 | 125 | | |
122 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
123 | 169 | | |
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 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 | + | |
0 commit comments