Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw bar line even though the value is zero #2403

Closed
marbetschar opened this issue May 1, 2017 · 3 comments
Closed

Draw bar line even though the value is zero #2403

marbetschar opened this issue May 1, 2017 · 3 comments

Comments

@marbetschar
Copy link

I got a grouped bar chart and this works like a charm. However, to indicate there is data - even though the value of the data is zero - I'd like to have a bar drawn on every occasion.

Right now, the charting library draws the following:

wrong

But it should behave like follows - how can I achieve this? Unfortunately I've not found anything pointing me into the right direction :(

right

@marbetschar
Copy link
Author

marbetschar commented May 1, 2017

Doh! Got the solution: I just check the yValue during BarChartDataEntry creation and set it to a value slightly above zero.

BarChartDataEntry(x: xValue, y: yValue == 0.0 ? 0.01 : yValue)

Are there any downsides to this approach? Maybe this does not work, if the range of yValues is too large?

@liuxuan30
Copy link
Member

liuxuan30 commented May 3, 2017

I just want to say use 0.01 or 0.1 instead of 0. Something may happen is that, when your yMax is very large, e.g. 1 million, 0.01 can be ignored as well, so maybe use percentage like (yMax - yMin) * 0.01

@marbetschar
Copy link
Author

@liuxuan30 that's an awesome idea!! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants