Appearance
基础散点
功能说明(What)
基础散点用于展示二维数据点分布,直观观察聚合与离群。
应用场景(When)
- 分布与相关性分析
- 离群点检测
快速上手(How - Quick)
ts
import { BaseScatter } from '@ymhc/harmonycharts';
import type { BaseScatterConfig } from '@ymhc/harmonycharts';
@Entry
struct Index {
@Prop baseScatterConfig: BaseScatterConfig = {
series: [{ name: 'A', data: [[10, 20], [15, 35], [20, 22], [25, 45]] }],
tooltip: { show: true, trigger: 'item', confine: true },
legend: { show: true }
};
build() {
Column() {
BaseScatter({ config: this.baseScatterConfig, chartHeight: 220 })
}
}
}运行结果
完整示例配置(整页可用)
ts
const option: HarmonyChartsOption = {
grid: { top: 28, left: 12, right: 12, bottom: 24 },
tooltip: { show: true, trigger: 'item', triggerOn: 'mousemove', confine: true },
legend: { show: true },
xAxis: { type: 'value' },
yAxis: { type: 'value', includeZero: true },
series: [
{ type: 'scatter', name: 'A', data: [[10, 20], [15, 35], [20, 22], [25, 45]], symbol: 'circle', symbolSize: 8 }
]
};默认值(精确工程默认)
该页面默认值与 BaseScatter 一致,详见总览页「默认值(精确工程默认)」。
配置项说明(API)
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| symbol | 点形状 | SymbolType | 'circle' |
| symbolSize | 点大小 | number | 8 |
事件与交互(Events)
ts
chart.on('click', (params) => {
// params.seriesType === 'scatter'
});高级用法(Advanced)
- 多系列对比与图例联动
- dataZoom 适配长序列
注意事项 / 设计说明(Notes)
- 数据量很大时建议减少点大小或开启分组。