Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candle Stick does not show #3239

Closed
Patrick3131 opened this issue Feb 4, 2018 · 0 comments
Closed

Candle Stick does not show #3239

Patrick3131 opened this issue Feb 4, 2018 · 0 comments

Comments

@Patrick3131
Copy link

Patrick3131 commented Feb 4, 2018

Hey!
I could successfully implement the framework to get a line chart but now I want to try to get get a candle stick chart, but the candle stick chart wont show up. The X and Y axis get created and align to the data I set, but the graph itself does not appear.

This is the code I am using:

    class GraphCreation {
        
        let chartData: [ChartData]
        
        init(chartData: [ChartData]) {
            self.chartData = chartData
    
        }
        
        func chartCreationLine(chartView: LineChartView) -> LineChartView {
        
        var lineChartEntry = [ChartDataEntry]()
        
        for i in 0..<chartData.count {
        let value = ChartDataEntry(x: Double(i), y: chartData[i].open)
        lineChartEntry.append(value)
        }
        let line1 = LineChartDataSet(values: lineChartEntry, label: "Number")
        
        let data = LineChartData()
        data.addDataSet(line1)
        chartView.data = data
        chartView.chartDescription?.text = "Chart"
        
        return chartView
        }
        
        func chartCreationCandle(chartView: CandleStickChartView) -> CandleStickChartView {
            var candleChartEntry = [CandleChartDataEntry]()
            
            for i in 0..<chartData.count {
                let value = CandleChartDataEntry(x: Double(i), shadowH: chartData[i].high, shadowL: chartData[i].low, open: chartData[i].open, close: chartData[i].close)
                candleChartEntry.append(value)
                
            }
            
            let set1 = CandleChartDataSet(values: candleChartEntry, label: "Chart")
    
            let data = CandleChartData()
            data.addDataSet(set1)
            chartView.data = data
            
            chartView.chartDescription?.text = "Candle Stick"
            
            
            
            return chartView
        }
        
    }

I of course looked at the demos already, but could not figure out what the problem is or what is missing.

I also set a chartView outlet in the Viewcontroller.

screen shot 2018-02-05 at 00 05 42
screen shot 2018-02-04 at 23 57 15

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant