柱状图的柱子样式(顶部样式,数值统一显示在最顶部或一侧)

该博客介绍了如何利用Echarts库创建一种象形柱图,展示不同站台的上下客人数。通过定义数据和配置项,实现了斜箭头形状的柱状图,并使用线性渐变颜色增加视觉效果。同时,柱状图中包含了站名、人数以及内部和右侧的数值标签,为数据可视化提供了一种创新方式。
摘要由CSDN通过智能技术生成
效果图

在这里插入图片描述
斜箭头图片在这里插入图片描述

代码

提示:通过象形柱图实现

//站台上下客人数排行
var updown = document.getElementById('updown');
var updowndata = [["马家村", "马家", "张陈家", "港边路口", "杭商院北门"], [10, 13, 15, 18, 23],]
function updownNum(dom, data) {
  var updown = echarts.init(dom)
  // 指定图表的配置项和数据
  var undownoption = {
    grid: {  //图表的上下左右的距离
      left: '10%',
      right: '4%',
      bottom: '10%',
      top: '8%',
      padding: '0 0 0 0',
      containLabel: true,
    },
    tooltip: {},
    xAxis: {
      axisLabel: {
        show: false
      },
      splitLine: {
        show: false
      }
    },
    yAxis: {
      type: "category",
      data: data[0],
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        textStyle: {
          color: '#00c0d3',
          fontStyle: 'normal',
          fontSize: 16,
        }
      }

    },
    series: [
      {
        name: '人数',
        type: 'pictorialBar',
        z: -1,
        barWidth: 15,
        data: data[1],
        //将一个图片作为数据大小的变化基准  及斜箭头柱体图片
        symbol: 'image://../img/bgimg/zhuzhuangtu.png',
        symbolOffset: [0, '60%'],
        // symbolSize1:['100%', '100%'],
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0, 0, 1, 0,
              [
                { offset: 0, color: '#112e4f' },
                { offset: 1, color: '#0380e1' }
              ]
            ),
            label: {
              // show: true, //开启显示
              position: 'right',
              textStyle: { //数值样式
                color: '#00c0d3',
                fontSize: 16
              }

            },
          },

        }
      },
      {
        name: '人数',
        type: 'pictorialBar',
        data: data[1],
        barWidth: 35,
        z: 1,
        symbol: 'react', //你所看到的栅格背景  通过栅格背景控制数据显示
        symbolRepeat: 'fixed',//设置固定可让数据在统一位置显示

        symbolSize: ['6%', '100%'],
        symbolMargin: 1,
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0, 0, 1, 0,
              [
                {
                  offset: 0,
                  color: 'rgba(0, 122, 204, 0.2)'
                },
              ]
            ),
            label: {
              show: true, //开启显示
              position: 'insideRight',
              textStyle: { //数值样式
                color: '#00ffff',
                fontStyle: 'italic',
                fontSize: 16
              }

            },
          },

        }
      },

    ]
  };
  // 使用刚指定的配置项和数据显示图表。
  updown.setOption(undownoption);
}
updownNum(updown, updowndata)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LBY_XK

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值