From 665f5e84160d017b36a02354fb045cad5c253018 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Thu, 20 Nov 2025 14:51:43 +0800 Subject: [PATCH] update pay function --- src/views/DataBrowser/TradingViewChart.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/views/DataBrowser/TradingViewChart.tsx b/src/views/DataBrowser/TradingViewChart.tsx index 43a774c9..88fd03d0 100644 --- a/src/views/DataBrowser/TradingViewChart.tsx +++ b/src/views/DataBrowser/TradingViewChart.tsx @@ -11,7 +11,7 @@ import { useColorMode, Tooltip, } from '@chakra-ui/react'; -import * as LightweightCharts from 'lightweight-charts'; +import { createChart, LineSeries } from 'lightweight-charts'; import type { IChartApi, ISeriesApi, LineData, Time } from 'lightweight-charts'; import { FaExpand, @@ -74,11 +74,11 @@ const TradingViewChart: React.FC = ({ try { // 调试信息 console.log('🔍 TradingView Chart - 开始初始化'); - console.log('📦 LightweightCharts 模块:', LightweightCharts); - console.log('📊 createChart 函数类型:', typeof LightweightCharts.createChart); + console.log('📊 createChart 函数类型:', typeof createChart); + console.log('📊 LineSeries 类型:', LineSeries); // 创建图表 (lightweight-charts 5.0 标准 API) - const chart = LightweightCharts.createChart(chartContainerRef.current, { + const chart = createChart(chartContainerRef.current, { width: chartContainerRef.current.clientWidth, height: 500, layout: { @@ -149,7 +149,8 @@ const TradingViewChart: React.FC = ({ } // 创建折线系列 (lightweight-charts 5.0 使用 addSeries 方法) - const lineSeries = chart.addSeries('Line', { + // 第一个参数是 series 类本身(不是实例) + const lineSeries = chart.addSeries(LineSeries, { color: themeColors.primary.gold, lineWidth: 2, crosshairMarkerVisible: true, @@ -209,8 +210,8 @@ const TradingViewChart: React.FC = ({ console.error('Error details:', { message: error.message, stack: error.stack, - LightweightChartsModule: LightweightCharts, - createChartType: typeof LightweightCharts.createChart, + createChartType: typeof createChart, + LineSeriesType: typeof LineSeries, }); // 重新抛出错误让 ErrorBoundary 捕获 throw error;