Appearance
你正在查看 v1.0.1 文档。切换到最新版请访问:/
阶梯折线
功能说明(What)
阶梯折线用于展示阶段性变化或离散区间变化,强调“跳变”过程。
应用场景(When)
- 阶段性变化
- 版本切换、策略分段
快速上手(How - Quick)
ts
import { BaseLine } from '@ymhc/harmonycharts';
import type { BaseLineConfig } from '@ymhc/harmonycharts';
@Entry
struct Index {
@Prop baseLineConfig: BaseLineConfig = {
categories: ['Mon', 'Tue', 'Wed', 'Thu'],
series: [{ name: 'Trend', data: [120, 200, 150, 80], step: 'middle' }],
tooltip: { show: true, trigger: 'axis', confine: true },
legend: { show: true }
};
build() {
Column() {
BaseLine({ config: this.baseLineConfig, chartHeight: 220 })
}
}
}运行结果
完整示例配置(整页可用)
ts
const option: HarmonyChartsOption = {
grid: { top: 28, left: 12, right: 12, bottom: 24 },
tooltip: { show: true, trigger: 'axis', triggerOn: 'mousemove', confine: true },
legend: { show: true },
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu'], boundaryGap: false },
yAxis: { type: 'value', includeZero: true },
series: [
{ type: 'line', name: 'Trend', data: [120, 200, 150, 80], step: 'middle', lineStyle: { color: '#5470C6', width: 2 } }
]
};默认值(精确工程默认)
该页面默认值与 BaseLine 一致,详见总览页「默认值(精确工程默认)」。
配置项说明(API)
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| step | 阶梯折线类型 | boolean | 'start' | 'middle' | 'end' | false |
事件与交互(Events)
ts
chart.on('click', (params) => {
// params.seriesType === 'line'
});高级用法(Advanced)
- 阶梯折线与 dataZoom 联动
注意事项 / 设计说明(Notes)
- step 为 true 等同于 'end'。