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)
},
相关推荐
码上暴富20 小时前
Echarts雷达图根据数值确定颜色
前端·javascript·echarts
懒大王95271 天前
uni-app + Vue3 开发展示 echarts 图表
前端·uni-app·echarts
小谭鸡米花2 天前
uni小程序中使用Echarts图表
前端·小程序·echarts
@AfeiyuO4 天前
分类别柱状图(Vue3)
typescript·vue·echarts
Pu_Nine_94 天前
10 分钟上手 ECharts:从“能跑”到“生产级”的完整踩坑之旅
前端·javascript·echarts·css3·html5
小白_ysf4 天前
uniapp和vue3项目中引入echarts 、lime-echart(微信小程序、H5等)
微信小程序·uni-app·echarts·h5·lime-echart
Chan165 天前
【智能协同云图库】基于统一接口架构构建多维度分析功能、结合 ECharts 可视化与权限校验实现用户 / 管理员图库统计、通过 SQL 优化与流式处理提升数据
java·spring boot·后端·sql·spring·intellij-idea·echarts
zhangzuying10265 天前
基于Vue3 +ElementuiPlus + Dexie.js自研的浏览器插件新建标签页tab
vue.js·typescript·echarts
java水泥工7 天前
基于Echarts+HTML5可视化数据大屏展示-学生综合成绩评价系统大屏
spring boot·echarts·html5
java水泥工8 天前
基于Echarts+HTML5可视化数据大屏展示-茶叶种植大数据溯源平台
大数据·echarts·html5