From ac55af50d93427b91db9f52415c3e7a749943420 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Fri, 18 Sep 2026 09:51:10 +0800 Subject: feat(frontend): 图表增强——网格、hover 当日净值/回撤、回测区间阴影带 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [变更性质] 图表层能力扩展,前端重设计第二轮之三。 [新增功能] Chart 网格线使用主题 border 色;hover 手柄提示补充"当日净值+回撤";回测区间 belowMarks 渲染半透明阴影带(bandShaded 可关);series 支持 dashed/opacity,Area 填充渲染;equity 行内合并回撤列,drawdown 图改为百分比格式化。 [实现方案] 基于 layerchart marks/belowMarks 泳道与自定义 tooltip snippet(lcExtras 透传绕开字面量类型检查),宽度扩展点保持 resolvedWidth 合同不变。 [影响范围] Chart.svelte、ProjectResultsTab.svelte;图表 probe 断言(svgs 渲染、溢出为 0)不变。 --- frontend/src/components/Chart.svelte | 131 ++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 9 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/Chart.svelte b/frontend/src/components/Chart.svelte index 0854f3a..5b6038d 100644 --- a/frontend/src/components/Chart.svelte +++ b/frontend/src/components/Chart.svelte @@ -1,6 +1,7 @@ -
+{#snippet belowMarks({ context }: { context: ChartCtx; facet: Facet })} + {#if bandShaded} + {@const b = bandBounds(context)} + {#if b} + + {/if} + {/if} +{/snippet} + +{#snippet marks({ context }: { context: ChartCtx; facet: Facet })} + {#each context?.series?.visibleSeries ?? [] as s (s.key)} + {#if areaKeys.has(s.key)} + + {/if} + + {/each} +{/snippet} + +{#snippet tooltipBox({ context }: { context: ChartCtx })} + + {#snippet children({ data }: { data: Record })} + + + {#each context?.series?.visibleSeries ?? [] as s (s.key)} + {@const acc = s?.value} + {@const v = typeof acc === 'function' ? acc(data as never) : data?.[acc as string]} + {#if v !== undefined} + + {/if} + {/each} + {#each extras as e (e.key)} + {#if data?.[e.key] !== undefined} + + {/if} + {/each} + + {/snippet} + +{/snippet} + +
-- cgit v1.2.3