Files
Chan/docs/ENGINEERING_SPEC/ECR-008-chart-tv-split.md
jackyu66gitandCursor dbb6202325 feat(ECR-008): 拆分主站 chart_tv.js 为多模块薄门面
行为冻结物理拆分;保留 initTradingView/dispose 对外 API;无打包器。node --check 全绿。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 15:09:48 +08:00

39 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ENGINEERING_SPEC — ECR-008 chart_tv 拆分
**ECR:** ECR-008
**Level:** L3 · 行为冻结
**Date:** 2026-08-07
## Goal
物理拆分主站 Lightweight Charts 绘制单体,不改变可见行为。
## Module map
| File | Responsibility |
|------|----------------|
| `chart_tv_lifecycle.js` | `disposeTradingViewCharts`cleanup 数组与 chart.remove |
| `chart_tv_shell.js` | `chartTvBuildShell(ctx)`:容器、createChart、K 线主系列 |
| `chart_tv_indicators.js` | `chartTvRenderIndicators(ctx)`:成交量 / ATR / ChanMACD |
| `chart_tv_chan.js` | `chartTvRenderChan(ctx)`:笔 / 线段 / 中枢(含未完成与 BI) |
| `chart_tv_overlays.js` | `chartTvRenderOverlays(ctx)`:结构区、威科夫、BSP/分型、布林等 |
| `chart_tv_finalize.js` | `chartTvFinalize(ctx)`:时间轴同步、bindSync、视图恢复、tooltip |
| `chart_tv.js` | `initTradingView`:组 ctx → 顺序调用上述步骤 |
## Context object
`ctx` 至少携带:`symbol``timeframe``symbolConfig`、周期开关、`candles`、各 chart/container、`showMacd`。全局 `currentData` / `tvWidget` 仍按现网约定使用。
## HTML load order
`lifecycle → shell → indicators → chan → overlays → finalize → chart_tv.js → chart_sync.js → …`
## Tests
1. `node --check` 各新文件 + 门面
2. 人工:首屏、自动刷新、威科夫开关、三周期笔段中枢、Cycle Summary
## Out of scope
Live 验证批跑、威科夫算法调参、analyze JSON 快照、`chart_sync` 大改。