Echarts柱形图折线图合并demo(含图例)

文章目录


前言

柱形图折线图合并demo(含图例)
在这里插入图片描述

option = {
  xAxis: {
    type: 'category',
    data: [2001, 2002, 2003, 2004, 2005],
    axisTick: {
      show: false
    }
  },
  yAxis: {
    type: 'value',
    interval: 10,
    // scale: true,
    max: 300,
    min: 0,
    splitLine: {
      show: true,
      lineStyle: {
        type: 'dashed',
        color: 'DimGray'
      }
    }
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  grid: {
    //grid 组件离容器上下左右侧的距离
    // left: "3%",
    // right: "3%",
    // top: 35,
    // bottom: "3%",
    // containLabel: true,
  },
  legend: [
    //   柱状图(总产值)
    {
      top: '0%',
      left: '10%',
      textStyle: {
        // 图例文字样式
        color: '#fff',
        fontSize: 10,
        fontFamily: 'PingFangSC-Regular, PingFang SC;'
      },
      itemStyle: {
        color: '#429DFF'
      },
      itemWidth: 10, // 图例图形的宽度
      itemHeight: 7, // 图例图形的高度

      data: [
        {
          name: '总产值', // 图例文字内容
          icon: 'rect' // 图例图形的形状,有多个可选值:'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none',
        }
      ]
    },

    // 折线图(企业个数)
    {
      top: '0%',
      right: '10%',
      textStyle: {
        // 图例文字样式
        color: '#fff',
        fontSize: 14,
        fontFamily: 'PingFangSC-Regular, PingFang SC;'
      },
      itemStyle: {
        color: 'red'
      },
      itemWidth: 10, // 图例图形的宽度
      itemHeight: 2, // 图例图形的高度

      data: [
        {
          name: '企业个数', // 图例文字内容
          icon: 'rect' // 图例图形的形状,有多个可选值:'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none',
        }
      ]
    }
  ],

  series: [
    {
      name: '总产值',
      data: [50, 10, 90, 200, 250],
      barWidth: 10,
      type: 'bar',
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          { offset: 0, color: 'rgba(66, 157, 255, 0.8)' },
          { offset: 1, color: 'rgba(66, 157, 255, 0)' }
        ])
      }
    },

    {
      name: '企业个数',
      type: 'line',
      data: [50, 10, 90, 200, 250],
      lineStyle: {
        normal: {
          color: 'red', //折线的颜色
          width: '2' //折线粗细
        }
      },
      itemStyle: {
        normal: {
          color: '#fff', //拐点颜色
          borderColor: '#429DFF' //拐点边框颜色
        }
      }
    }
  ]
};

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值