Angular:使用echarts制作渐变色雷达图

15 篇文章 1 订阅
5 篇文章 0 订阅

雷达图对应的图示,雷达图上显示合同量和金额两组数据:

legend: {
        x: 'center',
        data: ['合同量', '金额'],
        textStyle: {
          color: '#fff'
        }
      },

设置雷达图各个坐标轴的含义、坐标轴位置、坐标轴间隔的样式等:

radar: {
        indicator: (function () {
          const res = [
            { text: '来源', max: 100 },
            { text: '其他', max: 100 },
            { text: '一览协议', max: 100 },
            { text: '邀请招标', max: 100 },
            { text: '询价', max: 100 },
            { text: '订购协议', max: 100 },
            { text: '谈判', max: 100 },
            { text: '公开招标', max: 100 },
          ];
          return res;
        })(),
        center: ['68%', '56%'],   // 坐标轴中心坐标
        radius: '58%',            // 坐标轴半径占可显示区域的比例
        axisLine: {               // 坐标轴样式
          lineStyle: {
            color: '#E9EBF1'
          }
        },
        splitArea: {              // 坐标轴分隔区显示颜色:默认是一深一浅的间隔颜色,这里我们设置间隔之间是空白
          areaStyle: {
            opacity: 0
          }
        }
      },

设置雷达图的数据和数据展示样式:


      series: [
        // 1、合同量:
        {
          type: 'radar',        // 雷达图
          data: [
            {
              name: '合同量',
              value: [21.6, 15.9, 40, 23.6, 32.2, 48.7, 18.8, 22.3],
              emphasis: {       // 鼠标悬浮时高亮显示,同时展示雷达图的数据样式
                label: {
                  show: true,
                  color: '#fff',
                  fontSize: 14,
                  backgroundColor: '#0D1B42',
                  borderRadius: 5,
                  padding: 3,
                  shadowBlur: 3   // 阴影宽度
                }
              }
            }
          ],
          itemStyle: {
            color: new echarts.graphic.LinearGradient(         // 设置渐变色
              0, 0, 0, 1,
              [
                { offset: 0, color: 'rgba(0, 230, 98, 1)' },
                { offset: 1, color: 'rgba(0, 155, 171, 1)' }
              ]
            )
          },
          areaStyle:                                          // 雷达图辐射区域的样式
          {
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                { offset: 0, color: 'rgba(0, 230, 98, 1)' },
                { offset: 1, color: 'rgba(0, 155, 171, 1)' }
              ]
            )
          },
        },
        
        // 2、金额:
        {
          type: 'radar',
          data: [
            {
              name: '金额',
              value: [24.0, 42.9, 71.0, 23.2, 22.2, 20.0, 46.4, 32.3],
              emphasis: {
                label: {
                  show: true,
                  color: '#fff',
                  fontSize: 14,
                  backgroundColor: '#0D1B42',
                  borderRadius: 5,
                  padding: 3,
                  shadowBlur: 3
                }
              }
            }
          ],
          itemStyle: {
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                { offset: 0, color: 'rgba(1, 184, 252, 1)' },
                { offset: 1, color: 'rgba(100, 74, 255, 1)' }
              ]
            )
          },
          areaStyle:
          {
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                { offset: 0, color: 'rgba(1, 184, 252, 1)' },
                { offset: 1, color: 'rgba(100, 74, 255, 1)' }
              ]
            )
          },
        }
      ],

注意我们这样设置渐变色:     

new echarts.graphic.LinearGradient( 
              0, 0, 0, 1,
             [
                { offset: 0, color: 'rgba(0, 230, 98, 1)' },
                { offset: 1, color: 'rgba(0, 155, 171, 1)' }
              ]
)

 

这样就实现了一个雷达的数据展示。

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值