Search code examples
iosswiftios-charts

iso-chart BarChart with rounded corners


Is there a setting in the BarChartView to enable rounded corners for the bars?

I want to achieve a similar effect to this other library iosbarchart enter image description here


Solution

  • i did a fork of ios-charts to roughly accomplish this: https://github.com/mcconkiee/ios-charts

    var yVals: [BarChartDataEntry] = []
                    var xVals: [String] = []
                    var dataCount = sections.count
                    for i in 0...(dataCount - 1) {
                        var dataObjectInstance = sections[i] as SomeCustomDataObject
                        var entry = BarChartDataEntry(value: dataObjectInstance.numeric!, xIndex: i)
                        entry.rounded = true //make the end caps round!
                        if let tintClr = dataObjectInstance.tint as String?{
                            if let clr = UIColor(hexString: tintClr) as UIColor?{
                                entry.tint = clr
                            }
                        }
                        yVals.append(entry)
                        var time = i % 12
                        if(time == 0) {
                            time = 12
                        }
                        if let objVal = dataObjectInstance.objectValue as String?{
                            xVals.append(objVal)
                        }
    
                    }