I'm learning ios-charts. I was using the tutorial found here. The first picture shows the result I am getting. How do you remove the blue circle dots so that it only shows a smooth line like what is shown in the second picture?
Here is snippet of the code
import UIKit
import Charts
class ChartsViewController: UIViewController {
@IBOutlet weak var lineChartView: LineChartView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0]
setChart(months, values: unitsSold)
}
func setChart(dataPoints: [String], values: [Double]) {
var dataEntries: [ChartDataEntry] = []
for i in 0..<dataPoints.count {
let dataEntry = ChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}
let lineChartDataSet = LineChartDataSet(yVals: dataEntries, label: "Units Sold")
let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
lineChartView.data = lineChartData
}
}
Set the .setDrawCircles = NO;
of your LineDataSet
set to disable the drawing of circle.
It was on the wiki...
https://github.com/PhilJay/MPAndroidChart/wiki/DataSet-classes-in-detail
to remove circle in a line
lineChartDataSet.drawCirclesEnabled = false
to remove value alone in a circle
lineChartData.drawValuesEnabled = false
In addition to the answers, you can use these properties to make your line more smooth
lineChartDataSet.drawCirclesEnabled = false
lineChartDataSet.drawCubicEnabled = true
or you can use mode property as drawCubicEnabled property is deprecated
lineChartDataSet.mode = .cubicBezier
lineChartDataSet.cubicIntensity = 0.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With