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

DataSource and Delegate aren't called #10

Closed
anirudhamahale opened this issue Apr 6, 2017 · 1 comment
Closed

DataSource and Delegate aren't called #10

anirudhamahale opened this issue Apr 6, 2017 · 1 comment

Comments

@anirudhamahale
Copy link

I created swift 3 project and ran pod install with ANDLineChartView (0.2.2) and implemented the DataSource and Delegate methods, Setting the DataSource and Delegate in ViewDidLoad but the methods associating with the DataSource and Delegate aren't called.

@anaglik
Copy link
Owner

anaglik commented Apr 6, 2017

I can't reproduce it. Here is an example UIViewController that I created today. Please try this in you project and let me know if you still have any issues.

import UIKit
import ANDLineChartView

class ViewController: UIViewController {
    lazy var chartView: ANDLineChartView = {
        let chartView = ANDLineChartView(frame: CGRect(origin: .zero, size: self.view.bounds.size))
        chartView.delegate = self
        chartView.dataSource = self
        return chartView
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.addSubview(self.chartView)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
extension ViewController: ANDLineChartViewDelegate {
    
}
extension ViewController: ANDLineChartViewDataSource {
    func numberOfElements(in chartView: ANDLineChartView!) -> UInt {
        return 10
    }
    func numberOfGridIntervals(in chartView: ANDLineChartView!) -> UInt {
        return 6
    }
    func chartView(_ chartView: ANDLineChartView!, valueForElementAtRow row: UInt) -> CGFloat {
        return CGFloat(row) * 2.0
    }
    func chartView(_ chartView: ANDLineChartView!, descriptionForGridIntervalValue interval: CGFloat) -> String! {
        return "\(interval)"
    }
    func maxValueForGridInterval(in chartView: ANDLineChartView!) -> CGFloat {
        return 30
    }
    func minValueForGridInterval(in chartView: ANDLineChartView!) -> CGFloat {
        return -4
    }
}

@anaglik anaglik closed this as completed Apr 6, 2017
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

2 participants