apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.11k stars 19.6k forks source link

[Bug] barMinHeight is always showing last stacked series even if value is zero #20197

Open ofir-zeitoun-ib opened 1 month ago

ofir-zeitoun-ib commented 1 month ago

Version

5.4.3

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWszGAG0iAXMmuhgE4QDmFApqYQOQCGAHhAM70A0x6xAvt3QVyAE0KoSsbNQBmYBgGYApFx6xyFABbzY9ACwrBJAEbAwmALaLDagMYwwjCNAAyjY9WyEwpAK7V-I2YAQVY2QgBtNQlJDABPEGoGW0YwagpgUjjVWNgRVMZI-gBZGC5dABV_cvoAdWoRGorNXxqAMXIagGVU7t9oegBdI0kWdgqIWwBrcTVR7EpoWogwTTcPLzJ_Odg-NT30YeI40PZI6J2wBKTdADdGbGr94iP0NloIanDYKMkYyWgjAsN3oABEIKRqLYwDlYldEgxjIxSLDJEjSMsRKsGAA2AAMNlybEc0wYFicAxGJmRxWcAAlqJRtIQ9FT0PlHJE8ZxYABWABMPP5eO5sAUClZYoAnKLxaL-cLBvsqf8SIDgQxwZDofzUSR4SD0Xr0OjMdjdPjCbFiYxSbpyc5jbB0bToAymTpWTsOYUfqKBUKRTzxZKFDLgwp5YrnocUHwANxAA&renderer=svg

Steps to Reproduce

  1. options:

    
    option = {
    tooltip: {
    trigger: 'axis',
    
    },
    grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
    },
    xAxis: [
    {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
      axisTick: {
        alignWithLabel: true
      }
    }
    ],
    yAxis: [
    {
      type: 'value'
    }
    ],
    series: [
    {
      name: 'Direct',
      type: 'bar',
      barWidth: '60%',
      stack: 'main',
      barMinHeight: 4,
      data: [0, 52, 200, 334, 390, 330, 220]
    },
    {
      name: 'Direct2',
      type: 'bar',
      barWidth: '60%',
      stack: 'main',
      barMinHeight: 4,
      data: [0, 52, 200, 334, 390, 330, 220]
    }
    ]
    };

### Current Behavior

see on Monday is showing the green bar even though Monday has zero 0 values

### Expected Behavior

if value is zero, no need for barMinHeight

### Environment

```markdown
- OS: Mac
- Browser: chrome
- Framework: Vue

Any additional comments?

No response

ofir-zeitoun-ib commented 1 month ago

Monday has 0 values image

helgasoft commented 1 month ago

if you want to 'see' zero value, then do not use barMinHeight

ofir-zeitoun-ib commented 1 month ago

let's say I have values stacked of 1000 and 1, the one will not be seen. but sometimes a zero value appears in other columns

@helgasoft , that was not an answer I expected

helgasoft commented 1 month ago

let's say I have values stacked of 1000 and 1, the one will not be seen.

All small values will be seen if barMinHeight is set. That's the purpose of it. Demo

ofir-zeitoun-ib commented 1 month ago

This confuses users to believe there is a value while its zero (on Monday in the example) if it is zero, don't show, if it is small, use barMinHeight

helgasoft commented 1 month ago

if it is zero, don't show, if it is small, use barMinHeight

then use color function - Demo.

ofir-zeitoun-ib commented 1 month ago

nice, but still it works only on the last declaration.

see this example (I changed the demo you sent me)

itemStyle= {color: cc => {return (cc.value==0) ? 'transparent' : cc.color; }};
option = {
  tooltip: { trigger: 'axis' }, legend:{},
  xAxis: [
    {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed'],
      axisTick: { alignWithLabel: true }
    }
  ],
  yAxis: {},
  series: [
    {
      name: 'Direct',
      type: 'bar',
      stack: 'main', 
      barMinHeight: 4,
      data: [0, 100, 1],
      label:itemStyle
    },
    {
      name: 'Direct2',
      type: 'bar',
      stack: 'main', 
      barMinHeight: 4,
      data: [0, 52, 1000], 
      label: itemStyle
    }
  ]
};
ofir-zeitoun-ib commented 1 month ago

We have critical bug, if it help... 🙏

see deferent cases:

itemStyle= {color: cc => {return (cc.value==0) ? 'transparent' : cc.color; }};

option = {
  tooltip: { trigger: 'axis' }, legend:{},
  xAxis: [
    {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed'],
      axisTick: { alignWithLabel: true }
    }
  ],
  yAxis: {},
  // works
  // series: [
  //   {
  //     name: 'Direct',
  //     type: 'bar',
  //     stack: 'main', 
  //     barMinHeight: 4,
  //     data: [0, 52, 1000],
  //     label:{show:true}, itemStyle
  //   },
  //   {
  //     name: 'Direct2',
  //     type: 'bar',
  //     stack: 'main', 
  //     barMinHeight: 4,
  //     data: [0, 52, 1], 
  //     label:{show:true}, itemStyle
  //   }
  // ],

  // doesn't work (small value not on last series)
  series: [
    {
      name: 'Direct',
      type: 'bar',
      stack: 'main', 
      barMinHeight: 4,
      data: [0, 52, 1],
      label:{show:true}, itemStyle
    },
    {
      name: 'Direct2',
      type: 'bar',
      stack: 'main', 
      barMinHeight: 4,
      data: [0, 52, 1000], 
      label:{show:true}, itemStyle
    }
  ],

  // works (reverse series)
  // series: [

  //   {
  //     name: 'Direct2',
  //     type: 'bar',
  //     stack: 'main', 
  //     barMinHeight: 4,
  //     data: [0, 52, 1000], 
  //     label:{show:true}, itemStyle
  //   },
  //   {
  //     name: 'Direct',
  //     type: 'bar',
  //     stack: 'main', 
  //     barMinHeight: 4,
  //     data: [0, 52, 1],
  //     label:{show:true}, itemStyle
  //   },
  // ]

};
helgasoft commented 1 month ago

that's a known bug, still not fixed, see #16565 and #17005 works properly in versions V5.2.2 and below

ofir-zeitoun-ib commented 3 weeks ago

We can't downgrade...