4

I am trying to draw Multiple line chart using iOS-Charts danielgindi/Charts library by as show in picture.

Expected Output: enter image description here

Data1 = [Jun: 34, Jul: 42, Aug: 32, Sep: 30, Oct: 38]

Data2 = [Oct: 38, Nov: 40, Dec: 32, Jan: 40]

let dataSet1 = LineChartDataSet(values: Data1, label: nil)
dataSet1.lineDashLengths =[0]
dataSet1.drawCirclesEnabled = false

let dataSet2 = LineChartDataSet(values: Data2, label: nil)
dataSet2.lineDashLengths =[10]
dataSet2.drawCirclesEnabled = true

let data = LineChartData(dataSets:[dataSet1, dataSet2])
lineChartView?.data = data

I want to draw the first set with solid line and second set with Dotted line.

I am using iOS Charts library. (MultiLineChartView) The problem which I m facing is the dotted line also start at the beginning of x-Axis. (As shown below)

enter image description here

Could anyone help me on this please?

user1251007
  • 15,891
  • 14
  • 50
  • 76
Rameez
  • 312
  • 4
  • 20

1 Answers1

2

You must be having minimum and maximum for the x-Axis so you just have to set the starting x-axis for your second set to be the ending x-axis of the first data set. A very good example is included in the examples as CombinedChartViewController. Please try to run the demo and play with the x-Axis of any type of chart,

ChartDataEntry(x: 0.5, y: 30)
Kamran
  • 14,987
  • 4
  • 33
  • 51