echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] 正负条形图,当series的data为0时,0的显示位置错位

Open shujuliuguyu opened this issue 1 month ago • 3 comments

Version

5.6.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/editor.html?c=bar-negative&code=tVHBasMwDL3vK3zzpYUm6RjL2GGHDXYYDFbYYfSgJmpi5trBdtaW0X-f5CRNaWGnDYxkyU_We5JtgrJG3IvvKyGCtTqoJo8BhU5VFbpcSNgpLycxyddXq0zghw5HyH2DBPM1lHYrY_JA9sAlGis05YAtIUAuPuTjrkHjkX4V8tkUdoNyOVTsHqgHgWLBWYsv0C2OHZaM3_-CLyBgZd2-Z9_xX6jicyQvhK_tNhdr0B77XORxyvfFGqa6oObk3rGMUd2ye3KK3RuE6FoTpZwQ9OgUXjA0sGGGvfqhYc97Be6Y8gGYr1zYAPqY1bBCfakiuBYHiBCN9YoXTNW0zDp0kzvRh5umBs_jGz9a26KlhOxoX5T0I8nS2UTQyeYJmZs5mVsK59ds0lk_gq7oTPK4_P8WrXH9l5pJ2jTJUrYzUk13kj1NWPc0zaJNBuW8_KvD3Q8&enc=deflate

Steps to Reproduce

1.本bug基于此例子修改https://echarts.apache.org/examples/zh/editor.html?c=bar-negative 2.访问此网站后,左边替换为以下内容

option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {
    data: ['Expenses', 'Income']
  },
  xAxis: [
    {
      type: 'value'
    }
  ],
  yAxis: [
    {
      type: 'category',
      axisTick: {
        show: false
      },
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    }
  ],
  series: [
    {
      name: 'Income',
      type: 'bar',
      stack: 'Total',
      label: {
        show: true,
        position: 'right'
      },
      emphasis: {
        focus: 'series'
      },
      data: [320, 0, 341, 374, 390, 450, 420]
    },
    {
      name: 'Expenses',
      type: 'bar',
      stack: 'Total',
      label: {
        show: true,
        position: 'left'
      },
      emphasis: {
        focus: 'series'
      },
      data: [0, -132, -101, -134, -190, -230, -210]
    }
  ]
};

Current Behavior

Image

Expected Behavior

见上面的图片

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

shujuliuguyu avatar Nov 12 '25 01:11 shujuliuguyu

@shujuliuguyu It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Bug] Positive and negative bar charts, when the data of the series is 0, the display position of 0 is misaligned

echarts-bot[bot] avatar Nov 12 '25 01:11 echarts-bot[bot]

duplicate of #21003, #15572, #14975

helgasoft avatar Nov 12 '25 03:11 helgasoft

As a workaround, it seems you can set stackStrategy: 'negative' for the Expenses series. The expense is usually a negative number, so it should be feasible for this scenario.

See the stackStrategy option.

plainheart avatar Nov 12 '25 17:11 plainheart