From 6e69b7337a0d609bd0908e1b75aaaf183b5828b6 Mon Sep 17 00:00:00 2001 From: Chris Amow Date: Thu, 20 Aug 2026 23:15:34 +0000 Subject: [PATCH] current bar fix and ma features --- static/app.js | 8 +++++++- static/chart.js | 32 +++++++++++++++++++++----------- static/index.html | 16 ++++++++++++---- static/style.css | 4 ++-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/static/app.js b/static/app.js index d366e92..0b16819 100644 --- a/static/app.js +++ b/static/app.js @@ -1205,6 +1205,12 @@ createApp({ return available.every(period => (prefs.value.enabled.ma[tf] || []).includes(period)); } + function maValue(period) { + const level = levels.value.find(item => item.kind === 'ma' && item.tf === '1d' && item.period === period); + const value = level?.anchor_p; + return value == null ? '—' : Number(value).toFixed(2); + } + function maAlertOn(period) { return (maAlerts.value['1d'] || []).includes(period); } @@ -1345,6 +1351,6 @@ createApp({ window.removeEventListener('keydown', handleKeydown); }); - return { status, price, sessionOpen, quoteChange, animateCurrentPrice, autoScrollLivePrice, extraDetail, barAge, dataUpdatedAt, buildStamp, timeframe, timeframes, drawingColors, drawingColorRows, drawingColorName, colorRowLabels, symbolChoices, selectedSymbol, symbolColor, symbolScale, symbolScales, symbolPanelOpen, prefs, clusters, clustersByPrice, events, eventsMore, loadOlderEvents, diagnosticMode, captureBusy, captureDiagnostic, armedTool, drawName, drawColor, drawWidth, drawSide, snap, selectedDrawing, selectedDrawings, drawingList, startDrawingListResize, manualLines, hasDrawingSelection, allShownSelected, selectedAreHidden, alertPrice, alertNote, alertEarlyPoints, levelColor, levelWidth, addPriceAlert, armTool, selectTimeframe, allEnabled, toggleGroup, maAlertOn, toggleMaAlert, deleteSelected, deleteLine, toggleDrawingSelection, toggleSelectAll, toggleSelectedVisibility, renameLine, updateLineStyle, updateLevelNumber, setArmed, commentText, commentFloat, comments, drawings, filteredDrawings, drawingFilter, drawingKind, drawingTf, deleteDrawing, toggleComment, togglePinned, chooseSymbol, toggleSymbolPanel, startSymbolDrag, dropSymbol, optionExpirations, optionExpiryId, optionSide, optionMode, optionMin, optionMax, optionContracts, optionUnderlying, optionBusy, optionError, optionSearched, optionCopied, onOptionsToggle, searchOptions, copyOption }; + return { status, price, sessionOpen, quoteChange, animateCurrentPrice, autoScrollLivePrice, extraDetail, barAge, dataUpdatedAt, buildStamp, timeframe, timeframes, drawingColors, drawingColorRows, drawingColorName, colorRowLabels, symbolChoices, selectedSymbol, symbolColor, symbolScale, symbolScales, symbolPanelOpen, prefs, clusters, clustersByPrice, events, eventsMore, loadOlderEvents, diagnosticMode, captureBusy, captureDiagnostic, armedTool, drawName, drawColor, drawWidth, drawSide, snap, selectedDrawing, selectedDrawings, drawingList, startDrawingListResize, manualLines, hasDrawingSelection, allShownSelected, selectedAreHidden, alertPrice, alertNote, alertEarlyPoints, levelColor, levelWidth, addPriceAlert, armTool, selectTimeframe, allEnabled, toggleGroup, maValue, maAlertOn, toggleMaAlert, deleteSelected, deleteLine, toggleDrawingSelection, toggleSelectAll, toggleSelectedVisibility, renameLine, updateLineStyle, updateLevelNumber, setArmed, commentText, commentFloat, comments, drawings, filteredDrawings, drawingFilter, drawingKind, drawingTf, deleteDrawing, toggleComment, togglePinned, chooseSymbol, toggleSymbolPanel, startSymbolDrag, dropSymbol, optionExpirations, optionExpiryId, optionSide, optionMode, optionMin, optionMax, optionContracts, optionUnderlying, optionBusy, optionError, optionSearched, optionCopied, onOptionsToggle, searchOptions, copyOption }; }, }).mount('#app'); diff --git a/static/chart.js b/static/chart.js index ba56035..143322c 100644 --- a/static/chart.js +++ b/static/chart.js @@ -646,6 +646,11 @@ class ConfluenceChart { this.chart.timeScale().subscribeVisibleLogicalRangeChange(() => { this.scheduleOverlays(); }); + this.scaleEndListener = () => { + requestAnimationFrame(() => this.syncCurrentPricePulse()); + }; + el.addEventListener('wheel', this.scaleEndListener, { passive: true }); + el.addEventListener('pointerup', this.scaleEndListener); this.installPinchZoom(); } @@ -847,10 +852,7 @@ class ConfluenceChart { setCurrentPriceAnimation(enabled) { this.animateCurrentPrice = Boolean(enabled); - if (!this.currentPricePulse) return; - const active = this.animateCurrentPrice && this.lastCurrentPrice != null; - this.currentPricePulse.hidden = !active; - this.currentPricePulse.classList.toggle('active', active); + this.syncCurrentPricePulse(); } setAutoScrollLivePrice(enabled) { @@ -881,14 +883,17 @@ class ConfluenceChart { else this.currentPriceLine = this.candles.createPriceLine(options); this.lastCurrentPrice = price; + this.syncCurrentPricePulse(); + } + + syncCurrentPricePulse() { if (!this.currentPricePulse) return; - requestAnimationFrame(() => { - const y = this.candles.priceToCoordinate(price); - if (y == null) return; - this.currentPricePulse.style.top = `${Math.round(y)}px`; - this.currentPricePulse.hidden = !this.animateCurrentPrice; - this.currentPricePulse.classList.toggle('active', this.animateCurrentPrice); - }); + const show = this.animateCurrentPrice && this.lastCurrentPrice != null; + this.currentPricePulse.hidden = !show; + this.currentPricePulse.classList.toggle('active', show); + if (!show || !this.candles || this.lastCurrentPrice == null) return; + const y = this.candles.priceToCoordinate(this.lastCurrentPrice); + if (y != null) this.currentPricePulse.style.top = `${Math.round(y)}px`; } setCommentHandlers({ onToggle, onMove, onSelect }) { @@ -1445,6 +1450,7 @@ class ConfluenceChart { this.renderProjectionDiagnostic(); this.renderComments(); this.renderContextLabels(); + this.syncCurrentPricePulse(); }); } @@ -2985,6 +2991,10 @@ class ConfluenceChart { clearTimeout(this.lineFocusTimer); clearTimeout(this.fibFocusTimer); for (const node of this.commentNodes.values()) clearTimeout(node.focusTimer); + if (this.chartEl && this.scaleEndListener) { + this.chartEl.removeEventListener('wheel', this.scaleEndListener); + this.chartEl.removeEventListener('pointerup', this.scaleEndListener); + } if (this.chartEl && this.clickListener) this.chartEl.removeEventListener('click', this.clickListener); if (this.chartEl && this.contextListener) this.chartEl.removeEventListener('contextmenu', this.contextListener); if (this.anchorMoveListener) window.removeEventListener('pointermove', this.anchorMoveListener); diff --git a/static/index.html b/static/index.html index 0bce863..14a23e6 100644 --- a/static/index.html +++ b/static/index.html @@ -42,10 +42,18 @@