我是靠谱客的博主 激昂大船,最近开发中收集的这篇文章主要介绍Echarts 计算每份占比(等分),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

const doDashboard = (val: any) => {
  if (val >= 0 && val < 75) {
    return val * 30 / 75
  } else if (val >= 75 && val <= 85) {
    return 30 + (val - 75) * 40 / 10
  } else {
    return 70 + (val - 85) * 30 / 15
  }
} 


option = {
    series: [
      {
        type: "gauge",
        startAngle: 190,
        endAngle: -10,
        min: 0,
        max: 100,
        axisLine: {
          lineStyle: {
            width: 15,
            color: [
              [0.3, "#91BB7E"],
              [0.7, "#F7DD6F"],
              [1, "#D66474"]
            ]
          }
        },
        pointer: {
          //指针
          icon: "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
          length: "60%", //指针长度
          width: 5,
          offsetCenter: [0, "-60%"],
          itemStyle: {
            color: "auto"
          }
        },
        axisTick: {
          show: false,
          distance: -30,
          length: 8,
          lineStyle: {
            color: "#fff",
            width: 2
          }
        },
        splitLine: {
          show: false,
          distance: -20,
          lineStyle: {
            color: "#fff",
            width: 4
          }
        },
        axisLabel: {
          distance: 30,
          fontSize: 12,
          formatter: function (value: any) {
            if (value === 30) {
              return 75 + "%";
            } else if (value === 70) {
              return 85 + "%";
            } else {
              return "";
            }
          },
        },
        detail: {
          fontSize: 20,
          valueAnimation: true,
          color: "auto",
          show: true,
          offsetCenter: [0, -30],
          formatter: function () {
            return dashboardData.valueNumber + "%";
          }
        },
        data: [
          {
            value: doDashboard(dashboardData.valueNumber),
            name: dashboardData.title,
            title: {
              lineHeight: 20,
              offsetCenter: [0, 0],
              fontSize: 12
            }
          }
        ]
      }
    ]
  };
  var chartDom = document.getElementById('main') as HTMLElement;
  var myChart = echarts.init(chartDom);
  option && myChart.setOption(option);

最后

以上就是激昂大船为你收集整理的Echarts 计算每份占比(等分)的全部内容,希望文章能够帮你解决Echarts 计算每份占比(等分)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(36)

评论列表共有 0 条评论

立即
投稿
返回
顶部