added centralized timezone config with UI selector in hamburger menu
This commit is contained in:
@ -1,15 +1,10 @@
|
||||
import { INTERVALS, COLORS } from '../core/index.js';
|
||||
import { calculateAllIndicatorSignals, calculateSummarySignal } from './signals-calculator.js';
|
||||
import { updateIndicatorCandles } from './indicators-panel-new.js';
|
||||
import { TimezoneConfig } from '../config/timezone.js';
|
||||
|
||||
function formatDate(timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||
const year = String(date.getUTCFullYear()).slice(-2);
|
||||
const hours = String(date.getUTCHours()).padStart(2, '0');
|
||||
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
||||
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
||||
return TimezoneConfig.formatDate(timestamp);
|
||||
}
|
||||
|
||||
export class TradingDashboard {
|
||||
@ -98,8 +93,7 @@ timeScale: {
|
||||
rightOffset: 12,
|
||||
barSpacing: 10,
|
||||
tickMarkFormatter: (time, tickMarkType, locale) => {
|
||||
const date = new Date((time + 3600) * 1000);
|
||||
return `${String(date.getUTCMonth() + 1).padStart(2, '0')}/${String(date.getUTCDate()).padStart(2, '0')} ${String(date.getUTCHours()).padStart(2, '0')}:${String(date.getUTCMinutes()).padStart(2, '0')}`;
|
||||
return TimezoneConfig.formatTickMark(time);
|
||||
},
|
||||
},
|
||||
handleScroll: {
|
||||
@ -419,7 +413,7 @@ async loadNewData() {
|
||||
const existingData = this.allData.get(this.currentInterval) || [];
|
||||
this.allData.set(this.currentInterval, this.mergeData(existingData, chartData));
|
||||
|
||||
console.log(`[NewData Load] Added ${chartData.length} new candles, total in dataset: ${this.allData.get(this.currentInterval).length}`);
|
||||
//console.log(`[NewData Load] Added ${chartData.length} new candles, total in dataset: ${this.allData.get(this.currentInterval).length}`);
|
||||
|
||||
if (atEdge) {
|
||||
this.chart.timeScale().scrollToRealTime();
|
||||
@ -427,7 +421,7 @@ async loadNewData() {
|
||||
|
||||
this.updateStats(latest);
|
||||
|
||||
console.log('[Chart] Calling drawIndicatorsOnChart after new data');
|
||||
//console.log('[Chart] Calling drawIndicatorsOnChart after new data');
|
||||
window.drawIndicatorsOnChart?.();
|
||||
window.updateIndicatorCandles?.();
|
||||
|
||||
|
||||
@ -854,22 +854,22 @@ export function drawIndicatorsOnChart() {
|
||||
const candles = window.dashboard?.allData?.get(currentInterval);
|
||||
|
||||
if (!candles || candles.length === 0) {
|
||||
console.log('[Indicators] No candles available');
|
||||
//console.log('[Indicators] No candles available');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[Indicators] ========== drawIndicatorsOnChart START ==========`);
|
||||
console.log(`[Indicators] Candles from allData: ${candles.length}`);
|
||||
console.log(`[Indicators] First candle time: ${candles[0]?.time} (${new Date(candles[0]?.time * 1000).toLocaleDateString()})`);
|
||||
console.log(`[Indicators] Last candle time: ${candles[candles.length - 1]?.time} (${new Date(candles[candles.length - 1]?.time * 1000).toLocaleDateString()})`);
|
||||
// console.log(`[Indicators] ========== drawIndicatorsOnChart START ==========`);
|
||||
// console.log(`[Indicators] Candles from allData: ${candles.length}`);
|
||||
// console.log(`[Indicators] First candle time: ${candles[0]?.time} (${new Date(candles[0]?.time * 1000).toLocaleDateString()})`);
|
||||
// console.log(`[Indicators] Last candle time: ${candles[candles.length - 1]?.time} (${new Date(candles[candles.length - 1]?.time * 1000).toLocaleDateString()})`);
|
||||
|
||||
const oldestTime = candles[0]?.time;
|
||||
const newestTime = candles[candles.length - 1]?.time;
|
||||
const oldestDate = oldestTime ? new Date(oldestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
const newestDate = newestTime ? new Date(newestTime * 1000).toLocaleDateString() : 'N/A';
|
||||
|
||||
console.log(`[Indicators] ========== Redrawing ==========`);
|
||||
console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
||||
//console.log(`[Indicators] ========== Redrawing ==========`);
|
||||
// console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
||||
|
||||
const activeIndicators = getActiveIndicators();
|
||||
|
||||
@ -929,14 +929,14 @@ export function drawIndicatorsOnChart() {
|
||||
|
||||
window.dashboard.chart.panes()[0]?.setHeight(mainPaneHeight);
|
||||
|
||||
console.log(`[Indicators] ========== Rendering Indicators ==========`);
|
||||
console.log(`[Indicators] Input candles: ${candles.length} | Panel count: ${totalPanes}`);
|
||||
//console.log(`[Indicators] ========== Rendering Indicators ==========`);
|
||||
//console.log(`[Indicators] Input candles: ${candles.length} | Panel count: ${totalPanes}`);
|
||||
|
||||
overlayIndicators.forEach(({ indicator, meta, instance }) => {
|
||||
console.log(`[Indicators] Processing overlay: ${indicator.name}`);
|
||||
console.log(`[Indicators] Before renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
//console.log(`[Indicators] Processing overlay: ${indicator.name}`);
|
||||
//console.log(`[Indicators] Before renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
renderIndicatorOnPane(indicator, meta, instance, candles, 0, lineStyleMap);
|
||||
console.log(`[Indicators] After renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
//console.log(`[Indicators] After renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
});
|
||||
|
||||
paneIndicators.forEach(({ indicator, meta, instance }, idx) => {
|
||||
@ -947,10 +947,10 @@ export function drawIndicatorsOnChart() {
|
||||
indicatorPanes.set(indicator.id, paneIndex);
|
||||
}
|
||||
|
||||
console.log(`[Indicators] Processing pane: ${indicator.name} (pane ${paneIndex})`);
|
||||
console.log(`[Indicators] Before renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
//console.log(`[Indicators] Processing pane: ${indicator.name} (pane ${paneIndex})`);
|
||||
//console.log(`[Indicators] Before renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
renderIndicatorOnPane(indicator, meta, instance, candles, paneIndex, lineStyleMap);
|
||||
console.log(`[Indicators] After renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
//console.log(`[Indicators] After renderIndicatorOnPane: indicator.cachedResults length = ${indicator.cachedResults?.length || 0}`);
|
||||
|
||||
const pane = window.dashboard.chart.panes()[paneIndex];
|
||||
if (pane) {
|
||||
@ -959,27 +959,10 @@ export function drawIndicatorsOnChart() {
|
||||
parseInt(localStorage.getItem(`pane_height_${indicator.type}`)) ||
|
||||
120;
|
||||
pane.setHeight(storedHeight);
|
||||
|
||||
// Subscribe to pane height changes to save to localStorage
|
||||
const originalHeight = storedHeight;
|
||||
const paneElement = pane.getHTMLElement && pane.getHTMLElement();
|
||||
if (paneElement) {
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
const newHeight = Math.round(entry.contentRect.height);
|
||||
if (newHeight !== originalHeight && newHeight > 50) {
|
||||
indicator.paneHeight = newHeight;
|
||||
localStorage.setItem(`pane_height_${indicator.type}`, newHeight);
|
||||
console.log(`[Indicators] Saved pane height for ${indicator.type}: ${newHeight}px`);
|
||||
}
|
||||
}
|
||||
});
|
||||
resizeObserver.observe(paneElement);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`[Indicators] ========== drawIndicatorsOnChart END ==========`);
|
||||
//console.log(`[Indicators] ========== drawIndicatorsOnChart END ==========`);
|
||||
} catch (error) {
|
||||
console.error('[Indicators] Error drawing indicators:', error);
|
||||
}
|
||||
|
||||
@ -173,16 +173,16 @@ export function calculateAllIndicatorSignals() {
|
||||
const activeIndicators = window.getActiveIndicators?.() || [];
|
||||
const candles = window.dashboard?.allData?.get(window.dashboard?.currentInterval);
|
||||
|
||||
console.log('[Signals] ========== calculateAllIndicatorSignals START ==========');
|
||||
//console.log('[Signals] ========== calculateAllIndicatorSignals START ==========');
|
||||
console.log('[Signals] Active indicators:', activeIndicators.length, 'Candles:', candles?.length || 0);
|
||||
|
||||
if (!candles || candles.length < 2) {
|
||||
console.log('[Signals] Insufficient candles available:', candles?.length || 0);
|
||||
//console.log('[Signals] Insufficient candles available:', candles?.length || 0);
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!activeIndicators || activeIndicators.length === 0) {
|
||||
console.log('[Signals] No active indicators');
|
||||
//console.log('[Signals] No active indicators');
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ export function calculateAllIndicatorSignals() {
|
||||
});
|
||||
}
|
||||
|
||||
console.log('[Signals] ========== calculateAllIndicatorSignals END ==========');
|
||||
//console.log('[Signals] ========== calculateAllIndicatorSignals END ==========');
|
||||
console.log('[Signals] Total signals calculated:', signals.length);
|
||||
return signals;
|
||||
}
|
||||
Reference in New Issue
Block a user