Spaces:
Running
Running
thibaud frere
commited on
Commit
·
8bb224c
1
Parent(s):
db5abc7
modify symblink in public/data to be relative to the repo and not absolute; update filter quads chart
Browse files- app/public/data +1 -1
- app/src/content/embeds/filters-quad.html +45 -3
app/public/data
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
../src/content/assets/data
|
app/src/content/embeds/filters-quad.html
CHANGED
|
@@ -107,6 +107,8 @@
|
|
| 107 |
const xScale = d3.scaleLinear(); const yScale = d3.scaleLinear();
|
| 108 |
const lineGen = d3.line().x(d => xScale(d.step)).y(d => yScale(d.value));
|
| 109 |
let isRankStrictFlag = false; let rankTickMax = 1;
|
|
|
|
|
|
|
| 110 |
|
| 111 |
// Colors and markers (match original embeds)
|
| 112 |
const primary = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim() || '#E889AB';
|
|
@@ -183,7 +185,14 @@
|
|
| 183 |
runs.forEach(r => { (map[r]||[]).forEach(pt => { const v = isRankStrict ? Math.round(pt.value) : pt.value; minStep=Math.min(minStep,pt.step); maxStep=Math.max(maxStep,pt.step); maxVal=Math.max(maxVal,v); minVal=Math.min(minVal,v); }); });
|
| 184 |
if (!isFinite(minStep) || !isFinite(maxStep)) return;
|
| 185 |
xScale.domain([minStep, maxStep]); if (isRank) { rankTickMax = Math.max(1, Math.round(maxVal)); yScale.domain([rankTickMax, 1]); } else { yScale.domain([minVal, maxVal]).nice(); }
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
const { innerWidth, innerHeight } = updateScales();
|
| 189 |
|
|
@@ -284,7 +293,21 @@
|
|
| 284 |
return {
|
| 285 |
ready,
|
| 286 |
getMetrics: () => metricList.slice(),
|
| 287 |
-
setMetric: (m) => { if (m) renderMetric(m); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
};
|
| 289 |
}
|
| 290 |
|
|
@@ -328,7 +351,26 @@
|
|
| 328 |
if (def) select.value = def;
|
| 329 |
label.appendChild(select); ctrl.appendChild(label);
|
| 330 |
|
| 331 |
-
const applyAll = (v) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
if (def) applyAll(def);
|
| 333 |
select.addEventListener('change', () => applyAll(select.value));
|
| 334 |
|
|
|
|
| 107 |
const xScale = d3.scaleLinear(); const yScale = d3.scaleLinear();
|
| 108 |
const lineGen = d3.line().x(d => xScale(d.step)).y(d => yScale(d.value));
|
| 109 |
let isRankStrictFlag = false; let rankTickMax = 1;
|
| 110 |
+
// Optional shared Y domain override (set from outside to sync the 4 charts)
|
| 111 |
+
let yDomainOverride = null; // { metricKey, domain:[min,max] | [max,1] for rank, isRankStrict, rankTickMax }
|
| 112 |
|
| 113 |
// Colors and markers (match original embeds)
|
| 114 |
const primary = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim() || '#E889AB';
|
|
|
|
| 185 |
runs.forEach(r => { (map[r]||[]).forEach(pt => { const v = isRankStrict ? Math.round(pt.value) : pt.value; minStep=Math.min(minStep,pt.step); maxStep=Math.max(maxStep,pt.step); maxVal=Math.max(maxVal,v); minVal=Math.min(minVal,v); }); });
|
| 186 |
if (!isFinite(minStep) || !isFinite(maxStep)) return;
|
| 187 |
xScale.domain([minStep, maxStep]); if (isRank) { rankTickMax = Math.max(1, Math.round(maxVal)); yScale.domain([rankTickMax, 1]); } else { yScale.domain([minVal, maxVal]).nice(); }
|
| 188 |
+
// Apply shared Y domain override if provided for this metric
|
| 189 |
+
if (yDomainOverride && yDomainOverride.metricKey === metricKey && Array.isArray(yDomainOverride.domain)) {
|
| 190 |
+
isRankStrictFlag = !!yDomainOverride.isRankStrict;
|
| 191 |
+
rankTickMax = yDomainOverride.rankTickMax != null ? yDomainOverride.rankTickMax : rankTickMax;
|
| 192 |
+
yScale.domain(yDomainOverride.domain);
|
| 193 |
+
} else {
|
| 194 |
+
isRankStrictFlag = isRankStrict;
|
| 195 |
+
}
|
| 196 |
|
| 197 |
const { innerWidth, innerHeight } = updateScales();
|
| 198 |
|
|
|
|
| 293 |
return {
|
| 294 |
ready,
|
| 295 |
getMetrics: () => metricList.slice(),
|
| 296 |
+
setMetric: (m) => { if (m) renderMetric(m); },
|
| 297 |
+
// Expose extent for a given metric so the host can compute a shared Y domain
|
| 298 |
+
getExtent: (metricKey) => {
|
| 299 |
+
const map = dataByMetric.get(metricKey) || {};
|
| 300 |
+
const runs = runOrder;
|
| 301 |
+
let maxVal = -Infinity, minVal = Infinity;
|
| 302 |
+
const isRank = /rank/i.test(metricKey); const isAverage = /average/i.test(metricKey); const isRankStrict = isRank && !isAverage;
|
| 303 |
+
runs.forEach(r => { (map[r]||[]).forEach(pt => { const v = isRankStrict ? Math.round(pt.value) : pt.value; if (isFinite(v)) { maxVal=Math.max(maxVal,v); minVal=Math.min(minVal,v); } }); });
|
| 304 |
+
if (!isFinite(minVal) || !isFinite(maxVal)) return null;
|
| 305 |
+
return { min: minVal, max: maxVal, isRankStrict };
|
| 306 |
+
},
|
| 307 |
+
// Allow host to set a shared Y domain override (persisted across resizes)
|
| 308 |
+
setYDomainOverride: (metricKey, domain, isRankStrict, sharedRankTickMax) => {
|
| 309 |
+
yDomainOverride = { metricKey, domain, isRankStrict: !!isRankStrict, rankTickMax: sharedRankTickMax };
|
| 310 |
+
}
|
| 311 |
};
|
| 312 |
}
|
| 313 |
|
|
|
|
| 351 |
if (def) select.value = def;
|
| 352 |
label.appendChild(select); ctrl.appendChild(label);
|
| 353 |
|
| 354 |
+
const applyAll = (v) => {
|
| 355 |
+
// Compute shared Y domain across all instances for selected metric
|
| 356 |
+
const isRank = /rank/i.test(v); const isAverage = /average/i.test(v); const isRankStrict = isRank && !isAverage;
|
| 357 |
+
const extents = instances.map(i => (i && typeof i.getExtent === 'function') ? i.getExtent(v) : null).filter(Boolean);
|
| 358 |
+
if (!extents.length) { instances.forEach(i => i && typeof i.setMetric === 'function' && i.setMetric(v)); return; }
|
| 359 |
+
let globalMin = Math.min(...extents.map(e => e.min));
|
| 360 |
+
let globalMax = Math.max(...extents.map(e => e.max));
|
| 361 |
+
let domain, rankTickMax;
|
| 362 |
+
if (isRankStrict) {
|
| 363 |
+
rankTickMax = Math.max(1, Math.round(globalMax));
|
| 364 |
+
domain = [rankTickMax, 1];
|
| 365 |
+
} else {
|
| 366 |
+
domain = [globalMin, globalMax];
|
| 367 |
+
}
|
| 368 |
+
// Apply override then render
|
| 369 |
+
instances.forEach(i => {
|
| 370 |
+
if (i && typeof i.setYDomainOverride === 'function') i.setYDomainOverride(v, domain, isRankStrict, rankTickMax);
|
| 371 |
+
if (i && typeof i.setMetric === 'function') i.setMetric(v);
|
| 372 |
+
});
|
| 373 |
+
};
|
| 374 |
if (def) applyAll(def);
|
| 375 |
select.addEventListener('change', () => applyAll(select.value));
|
| 376 |
|