0
votes

This seems to me like something pretty trivial to do, and I got it working on android but not on iOS, even after reading pretty thoroughly through previous issues and SO...

Anyhow, I'm simply trying to create a combined chart of historical price data that includes candlestick chart alongside volume indicators (bar charts) in the background. It comes out displaying like this:

enter image description here

Code is pretty straightforward and follows the example:

let set1 = CandleChartDataSet(values: yVals1, label: "Data Set")
set1.axisDependency = YAxis.AxisDependency.left
set1.setColor(UIColor(white: 80 / 255, alpha: 1))
set1.drawIconsEnabled = false
set1.shadowColor = .darkGray
set1.shadowWidth = 0.7
set1.decreasingColor = .red
set1.decreasingFilled = true
set1.increasingColor = UIColor(red: 122 / 255, green: 242 / 255, blue: 84 / 255, alpha: 1)
set1.increasingFilled = false
set1.neutralColor = .blue
set1.drawValuesEnabled = false
self.candleStickChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: xValues)
let candleStickData = CandleChartData(dataSet: set1)


let data = CombinedChartData()
let barChartDataSet = BarChartDataSet(values: barChartEntries, label: "values")
barChartDataSet.setColor(UIColor.rhLightGrey().withAlphaComponent(0.3))
barChartDataSet.axisDependency = YAxis.AxisDependency.right
let barChartData = BarChartData(dataSet: barChartDataSet)

data.candleData = candleStickData
data.barData = barChartData

self.candleStickChartView.rightAxis.axisMinimum = 0.0

self.candleStickChartView.data = data
self.candleStickChartView.setNeedsDisplay()

When I remove data.barData = barChartData it displays the candlestick fine, however I can't get the "scaling" to be dependent by the candlestick values (which are much lower) than the volume bars.

Any ideas?

Thanks!

1

1 Answers

0
votes

Seemed like a clean+re-build worked for me, doh