|
32 | 32 | let masterData = $state([]); |
33 | 33 | let xColumn = $state("step"); |
34 | 34 | let metrics = $state([]); |
| 35 | + let singlePointMetrics = $state(new Set()); |
35 | 36 | let xLim = $state(null); |
36 | 37 | let hasLoaded = $state(false); |
37 | 38 | let metricOrder = $state({}); |
|
115 | 116 | (c) => c !== xColumn && c !== "run" && c !== "data_type" && c !== "x_axis", |
116 | 117 | ); |
117 | 118 | metrics = cols; |
| 119 | +
|
| 120 | + const countPerRunMetric = new Map(); |
| 121 | + for (const r of originals) { |
| 122 | + const run = r.run; |
| 123 | + for (const col of cols) { |
| 124 | + if (r[col] == null) continue; |
| 125 | + const key = `${col}\0${run}`; |
| 126 | + countPerRunMetric.set(key, (countPerRunMetric.get(key) || 0) + 1); |
| 127 | + } |
| 128 | + } |
| 129 | + const sp = new Set(cols); |
| 130 | + for (const [key, count] of countPerRunMetric) { |
| 131 | + if (count > 1) { |
| 132 | + sp.delete(key.split("\0")[0]); |
| 133 | + } |
| 134 | + } |
| 135 | + singlePointMetrics = sp; |
118 | 136 | } |
119 | 137 |
|
120 | 138 | async function fetchNewRuns() { |
|
223 | 241 | return result.data; |
224 | 242 | } |
225 | 243 |
|
226 | | - function isSinglePoint(metric) { |
227 | | - const originals = masterData.filter( |
228 | | - (r) => (r.data_type === "original" || !r.data_type) && r[metric] != null, |
229 | | - ); |
230 | | - const countPerRun = new Map(); |
231 | | - for (const r of originals) { |
232 | | - const run = r.run; |
233 | | - countPerRun.set(run, (countPerRun.get(run) || 0) + 1); |
234 | | - } |
235 | | - if (countPerRun.size === 0) return false; |
236 | | - for (const count of countPerRun.values()) { |
237 | | - if (count > 1) return false; |
238 | | - } |
239 | | - return true; |
240 | | - } |
241 | 244 | </script> |
242 | 245 |
|
243 | 246 | <div class="metrics-page"> |
|
283 | 286 | <div class="plot-grid"> |
284 | 287 | {#each orderedDirect as metric, i} |
285 | 288 | {@const plotData = getPlotData(metric)} |
286 | | - {@const useBar = isSinglePoint(metric)} |
| 289 | + {@const useBar = singlePointMetrics.has(metric)} |
287 | 290 | {#if plotData.length > 0} |
288 | 291 | {#if useBar} |
289 | 292 | <BarPlot |
|
328 | 331 | <div class="plot-grid"> |
329 | 332 | {#each orderedSub as metric, i} |
330 | 333 | {@const plotData = getPlotData(metric)} |
331 | | - {@const useBar = isSinglePoint(metric)} |
| 334 | + {@const useBar = singlePointMetrics.has(metric)} |
332 | 335 | {#if plotData.length > 0} |
333 | 336 | {#if useBar} |
334 | 337 | <BarPlot |
|
0 commit comments