标记线 / 标记点
spec.marks(纯 JSON):markLine 画水平(axis:'y',数值)或垂直(axis:'x',类目名/索引)参考线——dashed,--icen-token-<tone>(success/warning/error/info,缺省 muted)+ 尾部标签(视口内夹取);
阈值参考线(error tone)+ 版本发布垂直线 + 峰值标记点——「ghost」类目不存在,被跳过并 warn 一次
<p class="demo-label" style="margin:0 0 10px">阈值参考线(error tone)+ 版本发布垂直线 + 峰值标记点——「ghost」类目不存在,被跳过并 warn 一次</p><div class="icen-chart" id="demo-charts-marks" style="border:1px solid var(--icen-token-line-soft);border-radius:var(--icen-radius-md);padding:12px"></div>
行为与接口说明
spec.marks(纯 JSON):markLine 画水平(axis:'y',数值)或垂直(axis:'x',类目名/索引)参考线——dashed,--icen-token-<tone>(success/warning/error/info,缺省 muted)+ 尾部标签(视口内夹取);markPoint 在对应类目/系列处画标记点 + text 标注。无效标记(类目不存在/值 NaN/系列越界)跳过并 console.warn 一次(按唯一标记去重),不炸渲染。
安装
bun add @icen.ai/ui pnpm add @icen.ai/ui npm install @icen.ai/ui yarn add @icen.ai/ui 用法
renderChart(el, { type: 'line', labels, values, marks: [ { type: 'line', axis: 'y', value: 80, label: '告警阈值', tone: 'error' }, { type: 'line', axis: 'y', value: 40, label: '水位下限' }, // 缺省 muted { type: 'line', axis: 'x', value: 'v1.0' }, // 类目名(也接受索引 number) { type: 'point', label: '周三', seriesIndex: 1, text: '发布日' }, // 系列标记点 ],});/* 无效标记诚实跳过:{ type: 'point', label: '不存在' } → console.warn 一次,渲染照常 */