Search code examples
ios-charts

IOS-Charts cannot show any x-axis labels in a line chart


(Hopefully simple question) How do I get X-axis labels to show. I want four words to show in a line chart with multiple plots.

The plots and everything else works beautifully!


Solution

  • You need to specify the x-axis labels title when you create the LineChartData object:

    let chartData = LineChartData(xVals: labels, dataSet: dataSet)
    chartView.data = chartData
    

    The xVals parameter is the x-axis label title array.

    You can check out how it's done in the example project: https://github.com/danielgindi/ios-charts, ChartsDemo folder