Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Line chart with 2 dataSets

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?

like image 821
Rameez Avatar asked Oct 15 '25 05:10

Rameez


1 Answers

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)
like image 130
Kamran Avatar answered Oct 16 '25 19:10

Kamran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!