Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove the dots in LineChartView iOS charts

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? This is the result I am getting

This is what I am trying to get

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

}

}
like image 404
lil9porkchop Avatar asked May 17 '16 05:05

lil9porkchop


3 Answers

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

like image 195
David 'mArm' Ansermot Avatar answered Nov 10 '22 00:11

David 'mArm' Ansermot


to remove circle in a line

lineChartDataSet.drawCirclesEnabled = false

to remove value alone in a circle

lineChartData.drawValuesEnabled = false
like image 26
pragadeesh Avatar answered Nov 10 '22 02:11

pragadeesh


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
like image 3
Ahmed M. Hassan Avatar answered Nov 10 '22 02:11

Ahmed M. Hassan