feat(visualizer): add build overlay toggle

Default is off so candles match production; enable via the new Build button when needed.
This commit is contained in:
u1
2026-01-09 02:05:37 +01:00
parent 9420c89f52
commit a9ccc0b00e
4 changed files with 51 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ type Props = {
ema20?: SeriesPoint[];
bb20?: { upper: SeriesPoint[]; lower: SeriesPoint[]; mid: SeriesPoint[] };
showIndicators: boolean;
showBuild: boolean;
bucketSeconds: number;
seriesKey: string;
fib?: FibRetracement | null;
@@ -116,6 +117,7 @@ export default function TradingChart({
ema20,
bb20,
showIndicators,
showBuild,
bucketSeconds,
seriesKey,
fib,
@@ -596,12 +598,29 @@ export default function TradingChart({
s.bbLower?.setData(bbLower);
s.bbMid?.setData(bbMid);
s.build.applyOptions({ visible: showBuild });
if (!showBuild) {
buildSamplesRef.current.clear();
buildKeyRef.current = seriesKey;
lastBuildCandleStartRef.current = null;
s.build.setData([]);
}
if (buildKeyRef.current !== seriesKey) {
buildSamplesRef.current.clear();
buildKeyRef.current = seriesKey;
lastBuildCandleStartRef.current = null;
}
if (!showBuild) {
s.sma20?.applyOptions({ visible: showIndicators });
s.ema20?.applyOptions({ visible: showIndicators });
s.bbUpper?.applyOptions({ visible: showIndicators });
s.bbLower?.applyOptions({ visible: showIndicators });
s.bbMid?.applyOptions({ visible: showIndicators });
return;
}
const bs = resolveBucketSeconds(bucketSeconds, candles);
const eps = 1e-3;
const maxPointsPerCandle = 600;
@@ -714,7 +733,21 @@ export default function TradingChart({
s.bbUpper?.applyOptions({ visible: showIndicators });
s.bbLower?.applyOptions({ visible: showIndicators });
s.bbMid?.applyOptions({ visible: showIndicators });
}, [candleData, volumeData, oracleData, smaData, emaData, bbUpper, bbLower, bbMid, showIndicators, candles, bucketSeconds, seriesKey]);
}, [
candleData,
volumeData,
oracleData,
smaData,
emaData,
bbUpper,
bbLower,
bbMid,
showIndicators,
showBuild,
candles,
bucketSeconds,
seriesKey,
]);
useEffect(() => {
const s = seriesRef.current;