Echarts进度条状的柱状图demo

项目场景:

Echarts进度条状的柱状图
在这里插入图片描述


问题描述

@Override
	var colorList = [
  ['#00E8FF', '#429DFF'],
  ['#E1F24C', '#8AEC6A'],
  ['#2BF3E4', '#04DFCF']
];
function colorFn(params) {
  //params 传递过来的柱子对象
  // dataIndex 是当前柱子的索引
  var colorItem = colorList[params.dataIndex];
  return new echarts.graphic.LinearGradient(
    1,
    0,
    0,
    0,
    [
      {
        offset: 0,
        color: colorItem[0]
      },
      {
        offset: 1,
        color: colorItem[1]
      }
    ],
    false
  );
}
let sumNumber = [{ value: 100 }, { value: 100 }, { value: 100 }];
console.log(sumNumber);
let NumberList = sumNumber.map((v, index) => {
  return {
    value: v.value,
    itemStyle: {
      normal: {
        barBorderRadius: 15,
        color: 'none', //填充色
        borderColor: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
          {
            offset: 0,
            color: colorList[index][1]
          },
          {
            offset: 1,
            color: colorList[index][0]
          }
        ])
      },

      borderWidth: 2
    }
  };
});
 option = {
  // tooltip: {
  //   // trigger: 'axis',
  //   axisPointer: {
  //     type: 'shadow'
  //   }
  // },
  grid: {
    left: '10%',
    right: '4%',
    bottom: '0%',
    top: '10%'
    // containLabel: true
  },
  xAxis: {
    show: false //不显示x轴相关信息
  },
  yAxis: [
    {
      type: 'category',
      data: ["111111", "222222", "333333"],
      axisLabel: {
        show: true,
        inside: true,
        textStyle: {
          color: '#fff',
          verticalAlign: 'bottom',
          fontSize: 12,
          align: 'left',
          padding: [0, 0, 10, 0]
        }
      },
      axisTick: {
        show: false
      },
      axisLine: {
        show: false
      },
      inverse: true
    },
    {
      type: 'category',
      data:[28.19, 15078, 11606],//显示的数据
      axisTick: { show: false }, //不显示刻度线
      axisLabel: {
        show: true,
        inside: true,
        textStyle: {
          color: '#fff',
          fontSize: 12,
          verticalAlign: 'bottom',
          align: 'right',
          padding: [0, 0, 10, 0]
        }
      },
      axisLine: {
        show: false
      },
      inverse: true
    }
  ],
  series: [
    {
      name:["111111", "222222", "333333"],
      yAxisIndex: 0,
      tooltip: {
        show: true //显示提示框
      },
      type: 'bar',
      data:[90, 40, 10],
      // 修改第一条柱子的圆角
      itemStyle: {
        normal: {
          barBorderRadius: 20,
          color: colorFn
        }
        // color 可以修改柱子的颜色
        // color:"orange"
      },
      // 柱子之间的间距
      barCategoryGap: 10,
      // 柱子之间的宽度
      barWidth: 5
      // 显示柱子内的文字
      // label: {
      //   show: true,
      //   color:'#fff',
      //   position: 'inside',
      //   formatter: '{c}%'
      //   // {c} 会自动解析为data中的数据
      // }
    },
    {
      // name: '框',
      tooltip: {
        show: false //显示提示框
      },
      yAxisIndex: 1,
      type: 'bar',
      barGap: '0%',
      // 柱子之间的间距
      barCategoryGap: 10,
      // 柱子之间的宽度
      barWidth: 10,
      data: NumberList
    }
  ]
};


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值