Skip to content

你正在查看 v1.0.1 文档。切换到最新版请访问:/

多系列对比雷达

功能说明(What)

多系列雷达用于对比不同对象的多维指标差异。

应用场景(When)

  • 多对象能力对比
  • 竞品/版本对比

快速上手(How - Quick)

ts
import { BaseRadar } from '@ymhc/harmonycharts';
import type { BaseRadarConfig } from '@ymhc/harmonycharts';

@Entry
struct Index {
  @Prop baseRadarConfig: BaseRadarConfig = {
    indicators: [
      { name: 'Speed', max: 100 },
      { name: 'Quality', max: 100 },
      { name: 'Reliability', max: 100 },
      { name: 'Flexibility', max: 100 },
      { name: 'Cost', max: 100 }
    ],
    data: [
      { name: 'Plan', value: [70, 80, 65, 75, 60] },
      { name: 'Actual', value: [60, 72, 70, 68, 55] }
    ],
    tooltip: { show: true, trigger: 'item', confine: true },
    legend: { show: true }
  };

  build() {
    Column() {
      BaseRadar({ config: this.baseRadarConfig, chartHeight: 240 })
    }
  }
}

运行结果

radar compare

完整示例配置(整页可用)

ts
const option: HarmonyChartsOption = {
  radar: {
    indicator: [
      { name: 'Speed', max: 100 },
      { name: 'Quality', max: 100 },
      { name: 'Reliability', max: 100 },
      { name: 'Flexibility', max: 100 },
      { name: 'Cost', max: 100 }
    ],
    center: ['50%', '50%'],
    radius: '70%'
  },
  tooltip: { show: true, trigger: 'item', confine: true },
  legend: { show: true },
  series: [{ type: 'radar', name: 'Radar', data: [{ name: 'Plan', value: [70, 80, 65, 75, 60] }, { name: 'Actual', value: [60, 72, 70, 68, 55] }] }]
};

默认值(精确工程默认)

该页面默认值与 BaseRadar 一致,详见总览页「默认值(精确工程默认)」。

配置项说明(API)

参数说明类型默认值
legend图例LegendOption{ show: true }
data雷达数据BaseRadarItem[]-

事件与交互(Events)

ts
chart.on('click', (params) => {
  // params.seriesType === 'radar'
});

高级用法(Advanced)

  • 使用 areaStyle 增强对比区域

注意事项 / 设计说明(Notes)

  • 建议控制系列数量,避免视觉杂乱。

HarmonyCharts 鸿蒙图表文档。