echarts 可视化数据展示 横柱状图

效果

  initChart2() {
        var option = {
          grid: {          //图表位置
            left: "2%",
            // right: "4%",
            top: "4%",
            // bottom: "20px",
            containLabel: true
          },
          tooltip: {
              trigger: 'axis',
              axisPointer: {
                  type: 'shadow'
              }
          },
          legend: {
            data: ['签约老人(千人)', '服务单数(千单)'],
            x:'left',
            y:'80%',
            icon:"circle",    //按钮样式
            textStyle:{ 
                fontSize: 14,
                color: '#ffffff'
            }
          },
          xAxis: {             //xy轴的数据
              type:'value',
              show:false,
          },
          yAxis: {
              type:'category',
              data: ['转塘','三墩','蒋村','西溪','留下','双浦'],
              splitLine: {show: false},
              axisLine: {
                  lineStyle: {
                      color: '#fff',
                  }
              },
            axisLabel: {
            show: true,
            textStyle: {
                color: '#fff',
                fontSize:'14'
            }
            }
          },
          series: [{
              name: '签约老人(千人)',
              type: 'bar',
              barWidth: 10,    //柱状图粗细
              itemStyle: {
                  normal: {
                      barBorderRadius: 20,
                      color: new echarts.graphic.LinearGradient(
                          0, 0, 1, 0,
                          [
                              {offset: 0, color: 'rgba(42,114,235,.5)'},   //渐变色
                              {offset: 1, color: 'rgba(42,114,235,1)'},
                          ]
                      )
                  }
              },
              data:[20,30,30,10,30,50]
          },{
              name: '服务单数(千单)',
              type: 'bar',
              barWidth: 10,
              itemStyle: {
                  normal: {
                      barBorderRadius: 20,
                      color: new echarts.graphic.LinearGradient(
                          0, 0, 1, 0,
                          [
                              {offset: 0, color: 'rgba(76,253,247,.5)'},
                              {offset: 1, color: 'rgba(76,253,247,1)'},
                          ]
                      )
                  }
              },
              data:[30,40,50,60,70,80]   //数据量
          }]
      };
      // 基于准备好的dom,初始化echarts实例
      var myChart = echarts.init(document.getElementById("main2"));
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    },

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值