【Echarts】实现顶部带光标的渐变柱状图

先上效果图

再上具体参数

const option = {
 xAxis: {
      type: 'category',
      data: ['1月','2月','3月'],
      axisLabel: {
        textStyle: {
          color: '#E6F7FF',
          fontSize: '14px'
        }
      }
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle: {
          type: "solid",
          color: ["rgba(255,255,255,0.1)"],
        },
        show: true,
      },
      axisLabel: {
        textStyle: {
          color: '#E6F7FF',
          fontSize: '14px'
        }
      }
    },
    grid: {
      left: '40px',   // 左侧内边距
      right: 0,  // 右侧内边距
      bottom: '40px', // 底部内边距
      top: '30px',
    },
    series: [
      {
        data: [1,2,3],
        type: 'bar',
        barWidth: '13.91px',
        itemStyle: {
          color: {
            type: "linearGradient", // 设置渐变类型
            shadowColor: "#159AFF",
            x1: 0,
            y1: 0,
            x2: 1,
            y2: 1,
            colorStops: [
              {
                // 设置渐变颜色
                offset: 0,
                color: "rgba(0, 58, 255, 0.2)", // 结束颜色为蓝色
              },
              {
                offset: 1,
                color: "#159AFF", // 起始颜色为红色
              },
            ],
          },
        },
        shadowColor: 'inset 0px 3px 0px 0px #159AFF',
        silent: true,
        markPoint: {
          data:[
             {
              symbol: "rect",
              symbolSize: [14, 2.5],
              xAxis: '1月', //x轴内容
              yAxis: '1', // y轴高度
              itemStyle: {
              color: "rgba(21, 154, 255, 1)",
              }
            },
             {
              symbol: "rect",
              symbolSize: [14, 2.5],
              xAxis: '2月', //x轴内容
              yAxis: '2', // y轴高度
              itemStyle: {
              color: "rgba(21, 154, 255, 1)",
              }
            },
            {
              symbol: "rect",
              symbolSize: [14, 2.5],
              xAxis: '3月', //x轴内容
              yAxis: '3', // y轴高度
              itemStyle: {
              color: "rgba(21, 154, 255, 1)",
              }
            }
          ]
        }
      }
    ]
  }
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值