Charts
Charts copied to clipboard
Posibility to add Corner Radius for rounded bars in bar chart
Issue :link:
Many years people needs to fork this repo to implement rounded bars in bar chart. In pull requests exists also fixing same issue, but my implementation is more configurable
- You can add corner radius for specific corners only (for example only for topLeft + topRight corner)
- Corner radius works also for highlight when select bars
How to use:
var dataSet = BarChartDataSet(entries: yVals)
dataSet.cornerRadius = 6
dataSet.roundedCorners = .allCorners
// or
dataSet.roundedCorners = [.topLeft, .topRight]
@crash481 found an interesting "bug" if a chart has both negative and positive values. If you specify topLeft and topRight we end up with this, which is totally expected but makes it less useful on these types of charts. So in these cases we can round all corners. Unless we find a way to add the rounding parameter to the BarChartDataEntry
Yes, it needs to check if value is negative and invert values. One moment I will check if it is fast - I will push
Thanks so much! I'll try it out.
The highlighting works great btw.
Now if your can also add rounded corners to the pie chart... 😊
Okay, it was not so fast, but I did it This is not case for my project, but hope this will help you and others!
Pull request is now even better
I would be grateful if you test the work on HorizontalBarChart
and send a screenshot of the result here
@crash481 Works great
@crash481 Noticed a small bug: when the
dataSet.roundedCorners = .allCorners
is used the highlighted bottom corners disappear on this chart:
But they work fine on this chart:
@crash481 were you able to figure out the issue above?