danielgindi iOS Chart Can I have two different Yaxis scale on a combined chart

ios, ios-charts, swift, swift3

Solution

When I created the bar chart part of a combined chart like the one you are dealing with I did this:

    let data: BarChartData = BarChartData()                
    let set = BarChartDataSet(yVals: entries, label: “label text”)
    set.valueTextColor = UIColor.blackColor()
    set.valueFont = UIFont(name: "Verdana", size: 14.0)!
    let colors = [UIColor.greenColor(), UIColor.redColor()]
    set.setColors(colors, alpha: 1.0)
    set.stackLabels = [“Option 1”, “Option 2”]
    set.valueFormatter2 = BarValueFormatter()
    set.axisDependency = Charts.ChartYAxis.AxisDependency.Right
    data.addDataSet(set)
    return data

And probably the line you are missing is:

set.axisDependency = Charts.ChartYAxis.AxisDependency.Right

Problem

I have created a combined chart with line/bar. now, bar chart and line chart using same y scale as left axis(0-5). Can I have line chart remain with it but have bar chart stick to right axis scale(0-10)? linechart yaxis scale from(0-5), barchart yaxis scale from(0-10).

Original source