fix: indicator panel overlap and performance optimizations

This commit is contained in:
DiTus
2026-03-20 22:32:00 +01:00
parent 0e8bf8e3bd
commit 62eeffaf1d
5 changed files with 110 additions and 101 deletions

View File

@ -136,6 +136,19 @@ function formatDate(timestamp) {
return TimezoneConfig.formatDate(timestamp);
}
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
export class TradingDashboard {
constructor() {
this.chart = null;
@ -157,6 +170,9 @@ constructor() {
this.dailyMAData = new Map(); // timestamp -> { ma44, ma125, price }
this.currentMouseTime = null;
// Throttled versions of heavy functions
this.throttledOnVisibleRangeChange = throttle(this.onVisibleRangeChange.bind(this), 150);
this.init();
}
@ -756,7 +772,6 @@ onVisibleRangeChange() {
console.log(`[VisibleRange] Chart data (${data.length}) vs dataset (${allData?.length || 0}) differ, redrawing indicators...`);
}
window.drawIndicatorsOnChart?.();
this.loadSignals().catch(e => console.error('Error loading signals:', e));
}