柱状图(网格形式)

效果图:

代码块:

var getsyzl = [
  '2014',
  '2015',
  '2016',
  '2017',
  '2018',
  '2019',
  '2020',
  '2021',
  '2022',
  '2023',
  '2020',
  '2021',
  '2022',
  '2023',
  '2020',
  '2021',
  '2022',
  '2023'
];
var getwkrs = [
  20, 673, 588, 782, 779, 1000, 20, 673, 588, 0, 0, 10, 20, 673, 588, 782, 0,
  1000
];
//splitNumber 方法(坐标轴的分割段数)
let splitNumbers = getsyzl.length / 2;

let symbolColors = ['#1CF407'];
let markPointDatum = [];
for (var i = 0; i < getwkrs.length; i++) {
  if (getwkrs[i] != 0) {
    let _obj = {
      symbol: 'pin',
      symbolOffset: [0, '-20%'],
      coord: [i, getwkrs[i]],
      value: getwkrs[i],
      itemStyle: {
        // borderWidth: 3,
        // borderColor: symbolColors[i],
        // color: symbolColors[i]
      }
    };
    markPointDatum.push(_obj);
  }
}
option = {
  backgroundColor: '#000',
  xAxis: [
    {
      data: getsyzl,
      boundaryGap: false,
      axisLabel: {
        interval: 0, //解决文字超过数量不显示问题
        margin: 10,
        color: '#A1D5FF',
        textStyle: {
          fontSize: 12
        }
      },
      axisLine: {
        // show:true,
        lineStyle: {
          color: '#102E74'
        }
      },
      axisTick: {
        show: true,
        alignWithLabel: true
      },
      splitLine: {
        show: true,
        interval: 0,
        lineStyle: {
          color: '#102E74'
        }
      }
    }
  ],
  yAxis: [
    {
      type: 'value',
      offset: 20,
      splitNumber: splitNumbers,
      axisLabel: {
        color: '#A1D5FF',
        textStyle: {
          fontSize: 12
        }
      },
      // axisLine: {
      //   show: false,
      //   lineStyle: {
      //     color: '#102E74'
      //   }
      // },
      axisTick: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: '#102E74'
        }
      }
    }
  ],
  series: [
    {
      name: '文科',
      type: 'bar',
      data: getwkrs,
      barWidth: '12px',
      itemStyle: {
        normal: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: 'rgba(6,251,253,0.9)' // 0% 处的颜色
              },
              {
                offset: 1,
                color: 'transparent' // 100% 处的颜色
              }
            ],
            false
          ),
          barBorderRadius: [30, 30, 0, 0]
        }
      },
      markPoint: {
        data: markPointDatum
      }
    }
  ]
};

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值