I have a code that makes a bubble chart, but I want to the bubbles to have numbers written in them. Please can anyone advise?
Here is the sample code that returns a bubble in the form of BubbleChartDataEntry. I want the bubbles to have numbers as seen below:
Currently, my code returns the graph below
I want to keep the x-axis
func setDataCount(_ count: Int, range: UInt32) {
let yVals1 = (0..<count).map { (i) -> BubbleChartDataEntry in
let val = Double(arc4random_uniform(range))
let size = CGFloat(arc4random_uniform(range))
return BubbleChartDataEntry(x: Double(i), y: val, size: size, icon: UIImage(named: "icon"))
}
let yVals2 = (0..<count).map { (i) -> BubbleChartDataEntry in
let val = Double(arc4random_uniform(range))
let size = CGFloat(arc4random_uniform(range))
return BubbleChartDataEntry(x: Double(i), y: val, size: size, icon: UIImage(named: "icon"))
}
let yVals3 = (0..<count).map { (i) -> BubbleChartDataEntry in
let val = Double(arc4random_uniform(range))
let size = CGFloat(arc4random_uniform(range))
return BubbleChartDataEntry(x: Double(i), y: val, size: size)
}
let set1 = BubbleChartDataSet(entries: yVals1, label: "DS 1")
set1.drawIconsEnabled = false
set1.setColor(ChartColorTemplates.colorful()[0], alpha: 0.5)
set1.drawValuesEnabled = true
let set2 = BubbleChartDataSet(entries: yVals2, label: "DS 2")
set2.drawIconsEnabled = false
set2.iconsOffset = CGPoint(x: 0, y: 15)
set2.setColor(ChartColorTemplates.colorful()[1], alpha: 0.5)
set2.drawValuesEnabled = true
let set3 = BubbleChartDataSet(entries: yVals3, label: "DS 3")
set3.setColor(ChartColorTemplates.colorful()[2], alpha: 0.5)
set3.drawValuesEnabled = true
let data = [set1, set2, set3] as BubbleChartData
data.setDrawValues(false)
data.setValueFont(UIFont(name: "HelveticaNeue-Light", size: 7)!)
data.setHighlightCircleWidth(1.5)
data.setValueTextColor(.white)
chartView.data = data
}

I have fixed it.