diff --git a/static/chart.js b/static/chart.js
index 7dd9ad3..b3dc33d 100644
--- a/static/chart.js
+++ b/static/chart.js
@@ -412,7 +412,7 @@ class ConfluenceChart {
this.bars = bars;
const candleData = bars.map(this.toCandle);
this.candles.setData(candleData);
- this.updateCurrentPrice(bars[bars.length - 1]?.c, false);
+ this.updateCurrentPrice(bars[bars.length - 1]?.c);
this.volume.setData(bars.map(ConfluenceChart.toVolume));
this.futureSpace.setData(this.futureTimes(bars));
// Anchored by time, not by logical index. A logical index addresses the
@@ -484,32 +484,35 @@ class ConfluenceChart {
this.renderComments();
}
- setCurrentPriceAnimation(enabled) { this.animateCurrentPrice = Boolean(enabled); }
+ 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);
+ }
- updateCurrentPrice(price, pulse = true) {
+ updateCurrentPrice(price) {
if (price == null) return;
const options = {
price,
color: '#b7771d',
- lineWidth: 3,
- lineStyle: LightweightCharts.LineStyle.Solid,
+ lineWidth: 1,
+ lineStyle: LightweightCharts.LineStyle.Dotted,
axisLabelVisible: true,
title: '',
};
if (this.currentPriceLine) this.currentPriceLine.applyOptions(options);
else this.currentPriceLine = this.candles.createPriceLine(options);
- const changed = this.lastCurrentPrice != null && price !== this.lastCurrentPrice;
this.lastCurrentPrice = price;
- if (!pulse || !changed || !this.animateCurrentPrice || !this.currentPricePulse) return;
+ if (!this.currentPricePulse) return;
requestAnimationFrame(() => {
const y = this.candles.priceToCoordinate(price);
if (y == null) return;
- this.currentPricePulse.hidden = false;
this.currentPricePulse.style.top = `${Math.round(y)}px`;
- this.currentPricePulse.classList.remove('active');
- void this.currentPricePulse.offsetWidth;
- this.currentPricePulse.classList.add('active');
+ this.currentPricePulse.hidden = !this.animateCurrentPrice;
+ this.currentPricePulse.classList.toggle('active', this.animateCurrentPrice);
});
}
diff --git a/static/index.html b/static/index.html
index 3156506..688d599 100644
--- a/static/index.html
+++ b/static/index.html
@@ -55,12 +55,12 @@
-