-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Bug with showing negative values and vertical zooming Horizontal Bar Chart #1702
Comments
At first I can't reproduce so I removed the bug tag, until I see it changes x values to negative; |
…ing bottom fails Similar to Bar chart renderer logic, continue if checking left fails, while break if checking right fails
I did a quick look, it is because the check for j in stride(from: 0, to: buffer.rects.count, by: 1)
{
let barRect = buffer.rects[j]
if (!viewPortHandler.isInBoundsTop(barRect.origin.y + barRect.size.height))
{
break // <-- where negative values break at first, so no rendering
}
if (!viewPortHandler.isInBoundsBottom(barRect.origin.y))
{
continue
} that break. However while testing it is far more than I estimate the impact. It happens in both bar chart and horizontal bar chart while zooming and scrolling. So my commit does not fix it at all. When trying to fix negative x values, it breaks positive x values; so I guess we can't simply fix it by changing around break/continue. For horizontal bar chart, what I found is that for negative values, the buffer.barRects origin y values are ascending, while the positive values, they are descending. Forcing sorting the origin y values could be a solution, but not perfect. @danielgindi any insights rather than sort barRects? Bar chart should be similar. Also we need to fix |
@valery-demin if you are hurry, one quick workaround is you could try to make sure x values are ascending (-5,-4,-3,-2,-1,0), when adding them. |
@danielgindi I have thought over it again, we had an implication that the x values should be ascending; people are not aware of this so weird thing happens. |
@liuxuan30 It must be ordered by definition, as we use the order to make quick searches through the values, and also optimize rendering loops by stopping when passed the last value to render. @valery-demin you should use |
|
I am trying to use these Charts for showing negative values on Horizontal Bar Chart.
![horizontal bar chart](https://cloud.githubusercontent.com/assets/5167253/19627631/bd6bd400-9953-11e6-86ce-5550bbc14898.gif)
For horizontal zooming it works well but for vertical it has bug.
I have prepared GIF with this bug (from Demo project):
I have added
-i
instead ofi
in this string (https://github.com/danielgindi/Charts/blob/master/ChartsDemo/Classes/Demos/HorizontalBarChartViewController.m line 122):[yVals addObject:[[BarChartDataEntry alloc] initWithX:-i * spaceForBar y:val]];
How can I avoid this behavior?
The text was updated successfully, but these errors were encountered: