9

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

}

}
lil9porkchop
  • 231
  • 2
  • 6

4 Answers4

14

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

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
  • the question was for ios-chart. This mpandroidchart is for android and some of the functions in there are not available in ios-chart – anoo_radha May 26 '17 at 15:44
  • That's what I was searching for for android is the same but instead of no use `setDrawCircleHole(false)` and `setDrawCircles(false)` – Skizo-ozᴉʞS ツ Oct 31 '21 at 21:25
10

to remove circle in a line

lineChartDataSet.drawCirclesEnabled = false

to remove value alone in a circle

lineChartData.drawValuesEnabled = false
pragadeesh
  • 97
  • 1
  • 5
3

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
Ahmed M. Hassan
  • 709
  • 9
  • 14
-1
lineChartDataSet.circleRadius = 0
Abdul Rasheed
  • 6,486
  • 4
  • 32
  • 48
Stalker
  • 47
  • 4