vue x轴文字纵向显示 - echart图表

介绍:

实现修改坐标轴颜色,x轴字体垂直显示

如图所示:在这里插入图片描述
代码如下:
<template>
  <div class="ml20 mr20 mb20 colorFOp">
    <div class="head tc mb20 ">测试案例</div>
      <div ref="test" class="testChart"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  data() {
    return {
      myTestChart:{},
    };
  },
  mounted() {
    this.testChart()
    window.onresize = ()=>{//窗口变化自动重载
      this.myTestChart.resize()
    }
  },
  methods: {
    testChart(){
      this.myTestChart = echarts.init(this.$refs.test);
      let option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {           
            type: 'shadow'       
          }
        },
        grid: {
          left: '15',
          right: '15',
          bottom: '5',
          top:'30',
          containLabel: true //防止标签溢出
        },
        xAxis: [
          {
            type: 'category',
            axisTick:{//隐藏刻度
              show:false,
            },
            axisLine: {
              show: true,
              lineStyle: {
                type: 'solid',
                color: '#fff',//x边线的颜色
                width:'1'//坐标线的宽度
              }
            },
            axisLabel: {
              rotate:-90,//x轴竖向展示
              interval:0,//刻度间隔
              textStyle: {
                color: '#fff',//坐标值得具体的颜色
                fontSize:12
              }
            },
            data:Array.from({length:12},(v,k)=>`${k+1}月份`)
          }
        ],
        yAxis: [
          {
            name: '万',
            nameTextStyle:{ //文字颜色
              color:"#65ABE7", 
              fontSize:12,  
            },
            type: 'value',
            splitLine:{
              show: false
            },
            axisLine: {
              show: true,
              lineStyle: {
                type: 'solid',
                color: '#fff',//左边线的颜色
                width:'1'//坐标线的宽度
              }
            },
            axisLabel: {
              textStyle: {
                color: '#fff',//坐标值得具体的颜色
              }
            }
          }, 
        ],
        color:['#00CEDE','#F00067','#1055D6'],
        series: [{
          name: '',
          type:'bar',
          data: [11,10,12,13,10,11,6,9,8,10,10,8],
          stack: 'total', //累加
          barWidth : 18,//柱图宽度
          itemStyle: {
            normal: {
              barBorderRadius:[0,0,25,25]//圆角
            }
          },
        },{
          name: '',
          type:'bar',
          data: [9,7,6,10,7,8,12,13,8,10,11,7],
          stack: 'total',//累加
          barWidth : 18,//柱图宽度
        },{
          name: '',
          type:'bar',
          data: [8,10,7,6,15,11,18,9,16,10,5,5],
          stack: 'total',//累加
          barWidth : 18,//柱图宽度
          itemStyle: {
            normal: {
              barBorderRadius:[25,25,0,0]//圆角
            }
          },
        }]
      }

      // 使用刚指定的配置项和数据显示图表。
      this.myTestChart.setOption(option);
    },
  },
};
</script>

<style lang="scss" scoped>
  .testChart{
    margin:100px auto;
    width:850px;
    height: 50vh;
  }
  .title{
    font-size: 16px;
    color: #00F8FD;
    line-height: 42px;
  }
</style>

外传:

台风,大风呼啸。

echarts纵向折线图可以实现多条纵坐标以及包含警戒线的功能。在y坐标中,可以重复写多个坐标,通过设置position属性来控制坐标的位置。例如,可以设置左侧的坐标和右侧的坐标分别显示不同的数据。同时,可以对每个坐标进行个性化设置,比如设置坐标的名称、刻度格式以及线条颜色等。 对于包含警戒线的功能,可以通过在x或者y中添加markLine来实现。markLine是用来标记线段的组件,可以设置不同的线段样式、起始点和终点以及值的范围。通过设置警戒线的位置和样式,可以提醒用户某个数据超出了预期范围。 因此,通过echarts的相关配置和设置,我们可以实现纵向折线图的多条纵坐标和包含警戒线的功能。这样可以更加清晰地展示不同数据的变化趋势,并提醒用户关注异常情况。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [echarts图表折线图点击纵向区域获取所有点的数据](https://download.youkuaiyun.com/download/zhangpeng710538178/10652480)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [vueechart折线图的使用(多条纵坐标)(警戒线横向纵向)使用(markLine),以及多坐标叠在一起解决](https://blog.youkuaiyun.com/weixin_46565787/article/details/122099194)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

刘斩仙的笔记本

富贵险中求

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

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

打赏作者

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

抵扣说明:

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

余额充值