ivnsch / SwiftCharts

Easy to use and highly customizable charts library for iOS
Apache License 2.0
2.53k stars 410 forks source link

Change Candlestick Fill #296

Closed jimijon closed 7 years ago

jimijon commented 7 years ago

It seems like ChartCandleStickLayer has hard coded the fill colors of black and white for the candle in the candlestick chart.

What is the proper way to change this color?

c-st commented 7 years ago

It seems to me that the colours are currently hardcoded in ChartCandleStickLayer.generateScreenItems() and cannot be customized currently.

The code setting the colours based on whether the stick is decreasing or increasing is this one (adjusted to using red + green): let (rectTop, rectBottom, fillColor) = closeScreenY < openScreenY ? (closeScreenY, openScreenY, UIColor.green) : (openScreenY, closeScreenY, UIColor.red).

So either you can copy that file over to your project and customize it or you fork this project and adjust ChartCandleStickLayer to allow setting those colours in init.

Edit: I created a pull request allowing to customize the fill colours here: https://github.com/i-schuetz/SwiftCharts/pull/299

ivnsch commented 7 years ago

Pull request merged - closing this.