-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or requestin-progressWork currently in progressWork currently in progress
Description
背景
當分析面板有 2 個度量(如「金額」與「數量」)且數值級距差異過大時,較小的度量會被壓縮成幾乎平坦的線條,圖表失真嚴重。
另外,金額欄位數值動輒百萬、上億,Y 軸顯示原始數字不易閱讀。
需求
1. 雙 Y 軸(Dual Y-Axis)
觸發條件:2 個度量的最大值差距 ≥ 10 倍時自動啟用
前端(ECharts):
- 左 Y 軸:第一個度量
- 右 Y 軸:第二個度量
- 各自獨立刻度,tooltip 同時顯示兩個度量值
- 1 個度量時維持單 Y 軸(向後相容)
後端(NPOI Excel):
AnalysisExcelExporter偵測雙度量 + 級距差異,建立 secondary value axis- 第二個 series 綁定右側 Y 軸
2. 金額縮放(Currency Scaling)
自動縮放規則(依最大值判斷):
| 最大值範圍 | 顯示單位 | 除數 |
|---|---|---|
| < 10,000 | 元 | 1 |
| 10,000 ~ 999,999 | 萬元 | 10,000 |
| 1,000,000 ~ 99,999,999 | 百萬元 | 1,000,000 |
| ≥ 100,000,000 | 億元 | 100,000,000 |
顯示方式:
- Y 軸標題顯示單位(如「金額(萬元)」)
- Tooltip 顯示原始精確值
- Excel 匯出時在 column header 附加單位
3. 可選:使用者手動切換
未來可考慮在 UI 加入下拉選單讓使用者手動選擇縮放單位,但 v1 先以自動判斷為主。
影響範圍
| 檔案 | 變更 |
|---|---|
framework_analysis.js |
ECharts 雙 Y 軸邏輯 + 縮放計算 |
AnalysisExcelExporter.cs |
NPOI secondary axis + header 單位 |
AnalysisExcelExporterTests.cs |
新增雙 Y 軸 + 縮放測試 |
| JS tests | 新增 detectDualAxis / scaleValue 測試 |
備註
- 僅影響
bar和line圖表類型(pie不適用雙 Y 軸) card類型不受影響- 向後相容:單度量行為不變
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestin-progressWork currently in progressWork currently in progress