maho125
maho125

Reputation: 33

iOS Charts - How to set different color of exact vertical grid line than have others

In my application I'm using iOS Charts and I want to split my line chart to sectors by vertical grid line with different color than have others (someting like on chart below). I looked into documentation but I didn't find any solution how to do that. I know only how to change color of all grid lines at once. Thanks for any advice.

example chart

UPDATE:

Here is my solution. I have array with x positions for vertical lines and in for loop I will add limit lines to chart.

for k:Int in 0 ..< limitLines.count {

        let limitLine = ChartLimitLine()
        limitLine.lineColor = UIColor.red
        limitLine.limit = limitLines[k]
        limitLine.lineWidth = 0.8
        lineChartView.xAxis.addLimitLine(limitLine)

 }

Here is resulting chart.

enter image description here

Upvotes: 2

Views: 2816

Answers (1)

Wingzero
Wingzero

Reputation: 9754

well.. this is not officially supported, but you could override drawGridLine() on x axis to do so, just need to know which grid line needs another color.

Upvotes: 1

Related Questions