I've created a BarChart using BarChartView
from ios-Charts but I can't figure out howto add rounded corners to bars.
This is the code that I'm using:
let barChart: BarChartView
//...
var xVals = [String]()
var yVals = [BarChartDataEntry]()
//...
let set1 = BarChartDataSet(yVals: yVals, label: "Label")
set1.drawValuesEnabled = false
set1.highlightLineWidth = 3
set1.colors = [UIColor.whiteColor()]
barChart.data = BarChartData(xVals: xVals, dataSet: set1)
I've looked for a property like set1.barCornerRadius
to set, but I didn't find anything.
Here is what I have:
Here is what I need:
In BarChartRenderer.swift
you can to modify open func drawDataSet(context: CGContext, dataSet: IBarChartDataSet, index: Int)
Then there's if-statement
for stacked and nonstacked bars, choose your case and remove:
context.fill(barRect)
and instead of it add:
let bezierPath = UIBezierPath(roundedRect: barRect, cornerRadius: %YOUR_CORNER_RADIUS%)
context.addPath(bezierPath.cgPath)
context.drawPath(using: .fill)