首页 > 其他分享 >y轴标签与柱状图样色统一 echarts

y轴标签与柱状图样色统一 echarts

时间:2023-09-28 10:00:47浏览次数:34  
标签:index style show true 标签 value 图样 type echarts

option = {
  title: {
    text: 'World Population'
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {},
 
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01],
    position: 'top',
    axisLine: {
      show: true,
    },
       axisTick:{
      show: true
      },
     splitLine: {
       show: false
     }
  },
  yAxis: {
    type: 'category',
    data: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World'],
    inverse: true,
    axisLine: {
      show: false,
    },
    axisTick:{
      show: false
    },
     axisLabel:{
       show: true,
      // align: 'center',
      // backgroundColor: '#3B98FE',
  formatter: function (value,index) {
        if(index == 0){
           return '{style' + index + '| ' + value + '}';
        }
        return '{style| ' + value + '}';
      },
        
      rich:{
        style0: {
          backgroundColor: 'red',
          padding:[5,12],
          // height:36
        },
        style: {
          backgroundColor: '#3B98FE',
          padding: [5, 12]
        }
      },
      // padding: [5, 12],
       color: "#fff",
       borderRadius: [3, 0, 0, 3]
     }
  },
  series: [
    {
      name: '2011',
      type: 'bar',
       barWidth: 36,
       label: {
        offset:[20,0],
      },
      data: [18203, 23489, 29034, 104970, 131744, 630230].reverse(),
      itemStyle:{
        borderRadius: [0, 18, 18, 0],
        normal: {
                            color: function(params) {
                                // 给出颜色组
                                var colorList = ['#FF6977', '#FFA448', '#00C891', '#3B98FE'];
                //循环调用
                if(params.dataIndex<4){
                  return colorList[params.dataIndex]
                }else{
                  return colorList[3]
                }
                                
                            },
                            borderRadius: [0, 18, 18, 0],
                        }
      }
    }

  ]
};

 

标签:index,style,show,true,标签,value,图样,type,echarts
From: https://www.cnblogs.com/zeosky-zhe/p/16275838.html

相关文章

  • echarts折线图 分段柱形图
    option={tooltip:{trigger:'axis',axisPointer:{//Useaxistotriggertooltiptype:'shadow'//'shadow'asdefault;canalsobe'line'or'shadow'}},legend:{t......
  • HTML中的常见标签
    HTML中的常见标签<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><metaname="viewport"content=&q......
  • 基于vue封装的Tag标签双击编辑单击选中可删除
    ......
  • Springboot+Echarts(五)
    Mybatis-plus操作的多表查询和分页查询今天首先回顾了之前所学的基本的单表增删改查这里想再自己写一遍是为了方便自己以后的开发流程顺利首先创建Springboot项目,选择java8和Springboot2.x.x之后选择Web依赖然后添加依赖<dependency><groupId>com.baomidou<......
  • 给tbody标签设置高度
    给tbody标签设置高度/max-height通过搜索得到三种方法1.在tbody上使用CSS设置高度,并给tbody设置"display:block;"属性。2.将tbody的内容放入一个div中,并设置div的高度。3.动态设置tbody的高度。使用方法1:`tbody{display:block}`此时可以给tbody设置......
  • echarts 响应式自动适应宽度
    beforeMount(){window.addEventListener('resize',this.$_resizeHandler)},beforeDestroy(){window.removeEventListener('resize',this.$_resizeHandler)},  ......
  • a标签打开文档有问题,增加target="_parent" 属性就好了
    以上是问题截图,点击a标签的时候提示的,看起来是js问题,但是没报错,引用也没问题。后来增加target="_parent"属性就好了。 ......
  • HTML <a> 标签的 target 属性
    https://www.w3school.com.cn/tags/att_a_target.asp<a>标签的target属性规定在何处打开链接文档。打开新窗口:<ahref="pref.html"target="view_window">Preface</a>在框架中打开窗口:<framesetcols="100,*"><framesrc="toc.h......
  • 前端a标签下载文件
    问题描述:后端直接返回牵牛的文件储存地址,前端想自定义下载文件的名称不成功解决办法:转为get请求,将返回值改为blod格式/***用于后端直接返回url牵牛下载地址并且需要自定义下面文件名称*@param{请求参数}data{url,fileName}*/vardownload=function(url,fil......
  • 流量治理的基石——基于字节码增强的全链路流量标签透传
     作者:李来   华为云高级软件工程师一、全链路流量标签透传在微服务架构中,流量标签用于对流量进行标记和分类,能够在微服务之间实现更精细的路由、负载均衡和流控等流量治理能力。以HTTP报文为例,每一条header都可以是一条流量标签,比如x-sermant-version:v1表示通过Sermant流......