Ver Fonte

图表问题基本都修复了。

skyfffire há 3 dias atrás
pai
commit
d72f3e2ff2
1 ficheiros alterados com 59 adições e 1 exclusões
  1. 59 1
      src/leadlag/templates/dashboard.html

+ 59 - 1
src/leadlag/templates/dashboard.html

@@ -638,6 +638,9 @@
 
             // 创建BPS图表
             displayBpsChart(data);
+
+            // 同步两个图表的缩放
+            syncChartsZoom();
         }
         
         // 显示BPS图表
@@ -761,7 +764,62 @@
 
             bpsChart.setOption(option);
         }
-        
+
+        // 同步两个图表的缩放
+        function syncChartsZoom() {
+            if (!priceChart || !bpsChart) return;
+
+            // 监听价格图表的缩放事件
+            priceChart.on('datazoom', function(event) {
+                // 获取价格图表的缩放范围
+                const option = priceChart.getOption();
+                const dataZoom = option.dataZoom;
+
+                if (dataZoom && dataZoom.length > 0) {
+                    // 将缩放范围应用到BPS图表
+                    bpsChart.setOption({
+                        dataZoom: [
+                            {
+                                type: 'inside',
+                                start: dataZoom[0].start,
+                                end: dataZoom[0].end
+                            },
+                            {
+                                type: 'slider',
+                                start: dataZoom[0].start,
+                                end: dataZoom[0].end
+                            }
+                        ]
+                    });
+                }
+            });
+
+            // 监听BPS图表的缩放事件
+            bpsChart.on('datazoom', function(event) {
+                // 获取BPS图表的缩放范围
+                const option = bpsChart.getOption();
+                const dataZoom = option.dataZoom;
+
+                if (dataZoom && dataZoom.length > 0) {
+                    // 将缩放范围应用到价格图表
+                    priceChart.setOption({
+                        dataZoom: [
+                            {
+                                type: 'inside',
+                                start: dataZoom[0].start,
+                                end: dataZoom[0].end
+                            },
+                            {
+                                type: 'slider',
+                                start: dataZoom[0].start,
+                                end: dataZoom[0].end
+                            }
+                        ]
+                    });
+                }
+            });
+        }
+
         // 加载缩略图数据(24小时,只显示币安价格,每秒最多一条)
         async function loadThumbnailData(symbol) {
             try {