echarts 去掉网格线、设置渐变色、标题图表位置、反转

本文介绍了如何在Echarts中实现去除网格线,调整图表标题位置,设置柱状图的渐变色以及进行坐标轴反转。通过splitLine属性可以去掉网格线,x和y轴的反转则通过xAxis和yAxis配置实现,而渐变色可以通过LinearGradient函数来设置。此外,还涉及到了图表grid的布局和坐标轴内容的定制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 去掉网格线:splitLine
          yAxis: [
            {
              // y轴不显示
              axisLine: {
                show: false
              },
              // 刻度不显示
              axisTick: {
                show: false
              },
              // 网格线不显示
              splitLine: {
                show: false
              },
              // 以上三个都不显示
              show: false,
              type: 'value'
            }
          ],
  • title位置:x
          // title: [
          //   {
          //     text: 'vvv',
          // 设置title的位置
          //     // x: '20%',
          //     textAlign: 'center'
          //   }
          // ],
  • 图表的位置:grid
          grid: [{
            top: '10',
            width: '80%',
            bottom: '16%',
            // left: 10,
            containLabel: true
          }],
  • 顺序反转:inserve
          xAxis: [
            {
              type: 'category',
              data: this.pvUvInfo.xKeyList,
              inverse: true
            }
          ],
  • x坐标、y坐标反转

xAxis yAxis中的内容替换就行

  • 柱形图四角圆润、添加渐变色、展示柱子的值

如果x坐标、y坐标反转后,设置渐变色 color: new this.echarts.graphic.LinearGradient(0, 0, 1, 0, [{

series: [
            {
              type: 'bar',
              smooth: true,
              barWidth: '20%',
              data: this.pvUvInfo.valueList,
              itemStyle: {
                normal: {
                  // 柱状角成椭圆形
                  barBorderRadius: 2,
                  //设置y轴方向的渐变色,
                  color: new this.echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                    offset: 0,
                    color: 'blue'
                  }, {
                    offset: 1,
                    color: '#0099FF'
                  }]),
                  // 设置柱子顶部展示值
                  label: {
                    show: true,
                    position: 'top'
                  }
                }
              }
            }
          ]
  • 坐标倾斜:
         xAxis: [
            {
              type: 'category',
              // gridIndex: 1,
              data: this.beidouTop10.xKeyList,
              // inverse: true,
              axisLabel: {
                interval: 0,
                rotate: 40
              }
            }
          ],

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值