diogobernardino / williamchart

Android Library to rapidly develop attractive and insightful charts in android applications.
5.09k stars 799 forks source link

BarChartView doesn't start drawing from zero #286

Closed ugurcany closed 3 years ago

ugurcany commented 3 years ago

For BarChartView, when I set scale sth like "-5, +5", it always draws columns starting from the bottom (-5). Is there a way to enforce drawing starting from point zero (0)? I believe it's a more accurate and common way to draw a bar chart. As an example: image

diogobernardino commented 3 years ago

The fact that it can handle a negative scale comes as a surprise to me, I never had that usecase in mind. If there's enough demand for such feature I can consider implement it.

A side note regarding your example: would you expect the bar to overlap the x label? For example, "B" is behind the bar, thus not so much visible.

ugurcany commented 3 years ago

For my case, I'm drawing x labels at the bottom of chart, not on zero axis. So, not overlapping.

Btw, I forked the repo and changed couple of stuff. Now I'm using the forked version in my project. If you like you can check the PR I created. It's up to you to merge it or not.

ugurcany commented 3 years ago

My comment is both for animation and also visual representation of negative and positive values in the same chart. For instance, currently if scale is sth like (-2,+5), then all values are drawn in an animation which starts from the axis of -2. However, this should not be the case. All bars should be originated from the 0 axis and animated starting from there.

diogobernardino commented 3 years ago

I deleted my comment before seeing your response. In the end I found more inconsistencies, so it might require a bit more than just fixing the animation. If it still turns out to be a simple addition, I can consider shipping it. I will keep the issue opened for now. Thanks for your input.

diogobernardino commented 3 years ago

I got something working for (vertical) bar charts, only in dev for now. I have to test it a bit more and eventually apply it to horizontal bar charts too.