echarts笔记

一、给legend图例限制长度

1.1 通过给其加 formatter: function (value) { }

legend: {
    type: 'scroll',
    orient: 'vertical',
    icon: "circle",
    right: 5,
    top: 15,
    bottom: 20,
    formatter: function (value) {
      if (value.length > 12) {
          value = value.substring(0, 12) + "....";
      }
      return value;
    },
    data: []
  },

1.2、更改图例\x轴\y轴字体颜色  图例下面加 textStyle,x轴和y轴下加lineStyle

legend: {
    top: 'bottom',
    icon: 'circle', //  这个字段控制形状  类型包括 circle,rect ,roundRect,triangle,diamond,pin,arrow,none
    itemGap: 7, // 设置间距
    padding: [0, 0, 15, 0], //图例距离
    textStyle: {
       color: '#333'
    }
  },

xAxis: {
    type: 'category',
    axisLine: {
      lineStyle: {
         color: '#333'
      }
    }
  },
yAxis: {
   axisLine: {
      lineStyle: {
         color: '#333'
      }
   }
},

1.2、给折线图的端点设置颜色,让数显示在顶部,添加渐变色

series: [
    {
      name: '发放金额',
      type: 'line',
      smooth: true,
      lineStyle: {
        width: 2,
        color: '#91cc75'
      },
      //设置端点颜色
      itemStyle: {
        normal: {
          color: '#91cc75'
        }
      },
      // showSymbol: false,
      // 添加渐变色
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: 'rgba(145, 204, 117,0.8)'
          },
          {
            offset: 1,
            color: 'rgba(145, 204, 117,0.1)'
          }
        ])
      },
      // 让数量显示在顶部
      label: {
        normal: {
          show: true,
          position: 'top',
          textStyle: {
            color: '#eee'
          }
        }
      },
      data: []
    }
  ]

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值