ECharts 饼图-环形进度图

option = {
  tooltip: {
    trigger: 'item',
  },
  legend: {
    top: '5%',
    left: 'center'
  },
  title:[{
        text: "40.5%",
        x: "center",
        y: "46%",
        itemGap: 5, // 文本间距
        textStyle: {
          color: "rgba(255, 255, 255, 0.95)",
          fontFamily: "PingFang SC",
          fontWeight: 500,
          fontSize: 30,
        },
        subtext: "完成情况",
        subtextStyle: {
          color: "rgba(255, 255, 255, 0.6)",
          fontSize: 20,
          // lineHeight: 16,  或者使用lineHeight来调节文本间距
          fontFamily: "PingFang SC",
          align: "center",
          fontWeight: 400,
        },
      }],
  series: [
    {
      name: 'Access From',
      type: 'pie',
      radius: ['40%', '50%'],
      center: ["50%", "50%"],
      avoidLabelOverlap: false,
      label: {
        show: false,
      },
      data: [
          {
            value: 40.5,
            name: "Search Engine",
            itemStyle: {
              borderColor: "rgba(255, 255, 255, 0.6)",
              color: {
                colorStops: [
                  {
                    offset: 0,
                    color: "#65FF99", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "#11A92A", // 100% 处的颜色
                  },
                ],
              },
            },
          },
          {
            value: 100 - 40.5,
            tooltip: {
              show: false,
            },
            emphasis: {
              disabled: true,
            },
            itemStyle: {
              borderWidth: 1,
              color: "rgba(160, 225, 255, 0.2)",
            },
          },
        ],
    }
  ]
};

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 ECharts饼图中实现环形渐变,可以使用 ECharts 的 `color` 属性来实现。以下是一个简单的示例代码: ```javascript option = { title: { text: '环形渐变饼图', left: 'center' }, tooltip: { trigger: 'item', formatter: '{a} <br/>{b}: {c} ({d}%)' }, series: [ { name: '访问来源', type: 'pie', radius: ['40%', '60%'], avoidLabelOverlap: false, label: { show: false, position: 'center' }, emphasis: { label: { show: true, fontSize: '30', fontWeight: 'bold' } }, labelLine: { show: false }, data: [ {value: 435, name: '直接访问'}, {value: 310, name: '邮件营销'}, {value: 234, name: '联盟广告'}, {value: 135, name: '视频广告'}, {value: 1548, name: '搜索引擎'} ], color: [ new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#fbb962'}, {offset: 0.5, color: '#f37b1d'}, {offset: 1, color: '#f37b1d'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#00c2ff'}, {offset: 0.5, color: '#008cff'}, {offset: 1, color: '#008cff'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#6fde6f'}, {offset: 0.5, color: '#00c633'}, {offset: 1, color: '#00c633'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#f5d114'}, {offset: 0.5, color: '#e8b027'}, {offset: 1, color: '#e8b027'} ]), new echarts.graphic.LinearGradient(0, 0, 0, 1, [ {offset: 0, color: '#3bafff'}, {offset: 0.5, color: '#0072ff'}, {offset: 1, color: '#0072ff'} ]) ] } ] }; ``` 在这个示例中,我们的饼图有 5 个扇形,每个扇形都有一个渐变颜色。我们使用 `new echarts.graphic.LinearGradient` 方法创建了一个线性渐变,然后将其分配给每个扇形。线性渐变的参数分别为 `0, 0, 0, 1`,表示从上到下的垂直渐变。在 `color` 属性中,我们将每个扇形的颜色设置为线性渐变。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值