• echarts中横向柱状图的数字在条纹上方


    实现效果: 数字在条纹的上方在这里插入图片描述
    实现方法:这些数字是用新添加一个坐标轴来实现的
    直接添加坐标轴数字显示是在条纹的正右边
    在这里插入图片描述
    所以需要配置一下偏移在这里插入图片描述
    完整代码

    var option = {
          grid: {
            left: "3%",
            right: "4%",
            bottom: "3%",
            containLabel: true,
          },
          xAxis: {
            type: "value",
            boundaryGap: [0, 0.01],
            axisLine: {
              show: false,
            },
            axisLabel: {
              show: false,
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "#121f33",
              },
            },
          },
          yAxis: [
            {
              type: "category",
              data: ["aa", "bb", "cc", "dd"],
    
              axisLine: {
                show: true,
                lineStyle: {
                  color: "#2a4661",
                },
              },
              axisTick: {
                show: false,
              },
              axisLabel: {
                color: "#b8babd",
              },
            },
            {
              type: "category",
              position: "right",
              offset: -40,
              inverse: false,
              axisTick: "none",
              axisLine: "none",
              show: true,
              axisLabel: {
                textStyle: {
                  height: 30,
                  width: 30,
                  padding: [0, 0, 10, 0],
                  color: "#03d0d4",
                  fontSize: "16",
                },
              },
              //------------------右侧展示的具体内容----------------------------
              data: [
                {
                  value: "89%",
                  textStyle: {
                    color: "#03ced1",
                    verticalAlign: "bottom",
                  },
                },
                {
                  value: "58%",
                  textStyle: {
                    color: "#03ced1",
                    verticalAlign: "bottom",
                  },
                },
                {
                  value: "66%",
                  textStyle: {
                    color: "#03ced1",
                    verticalAlign: "bottom",
                  },
                },
                {
                  value: "74%",
                  textStyle: {
                    color: "#03ced1",
                    verticalAlign: "bottom",
                  },
                },
              ],
            },
          ],
          series: [
            {
              type: "bar",
              showBackground: true,
              backgroundStyle: {
                color: "rgba(13, 32, 66, 0.5)",
                borderRadius: 10,
              },
              itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                  { offset: 0, color: "#021a52" },
                  { offset: 0.5, color: "#019cb5" },
                  { offset: 1, color: "#00fdfe" },
                ]),
                borderRadius: 10,
              },
              barWidth: "20",
    
              data: [89, 58, 66, 74],
            },
          ],
        };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113

    放在实例中运行即可
    https://echarts.apache.org/examples/zh/editor.html?c=pie-simple

  • 相关阅读:
    11.Nginx-Rewrite
    软件设计模式系列之十六——命令模式
    【机器学习】文本多分类
    工厂人员违规行为识别系统
    Spring Boot 邮件发送(五种类型的邮件)
    出栈序列的合法性
    Python爬虫动态ip代理防止被封的方法
    treectrl类封装 2023/8/13 下午4:07:35
    Unity:InputField账号密码输入
    autohotkey 记录
  • 原文地址:https://blog.csdn.net/weixin_44689966/article/details/134085734