开发预览 更新于 2026-05-10

LineChart 折线图

多 series 折线图,支持平滑曲线、网格线、x/y 轴标签。

基础用法

数据通过 props 传入,纯 SVG 渲染,无第三方图表库依赖。 配色取自 --viz-1..8 token,色盲友好。

2036536985000204060810121416182022
<CfLineChart ... />
<CfLineChart ... />

平滑曲线

smooth = true 走 Catmull-Rom 风格的 cubic Bezier,控制点取相邻两点的差值乘以 0.2 张力, 不会过冲(不会出现拐点处的”半圆”鼓包)。

smooth = false
203653698501234567891011
smooth = true(Catmull-Rom)
203653698501234567891011
<CfLineChart :series="series" smooth />
<CfLineChart series={series} smooth />

多 series

最多支持 8 条同时显示,配色按 --viz-1..8 依次循环。

52545658501234567891011
<CfLineChart :series="series" smooth />
<CfLineChart series={series} smooth />

API

属性类型默认值说明
seriesLineSeries[]{ name?, data: number[] }[]
labelsstring[]自动 0..n-1x 轴标签
width / heightnumber480 / 240
smoothbooleanfalse平滑曲线
showGrid / showLabelsbooleantrue
yLabelFn(v) => stringv.toFixed(0)y 轴标签格式化

反馈与讨论

LineChart 折线图 的讨论

0
0 / 600
一键发送
正在加载评论...