echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Y-axis, type:'log' , series type :'bar', the first data value is 0, the bars on charts is not normal.

Open hks2002 opened this issue 6 years ago • 16 comments

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'log'
    },
    series: [{
        data: [0, 200, 150, 80, 70, 110, 130],
        type: 'bar'
    }]
};

image

hks2002 avatar Jan 20 '19 11:01 hks2002

log(0) is -Infinity. So after removing 0 it will be OK. But it is needed to be think whether to trade 0 as an empty data.

100pah avatar Jan 22 '19 21:01 100pah

Yes,removing 0 it will be OK. Based the series type is 'bar', normally, data 0 should be accepted. and the bar length should be zero. As you said, if Echarts trade 0 as an empty data when Y-axis type is 'log' should be a good practices.

hks2002 avatar Jan 23 '19 13:01 hks2002

IMHO: also negative numbers (and 0) should be treated as empty

tmtron avatar Feb 11 '19 16:02 tmtron

Hi @100pah Is there any update on this issue? It is essential in most enterprise applications to allow users to switch between log scale and linear scale, and zero/negative values should be treated as empty in those cases.

pavish avatar Aug 15 '19 08:08 pavish

@100p @pavish It might not be ideal, but I've switch the data to null when the value is zero/negative and switch it back to its original value when using the linear scale.

jonavila avatar Aug 15 '19 12:08 jonavila

@100p @pavish It might not be ideal, but I've switch the data to null when the value is zero/negative and switch it back to its original value when using the linear scale.

@jonavila I guess I can use that for now, until the issue is fixed. Thanks!

pavish avatar Aug 15 '19 14:08 pavish

@jonavila I have found a better workaround for the moment. While changing linear axis to log axis just change min value config option to 1. eg., yAxis: { type: 'log', min: 1 }

Although, if your values are lesser than 1, just set the min value to the least value in your data.

pavish avatar Aug 25 '19 09:08 pavish

@100pah any updates on this?

dashed avatar Mar 04 '20 03:03 dashed

Years later and still not fixed? If you have one zero data point in your series you can't really use log axis currently....

Diesmo avatar Apr 21 '22 23:04 Diesmo

@100pah is possible to replace all 0 to null by dataset transform ?

trade 0 as an empty data should be as simple as possible

MeetzhDing avatar Jun 21 '22 12:06 MeetzhDing

hello guyz, any update on this ? my data are dynamic and i cant replace the 0 with null or empty data because it's a big difference in my case , (0 means no traffic and null means i fetched no data at this time), please if someone has a fix let me know

hannata avatar Oct 05 '22 09:10 hannata

in my case , (0 means no traffic and null means i fetched no data at this time), please if someone has a fix let me know

workaround - replace 0 with '' (empty string) and keep the nulls too.

This issue seems to be related to data preparation, not a ECharts bug. Label priority-high is a kind of a overkill.

helgasoft avatar Apr 18 '23 04:04 helgasoft

This issue seems to be related to data preparation, not a ECharts bug. Label priority-high is a kind of a overkill.

I disagree. 0 is a valid integer which should not cause a charting library to break.

pavish avatar Apr 18 '23 11:04 pavish

hello guyz, any update on this ? my data are dynamic and i cant replace the 0 with null or empty data because it's a big difference in my case , (0 means no traffic and null means i fetched no data at this time), please if someone has a fix let me know

the same here, 0 and null should be treated separately :(

sunface avatar Aug 08 '23 08:08 sunface

any updates!!

Khalilsqu avatar Feb 18 '24 20:02 Khalilsqu

I solved using NaN instead of 0

JacopoBonta avatar May 10 '24 12:05 JacopoBonta