diff --git a/src/views/DataBrowser/TradingViewChart.tsx b/src/views/DataBrowser/TradingViewChart.tsx index 598d3f06..336d0756 100644 --- a/src/views/DataBrowser/TradingViewChart.tsx +++ b/src/views/DataBrowser/TradingViewChart.tsx @@ -110,20 +110,25 @@ const TradingViewChart: React.FC = ({ timeVisible: true, secondsVisible: false, rightOffset: 12, - barSpacing: 3, + barSpacing: 6, // 增加条形间距,减少拥挤 fixLeftEdge: false, lockVisibleTimeRangeOnResize: true, rightBarStaysOnScroll: true, borderVisible: true, visible: true, + // 控制时间标签的最小间距(像素) + tickMarkMaxCharacterLength: 8, }, localization: { - timeFormatter: (time: any) => { - // 格式化时间显示 - const date = new Date(time * 1000); + locale: 'zh-CN', + // 自定义时间格式化,根据时间范围智能显示 + timeFormatter: (time) => { + const date = new Date(time); const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); const day = String(date.getDate()).padStart(2, '0'); + + // 只显示年-月-日,简洁明了 return `${year}-${month}-${day}`; }, }, @@ -174,9 +179,6 @@ const TradingViewChart: React.FC = ({ return timeA - timeB; }); - console.log('📊 转换后的图表数据(前3条):', chartData.slice(0, 3)); - console.log('📊 数据总数:', chartData.length); - // 设置数据 lineSeries.setData(chartData);