echarts 圆环图 高亮事件 切换 中心文字

javascript 复制代码
createEcharts() {
  let chartDom = this.$refs.echarts
  this.Echarts = echarts.init(chartDom)

  let option = {
    title: {
      text: '128', //主标题文本
      subtext: '总数', //副标题文本
      left: 'center',
      top: '32%',
      textStyle: {
        fontFamily: 'Montserrat-MediumItalic',
        fontSize: 30,
        color: '#fff',
        align: 'center',
      },
      subtextStyle: {
        fontFamily: 'Source Han Sans CN',
        fontSize: 16,
        color: '#AEAEB2',
      },
    },
    series: [
      {
        type: 'pie',
        center: ['50%', '50%'],
        radius: ['50%', '60%'],
        label: {
          color: '#fff',
        },
        itemStyle: {
          borderColor: '#1b2b3c',
          borderWidth: 2,
        },
        data: [
          { value: 128, name: '正常', itemStyle: { color: '#92c7f7' } },
          { value: 24, name: '离线', itemStyle: { color: '#c0c5c9' } },
          { value: 6, name: '故障', itemStyle: { color: '#ff673b' } },
        ],
      },
    ],
  }
  
  this.Echarts.on('mouseover', (params) => {
    // 获取高亮的数据项的值
    let highlightedValue = params.data.value

    // 更新饼图标题
    this.Echarts.setOption({
      title: {
        text: highlightedValue,
      },
    })
  })

  option && this.Echarts.setOption(option)
},
相关推荐
匹马夕阳15 小时前
ECharts极简入门
前端·信息可视化·echarts
禾苗种树17 小时前
在 Vue 3 中使用 ECharts 制作多 Y 轴折线图时,若希望 **Y 轴颜色自动匹配折线颜色**且无需手动干预,可以通过以下步骤实现:
前端·vue.js·echarts
不想上班只想要钱10 天前
ECharts鼠标悬浮提示框数字设置鼠标在左侧时 tooltip 显示到右侧,鼠标在右侧时 tooltip 显示到左侧。
javascript·计算机外设·echarts
枫叶落雨22212 天前
11苍穹外卖之Apache ECharts(数据可视化图表、后端传数据)
信息可视化·apache·echarts
祁许12 天前
【Vue】在Vue3中使用Echarts的示例 两种方法
前端·vue.js·typescript·vue·echarts
ctf_022613 天前
echarts 3d中国地图飞行线
3d·echarts·swift
Kill_paradise14 天前
echarts 鼠标移入柱状图展示手指,移入label 展示箭头
前端·javascript·echarts
cccc☜15 天前
echarts加载地图
前端·javascript·echarts
大厂在职_few16 天前
Android版&Kotlin版RxJava2+Retrofit2+OkHttp3的基础、封装和项目中的使用
android·kotlin·echarts
kidding72317 天前
Vue3使用Echarts组件步骤
前端·vue.js·echarts