Fix: Show UTC+1 time on chart and fix indicator redrawing
Changes: 1. UTC+1 Time Display - Updated formatDate() to add 1 hour offset for Central European Time (UTC+1) - Added timeFormatter to chart timeScale for x-axis labels - Both signal display and chart time axis now show UTC+1 time 2. Fix Indicator Redrawing - Added missing getActiveIndicators() call in drawIndicatorsOnChart - Fixed variable scope issue where activeIndicators wasn't defined - Ensures indicators are properly removed and recreated when new candles close
This commit is contained in:
@ -4,11 +4,13 @@ import { updateIndicatorCandles } from './indicators-panel-new.js';
|
|||||||
|
|
||||||
function formatDate(timestamp) {
|
function formatDate(timestamp) {
|
||||||
const date = new Date(timestamp);
|
const date = new Date(timestamp);
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
// Convert to UTC+1 (Central European Time)
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const utc1 = new Date(date.getTime() + (date.getTimezoneOffset() * 60000) + 3600000);
|
||||||
const year = String(date.getFullYear()).slice(-2);
|
const day = String(utc1.getDate()).padStart(2, '0');
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
const month = String(utc1.getMonth() + 1).padStart(2, '0');
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
const year = String(utc1.getFullYear()).slice(-2);
|
||||||
|
const hours = String(utc1.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(utc1.getMinutes()).padStart(2, '0');
|
||||||
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,12 +93,18 @@ constructor() {
|
|||||||
borderColor: '#363d4e',
|
borderColor: '#363d4e',
|
||||||
autoScale: true,
|
autoScale: true,
|
||||||
},
|
},
|
||||||
timeScale: {
|
timeScale: {
|
||||||
borderColor: '#363d4e',
|
borderColor: '#363d4e',
|
||||||
timeVisible: true,
|
timeVisible: true,
|
||||||
secondsVisible: false,
|
secondsVisible: false,
|
||||||
rightOffset: 12,
|
rightOffset: 12,
|
||||||
barSpacing: 10,
|
barSpacing: 10,
|
||||||
|
timeFormatter: (timestamp) => {
|
||||||
|
const date = new Date(timestamp);
|
||||||
|
// Convert to UTC+1 (Central European Time)
|
||||||
|
const utc1 = new Date(date.getTime() + (date.getTimezoneOffset() * 60000) + 3600000);
|
||||||
|
return `${String(utc1.getMonth() + 1).padStart(2, '0')}/${String(utc1.getDate()).padStart(2, '0')} ${String(utc1.getHours()).padStart(2, '0')}:${String(utc1.getMinutes()).padStart(2, '0')}`;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleScroll: {
|
handleScroll: {
|
||||||
vertTouchDrag: false,
|
vertTouchDrag: false,
|
||||||
|
|||||||
@ -864,9 +864,11 @@ export function drawIndicatorsOnChart() {
|
|||||||
const oldestDate = oldestTime ? new Date(oldestTime * 1000).toLocaleDateString() : 'N/A';
|
const oldestDate = oldestTime ? new Date(oldestTime * 1000).toLocaleDateString() : 'N/A';
|
||||||
const newestDate = newestTime ? new Date(newestTime * 1000).toLocaleDateString() : 'N/A';
|
const newestDate = newestTime ? new Date(newestTime * 1000).toLocaleDateString() : 'N/A';
|
||||||
|
|
||||||
console.log(`[Indicators] ========== Redrawing ==========`);
|
console.log(`[Indicators] ========== Redrawing ==========`);
|
||||||
console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
console.log(`[Indicators] Candles: ${candles.length} | Time range: ${oldestDate} (${oldestTime}) to ${newestDate} (${newestTime})`);
|
||||||
|
|
||||||
|
const activeIndicators = getActiveIndicators();
|
||||||
|
|
||||||
// Remove all existing series
|
// Remove all existing series
|
||||||
activeIndicators.forEach(ind => {
|
activeIndicators.forEach(ind => {
|
||||||
ind.series?.forEach(s => {
|
ind.series?.forEach(s => {
|
||||||
|
|||||||
Reference in New Issue
Block a user