echarts implements the horizontal column chart text on the column chart

Foreword:

    echarts implements horizontal column chart text on the column chart

Effect picture:

Implementation source code:

<div id="lip" style="width:100%;height:800px;"></div>

<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>

<script>
  function initEchartsFh() {
      
    var myChart = echarts.init(document.getElementById('lip'));
    var option = {
        grid: {
          left: "5%",
          right: "2%",
          width:"80%",
          bottom: "2%",
          top: "8%",
          containLabel: true
        },
        xAxis: {
          type: "value",

          splitLine: {
            show: false
          },
          axisLabel: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          }
        },
        yAxis: [
          {
            type: "category",
            inverse: true,
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
          },
          {
            type: "category",
            inverse: true,
            axisTick: "none",
            axisLine: "none",
            show: true,
            axisLabel: {
              textStyle: {
                color: "#F5784C",
                fontSize: "16"
              }
            },
            //------------------右侧展示的具体内容----------------------------
            data: [
                    {
                      value:"10%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"20%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"30%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"40%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"50%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"60%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"70%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"10%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"10%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:"10%",
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                  ],
          },
          {//名称
          type: 'category',
            offset: -10,
            position: "left",
            axisLine: {
              show: false
            },
            inverse: false,
            axisTick: {
              show: false
            },
            axisLabel: {
              interval: 0,
              color: ["#333"],
              align: "left",
              verticalAlign: "bottom",
              lineHeight: 32,
              fontSize: 16
            },
            //------------------文字描述----------------------------
            data: ['1号 60人完成','2号','3号','4号','5号','6号','7号','1号','1号','1号']
          },
        ],
        series: [
          {
            zlevel: 1,
            type: "bar",
            barWidth: "15px",
            animationDuration: 1500,
            //------------------数据及其样式----------------------------
            data: [
                    {
                      value:10,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:20,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:30,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:40,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:50,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:60,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:70,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:10,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:10,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                    {
                      value:10,
                      itemStyle:{
                        color:"#FFCB9B"
                      }
                    },
                  ],
            align: "center",
            itemStyle: {
              normal: {
                barBorderRadius: 10
              }
            }
          },
          {
            type: "bar",
            barWidth: 15,
            barGap: "-100%",
            margin: "20",
            //------------------背景按最大值----------------------------
            data: [100,100,100,100,100,100,100,100,100,100],
            textStyle: {
              //图例文字的样式
              fontSize: 10,
              color: "#fff"
            },
            itemStyle: {
              normal: {
                color: "#FFF9F3",
                //width:"100%",
                fontSize: 10,
                barBorderRadius: 30
              },
            }
          }
        ]

    };
    myChart.setOption(option);
  }
  window.onload = function(){
    initEchartsFh();
  }
  window.onresize = function(){
    initEchartsFh();
  }
</script>

Official website related address: https://www.makeapie.com/editor.html?c=xqjNqqjc_U

It ends here!

Guess you like

Origin blog.csdn.net/qq_41619796/article/details/114872296