0

I am using th swift Charts library. I'm trying to show a candle chart but it does not correctly showing data. After running it will be show just one item but if i will zoom in it will be show all items,

how immediately showing every item after running without needed to zoom ?

func setupCandleChart() {
   // candleChartView.autoScaleMinMaxEnabled = true // if enable this doesn't show anything
    setCandleDataCount(5, range: 30)
}

func setCandleDataCount(_ count: Int, range: UInt32) {
    let yVals1 = (0..<count).map { (i) -> CandleChartDataEntry in
        let mult = range + 1
        let val = Double(arc4random_uniform(40) + mult)
        let high = Double(arc4random_uniform(9) + 8)
        let low = Double(arc4random_uniform(9) + 8)
        let open = Double(arc4random_uniform(6) + 1)
        let close = Double(arc4random_uniform(6) + 1)
        let even = i % 2 == 0

        return CandleChartDataEntry(x: Double(i), shadowH: val + high, shadowL: val - low, open: even ? val + open : val - open, close: even ? val - close : val + close)
    }
    
    
    let set1 = CandleChartDataSet(entries: yVals1, label: "Data Set")
    let data = CandleChartData(dataSet: set1)
    candleChartView.data = data
}

enter image description here

if i will zoom:

enter image description here

7
  • I ran your code and it works fine for me. Where are you calling setupCandleChart() method? Btw what is the usage of UISliders showed in your screenshots, could there be a side effect due to those? Commented Sep 23, 2021 at 14:20
  • @SamB do u use the latest version of these library (4.0.1) ? uislider for data generator, first slider its count, second slider its range Commented Sep 23, 2021 at 14:58
  • i ran example from github and its work same :( Commented Sep 23, 2021 at 14:59
  • @SamB the setupCandleChart() method i calling in xibSetup function. Do u use ios 15 ? Commented Sep 23, 2021 at 15:05
  • My setup is iOS 14.4 and Charts 3.6.0. I have added the chart programmatically and calling setupCandleChart() in loadView() Commented Sep 23, 2021 at 15:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.