echarts 柱状图及折线图常用设置

echarts 柱状图及折线图基础效果功能设置

记录一下 下次直接使用

option = {
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
    // formatter: '{b}<br/>{a0}:{c0}<br/>{a1}:{c1}%'
  },
  // color: ['#A6FFC2', '#A6FFC2'],
  xAxis: [
    {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      boundaryGap: true, // 两边是否留空白
      axisTick: {
        alignWithLabel: true // 文字居中
      },
      axisLabel: {
        show: true, //文字显示
        interval: 0 //使x轴文字显示全
      },
      splitLine: {
        show: false, // 显示轴线
        lineStyle: {
          type: 'dashed' // 轴线样式
        }
      }
    }
  ],
  yAxis: [
    {
      type: 'value',
      axisTick: {
        alignWithLabel: true // 文字居中
      },
      splitLine: {
        show: true, // 显示轴线
        lineStyle: {
          type: 'dashed' // 轴线样式
        }
      }
    }
  ],
  series: [
    {
      name: 'Direct',
      type: 'bar',
      data: [
        10,
        52,
        {
          value: 200,
          itemStyle: {
            color: '#a90000'
          }
        },
        334,
        390,
        330,
        220
      ],
      // color: '#A6FFC2', // 线条颜色
      showBackground: true, //显示背景颜色
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.01)'
      },
      barWidth: '60%', //宽度
      barMaxWidth: '30', // 最大宽度
      label: {
        show: true, //显示数值
        position: 'top', //位置
        fontSize: 12
      },
      yAxisIndex: 0
    },
    {
      name: 'Directs',
      type: 'line',
      data: [820, 932, 901, 934, 1290, 1330, 1320],
      color: '#A6FFC2', // 线条颜色
      smooth: true,
      symbolSize: 8, //小圆点的大小
      symbol: function (value, ind) {
        if (5 == ind.dataIndex) {
          return 'circle';
        } else {
          return 'none';
        }
      },
      areaStyle: {
        color: {
          x: 0,
          y: 1,
          x2: 0,
          y2: 0,
          colorStops: [
            {
              offset: 0,
              color: 'rgba(166, 255, 194, 0)' // 0% 处的颜色
            },
            {
              offset: 1,
              color: '#A6FFC2' // 100% 处的颜色
            }
          ],
          global: false // 是否添加渐变
        }
      },
      // 显示最大值
      markPoint: {
        data: [{ type: 'max', name: 'Max' }]
      }
    }
  ]
};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值