echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[question] Bar Chart Grid Not Fully Utilized Due to containLabel Setting Resulting in Blank Space at Bottom

Open ryanuo opened this issue 1 year ago • 6 comments

Version

5.5.0

Link to Minimal Reproduction

Steps to Reproduce

未铺满div

Current Behavior

配置grid后,出现未填充满div问题

option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: [
    {
        "type": "category",
        "position": "bottom",
        "data": [
            "Alipay+",
            "",
            ""
        ],
        "axisLabel": {
            "color": "#ffffff",
            "fontSize": 12,
            "lineHeight": 16
        }
    },
    {
        "type": "category",
        "position": "bottom",
        "data": [
            "",
            "WF",
            ""
        ],
        "axisLabel": {
            "color": "#ffffff",
            "fontSize": 12,
            "lineHeight": 16
        }
    },
    {
        "type": "category",
        "position": "bottom",
        "data": [
            "",
            "",
            "HK Biz"
        ],
        "axisLabel": {
            "color": "#ffffff",
            "fontSize": 12,
            "lineHeight": 16
        }
    }
],
  yAxis: [
    {
      type: 'value'
    }
  ],
  series:[
    {
        "name": "USD",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 0,
        "data": [
            1000000000015.99
        ]
    },
    {
        "name": "USD",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 1,
        "data": [
            "",
            999999999999.99
        ]
    },
    {
        "name": "USD",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 2,
        "data": [
            "",
            "",
            999999999999.99
        ]
    },
    {
        "name": "EUR",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 0,
        "data": [
            1080699999999.91
        ]
    },
    {
        "name": "CNY",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 1,
        "data": [
            "",
            1408400000000
        ]
    },
    {
        "name": "CNY",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 2,
        "data": [
            "",
            "",
            1408400000000
        ]
    },
    {
        "name": "Others(US $)",
        "type": "bar",
        "barWidth": 22,
        "xAxisIndex": 1,
        "data": [
            "",
            2115000000000
        ]
    }
]
};

Expected Behavior

这样写是为了过滤为0的数据,不进行占位 现在解决了这个问题 出现了占不满div的问题

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

ryanuo avatar May 14 '24 04:05 ryanuo

@Ovilia @helgasoft 大佬可以帮忙看下吗,这个为占满div问题 底部空的较多,是因为我有多个xAxis的问题吗? image

ryanuo avatar May 15 '24 09:05 ryanuo

This has nothing to do with containLabel. You're using three xAxis so they will have 9% of the chart's height.

Ovilia avatar May 16 '24 06:05 Ovilia

This has nothing to do with containLabel. You're using three xAxis so they will have 9% of the chart's height.

那如果xAxis的个数是动态的呢这个 chart's height 如何拿呢, 我尝试使用bottom为-%,就是不知道这个高度的计算逻辑

ryanuo avatar May 16 '24 10:05 ryanuo

how to get the chart's height?

there is getHeight

helgasoft avatar May 16 '24 23:05 helgasoft

how to get the chart's height?

there is getHeight

How to remove the blank space at the bottom when using ContainLabel @helgasoft

ryanuo avatar May 17 '24 03:05 ryanuo

@rr210, we are not supposed to answer "how to" questions here. The recommendations are:


The issue list is reserved exclusively for bug reports and feature requests. For usage questions, please use the following resources:


try axisLabel: { show: false, to remove bottom space, and even better: redesign of your chart.

helgasoft avatar May 17 '24 17:05 helgasoft