Refine pricing display and Gaussian context
This commit is contained in:
@@ -331,7 +331,7 @@ function TemperatureChartCanvasComponent({
|
||||
payload={props.payload as ReadonlyArray<{ payload?: Record<string, any> }> | undefined}
|
||||
data={zoomedData}
|
||||
series={activeSeries}
|
||||
probabilityOverlay={null}
|
||||
probabilityOverlay={probabilityOverlay}
|
||||
tempSymbol={tempSymbol}
|
||||
isEn={isEn}
|
||||
/>
|
||||
|
||||
@@ -123,10 +123,31 @@ function buildTooltipProbabilityRows(
|
||||
tempSymbol: string,
|
||||
isEn: boolean,
|
||||
): TooltipProbabilityRow[] {
|
||||
void probabilityOverlay;
|
||||
void tempSymbol;
|
||||
void isEn;
|
||||
return [];
|
||||
if (!probabilityOverlay) return [];
|
||||
const rows: TooltipProbabilityRow[] = [];
|
||||
const mu = validNumber(probabilityOverlay.muLine?.value);
|
||||
if (mu !== null) {
|
||||
rows.push({
|
||||
key: "legacy_probability_mu",
|
||||
label: isEn ? "Gaussian μ" : "高斯 μ",
|
||||
value: `${mu.toFixed(1)}${tempSymbol}`,
|
||||
color: "#8b5cf6",
|
||||
});
|
||||
}
|
||||
|
||||
const topBand = [...probabilityOverlay.bands]
|
||||
.filter((band) => validNumber(band.probability) !== null)
|
||||
.sort((a, b) => b.probability - a.probability)[0];
|
||||
if (topBand) {
|
||||
const probabilityPct = Math.round(topBand.probability * 100);
|
||||
rows.push({
|
||||
key: topBand.key,
|
||||
label: topBand.label,
|
||||
value: `${probabilityPct}%`,
|
||||
color: "#a78bfa",
|
||||
});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
export const __buildTemperatureTooltipRowsForTest = buildTooltipRows;
|
||||
|
||||
+7
-3
@@ -1660,7 +1660,7 @@ export function runTests() {
|
||||
const firstBand = bandPoints[0].runway_band;
|
||||
assert(Array.isArray(firstBand) && firstBand[0] === 24.0 && firstBand[1] === 26.0, "runway_band tuple values should match input limits");
|
||||
|
||||
// ── Legacy Gaussian probability data should not render as a visible chart overlay ──
|
||||
// ── Legacy Gaussian probability data should be available as compact tooltip context only ──
|
||||
const gaussianOverlayChart = __buildTemperatureChartDataForTest(
|
||||
{
|
||||
city: "toronto",
|
||||
@@ -1688,9 +1688,13 @@ export function runTests() {
|
||||
) as any;
|
||||
|
||||
const gaussianOverlay = gaussianOverlayChart.probabilityOverlay;
|
||||
assert(gaussianOverlay === null, "legacy Gaussian probabilities should not create visible chart overlays");
|
||||
assert(
|
||||
gaussianOverlay?.muLine?.label === "Gaussian μ 27.4°C" &&
|
||||
gaussianOverlay.bands.length === 3,
|
||||
"legacy Gaussian probabilities should remain available for compact tooltip context",
|
||||
);
|
||||
assert(
|
||||
!gaussianOverlayChart.series.some((series: any) => String(series.key || "").includes("probability")),
|
||||
"legacy Gaussian probability distribution should not be rendered as a time-series line",
|
||||
"legacy Gaussian probability distribution should not be rendered as a time-series line on the main chart",
|
||||
);
|
||||
}
|
||||
|
||||
+22
-2
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
readFileSync,
|
||||
} from "node:fs";
|
||||
import path from "node:path";
|
||||
import {
|
||||
__buildTemperatureTooltipProbabilityRowsForTest,
|
||||
__buildTemperatureTooltipRowsForTest,
|
||||
@@ -73,7 +77,23 @@ export function runTests() {
|
||||
);
|
||||
|
||||
assert(
|
||||
probabilityRows.length === 0,
|
||||
"temperature tooltip should not show Gaussian μ or probability-band rows",
|
||||
probabilityRows.length === 2,
|
||||
"temperature tooltip should show Gaussian μ and the leading probability bucket as compact context",
|
||||
);
|
||||
assert(
|
||||
probabilityRows.some((row) => row.key === "legacy_probability_mu" && row.value === "27.4°C") &&
|
||||
probabilityRows.some((row) => row.key === "legacy_probability_27_0" && row.value === "42%"),
|
||||
"temperature tooltip should format Gaussian μ and probability values without drawing a full probability band on the main chart",
|
||||
);
|
||||
|
||||
const projectRoot = process.cwd();
|
||||
const chartCanvasSource = readFileSync(
|
||||
path.join(projectRoot, "components", "dashboard", "scan-terminal", "TemperatureChartCanvas.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
assert(
|
||||
chartCanvasSource.includes("probabilityOverlay={probabilityOverlay}") &&
|
||||
!chartCanvasSource.includes("probabilityOverlay={null}"),
|
||||
"temperature chart canvas must pass probability overlay data into the tooltip instead of hiding Gaussian μ",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2179,9 +2179,9 @@ function buildFullDayChartData(
|
||||
return point;
|
||||
});
|
||||
|
||||
// Keep probability data in the payload for market views, but do not draw
|
||||
// legacy Gaussian bands on the live temperature chart.
|
||||
const probabilityOverlay = null;
|
||||
// Keep legacy Gaussian data as compact tooltip context. It is not rendered
|
||||
// as a time-series line on the live temperature chart.
|
||||
const probabilityOverlay = buildLegacyGaussianProbabilityOverlay(row, hourly);
|
||||
|
||||
return { data, series, probabilityOverlay };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user