-3

I wanted to remove 'description text' view, 'data set' view (square shape view below the graph). I am using iOS Charts library - LineChartView

import Charts
---------------------- class declaration -------------------
@IBOutlet var graphEmotionsView: LineChartView! // Class outlet variable
let paramsList = ["","Anger" , "Disgust", "Fear", "Joy", "Sadness",""]
let paramsListVal = ['give some values']

In viewdidload //Set graph emotions view befor applying the data self.graphEmotionsView.backgroundColor = UIColor.lightGrayColor()

    //Gestures
    self.graphEmotionsView.doubleTapToZoomEnabled = false
    self.graphEmotionsView.pinchZoomEnabled = false

    //Highlight per tap
    self.graphEmotionsView.highlightPerTapEnabled = false
    self.graphEmotionsView.highlightPerDragEnabled = false
    self.graphEmotionsView.highlightFullBarEnabled = false


    //X
    self.graphEmotionsView.xAxis.labelPosition = .BottomInside
    self.graphEmotionsView.xAxis.labelTextColor = UIColor.whiteColor()

    var yVals1 : [ChartDataEntry] = [ChartDataEntry]()

    for i in 0 ..< emotionParamsValues.count {

        yVals1.append(ChartDataEntry(value: emotionParamsValues[i], xIndex: i+1))
    }
    print("yValues: \(yVals1)")

    let set2: LineChartDataSet = LineChartDataSet()
    set2.yVals = yVals1
    set2.label = ""
    set2.visible = true

    // set chart line
    set2.mode = .CubicBezier
    set2.axisDependency = .Left
    set2.lineWidth = 2.5
    set2.setColor(UIColor(red: 157/255.0, green: 0/255.0, blue: 38/255.0, alpha: 1.0))
    set2.highlightColor = UIColor.whiteColor()

    // set custom point
    set2.drawCirclesEnabled = true // should be true if you want hollow circles

    set2.drawCircleHoleEnabled = true
    set2.circleHoleRadius = 5.0
    set2.setCircleColor(UIColor(red: 157/255.0, green: 0/255.0, blue: 38/255.0, alpha: 1.0))

    // set fill chart
    set2.drawFilledEnabled = true
    set2.fillAlpha = 240 / 255.0
    set2.fillColor = UIColor(red: 237/255.0, green: 26/255.0, blue: 103/255.0, alpha: 0.9)

    var dataSets : [LineChartDataSet] = [LineChartDataSet]()
    dataSets.append(set2)

    dataSets[0].notifyDataSetChanged()

    let data: LineChartData = LineChartData(xVals: emotionParamsList, dataSets: dataSets)
    data.setValueTextColor(UIColor.whiteColor())

    self.graphEmotionsView.data = data

Output I am getting

SUNiL iOS
  • 129
  • 1
  • 8

1 Answers1

1

For fixing the description, try:

    chart.description = ""

For disable the legend, try:

    chart.legend.enabled = false

Shameless plug - you can find ios charts examples at ioscharts.io

Alex
  • 674
  • 6
  • 18