Skip to content

雷达图Radar

一、效果总览

二、描述

使用场景

  1. 需要比较一组数据再多个维度上综合优势(看雷达图总面积)的场景
  2. 需要比较一组数据中再某个维度上个别优势的场景(看某个维度上各个项目的位置)

三、构造函数及参数说明

typescript
@Component
export struct OmniRadarChart {
  private drawViewModel?: DrawBaseViewModel<RadarDataType>
  @Prop @Watch('onCountUpdated') options: Options<RadarDataType>;
  @State chartOption: OptionInterface<RadarDataType> = {};
  @State renderType: string = 'init'
  private click: Function = (event: InterfaceObj, params: InterfaceObj) => {
  }
  private tooltipClick: Function = (event: InterfaceObj, params: InterfaceObj) => {
  }
  @BuilderParam customTooltip: (tooltipInfo: InterfaceObj) => void = globalBuilder
}

OmniRadarChart

参数名参数类型描述是否必填默认值
optionsOptions环状图的数据和样式null
clickFunction图表点击事件的回调空实现
drawViewModelDrawBaseViewModel折线图绘制逻辑类new DrawRadarViewModel()
customTooltipFunction自定义tooltip时的点击回调图表库自动生成默认值

四、代码演示

typescript
@Component
export struct OmniRadarChartExamplePage {
  @State defOption: Options<number> = new Options({
    radar: {
      indicator: [
        { name: 'Sales' },
        { name: 'Administration' },
        { name: 'Information Technology' },
        { name: 'Customer Support' },
        { name: 'Development' }
      ]
    },
    series: [
      {
        name: '最高气温',
        lineStyle: {
          width: 1.5,
          color: "#ff52be80"
        },
        areaStyle: {
          color: {
            direction: [0, 1, 0, 0],
            colors: [
              '#9952be80'
            ]
          }
        },
        data: [11, 12, 15, 13, 12],
      },
      {
        name: '最高气温2',
        areaStyle: {
          color: {
            direction: [0, 1, 0, 0],
            colors: [
              '#99265fe5'
            ]
          }
        },
        data: [10, 12, 10.5, 13, 10]
      },
    ]
  })
  build() {
    NavDestination() {
      Column(){
        OmniRadarChart({
          options: this.defOption
        })
      }
      .height('50%')
    }
    .title("雷达图示例")
  }
}