Web 加上资金面/情绪叠图,并收紧默认图面。

默认主/次/次次改为 45m/15m/5m、开始时间一周;SD/CD 按 hist 摆位置和箭头;去掉笔线段背驰与第四类勾选。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-09-12 02:25:44 +08:00
co-authored by Cursor
parent b301ad22c9
commit c22cd48f36
24 changed files with 1200 additions and 306 deletions
+19 -2
View File
@@ -22,6 +22,8 @@ function chartTvFinalize(ctx) {
var atrChart = ctx.atrChart;
var macdChart = ctx.macdChart;
var chanMacdChart = ctx.chanMacdChart;
var sentimentChart = ctx.sentimentChart;
var sentimentChartContainer = ctx.sentimentChartContainer;
var createChartOptions = ctx.createChartOptions;
// 同步所有图表的时间轴配置
const hasPendingRestoreView = !!window._pendingRestoreView;
@@ -55,6 +57,9 @@ function chartTvFinalize(ctx) {
if (showMacd && macdChart) {
macdChart.timeScale().applyOptions(baseOptions);
}
if (sentimentChart) {
sentimentChart.timeScale().applyOptions(baseOptions);
}
};
// 首先同步时间轴设置
@@ -65,7 +70,8 @@ function chartTvFinalize(ctx) {
const visibleBarsCount = 200;
const allChartsNow = [mainChart, volumeChart, atrChart]
.concat(showMacd && macdChart ? [macdChart] : [])
.concat(showMacd && chanMacdChart ? [chanMacdChart] : []);
.concat(showMacd && chanMacdChart ? [chanMacdChart] : [])
.concat(sentimentChart ? [sentimentChart] : []);
const restoreOpts = function () {
const firstT = candles && candles.length ? candles[0].time : null;
const lastT = candles && candles.length ? candles[candles.length - 1].time : null;
@@ -103,6 +109,9 @@ function chartTvFinalize(ctx) {
if (showMacd && chanMacdChart) {
chanMacdChart.timeScale().setVisibleLogicalRange(logRange);
}
if (sentimentChart) {
sentimentChart.timeScale().setVisibleLogicalRange(logRange);
}
}
return;
}
@@ -117,6 +126,9 @@ function chartTvFinalize(ctx) {
if (showMacd && chanMacdChart) {
chanMacdChart.timeScale().setVisibleLogicalRange(logRange);
}
if (sentimentChart) {
sentimentChart.timeScale().setVisibleLogicalRange(logRange);
}
console.log('🔧 时间轴同步完成');
}
}, 50);
@@ -127,6 +139,8 @@ function chartTvFinalize(ctx) {
tvWidget.atrChart = atrChart;
tvWidget.macdChart = macdChart;
tvWidget.chanMacdChart = chanMacdChart;
tvWidget.sentimentChart = sentimentChart;
tvWidget.sentimentChartContainer = sentimentChartContainer;
tvWidget.state.isInitialized = true;
// 注册窗口卸载时释放资源,避免GPU内存泄漏
window.onbeforeunload = function() {
@@ -137,6 +151,7 @@ function chartTvFinalize(ctx) {
if (tvWidget.macdChart && typeof tvWidget.macdChart.remove === 'function') tvWidget.macdChart.remove();
if (tvWidget.chanMacdChart && typeof tvWidget.chanMacdChart.remove === 'function') tvWidget.chanMacdChart.remove();
if (tvWidget.atrChart && typeof tvWidget.atrChart.remove === 'function') tvWidget.atrChart.remove();
if (tvWidget.sentimentChart && typeof tvWidget.sentimentChart.remove === 'function') tvWidget.sentimentChart.remove();
}
} catch (e) {}
};
@@ -220,6 +235,7 @@ function chartTvFinalize(ctx) {
const allCharts = [mainChart, volumeChart, atrChart];
if (showMacd && macdChart) allCharts.push(macdChart);
if (showMacd && chanMacdChart) allCharts.push(chanMacdChart);
if (sentimentChart) allCharts.push(sentimentChart);
// 检查是否有待恢复的视图(缩放 + 位置)
const pending = window._pendingRestoreView || pendingView;
@@ -243,7 +259,8 @@ function chartTvFinalize(ctx) {
console.log('🔧 最终同步可见范围:', visibleRange);
[volumeChart, atrChart].concat(
showMacd && macdChart ? [macdChart] : [],
showMacd && chanMacdChart ? [chanMacdChart] : []
showMacd && chanMacdChart ? [chanMacdChart] : [],
sentimentChart ? [sentimentChart] : []
).forEach(c => {
try { c.timeScale().setVisibleRange(visibleRange); } catch(e) {}
});