-
-
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
HorizontalBarChartView drawValueAboveBarEnabled label rendering issue #124
Comments
@PhilJay I'm thinking if label width > bar width (horz) or if label height > bar height (vert) - draw above bar... |
@danielgindi Was wondering if you could point me in the right direction of where that label would be drawn. I was going to experiment a little bit and see if I could fix this myself, but I can't seem to find what I'm looking for. Thanks in advance! |
@danielgindi in order to fix this, i compared the valueTextWidth to the actual value of the BarChartDataEntry, as the width of the bar seems to be equal to the value of data entry. Starting at line 358 of HorizontalBarChartRenderer, I did the following: // calculate the correct offset depending on the draw position of the value
var valueTextWidth = valueText.sizeWithAttributes([NSFontAttributeName: valueFont]).width
if (Double(valueTextWidth)> val && !drawValueAboveBar)
{
//use the offset for drawValueAboveBar = true
posOffset = valueOffsetPlus
negOffset = -(valueTextWidth + valueOffsetPlus)
}
else
{
posOffset = (drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus))
negOffset = (drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus)
} I'm sure the same fix could work for the vertical bar charts, just with height instead of width, but I'm not familiar with them, as I'm not using vertical bar charts with labels in my project. If you want to let me know where you think this fix would need to be implemented, I can try to get a pull request done, otherwise I can make a pull request just for this one. |
@mcooksey It seems this fix doesn't work. |
@pashikua What version of ios-charts are you on? I haven't had a chance to try it on the latest code base. |
@mcooksey I used latest source. |
is there any update on above bug ? I am not able to see label on Bar while i use Horizontal Bar in my app. Thanks in advance! |
When i set my HorizontalBarChartView's drawValueAboveBarEnabled to false, I get the following layout issue when the BarChart has a y Value too small to fit the value label
In this case, I set the third bar to have a value of 1.00.
Do you have any ideas of how I can get that label to render on the right side of the bar instead of the left?
The text was updated successfully, but these errors were encountered: