How do you make a line chart dashed using the nifty iOS Charts? It is done this way in the Android charts version, but that approach does not work for iOS.
Asked
Active
Viewed 2,260 times
1 Answers
3
Adjust the LineChartDataSet using .lineDashLenghts
. Example usage below:
// Set data to the line chart and format
let dataSet = LineChartDataSet(entries: chartDataArray)
dataSet.lineWidth = 3
dataSet.lineDashLengths = [5]

Ben
- 3,346
- 6
- 32
- 51
-
1And you can add more dashes adding more lengths to pattern, something like this - dataSet.lineDashLengths = [5, 1, 9, 3, 4] – Denis Kozhukhov Jan 07 '21 at 12:08
-
Good call out Denis. For example, doing [5, 15] would give dashes of length 5 and spacing of 15. – Ben May 21 '21 at 17:50