IOS Chart Error

2 posts, 0 answers
  1. Vasu
    Vasu avatar
    14 posts
    Member since:
    Jan 2006

    Posted 24 Nov 2014 Link to this post

    Hi,

    We are evaluating Shinobi and Telerik for our upcoming IOS Dashboard app.  I am trying to build a sample graph and am able to generate using Shinobi.  But when I am trying to use Telerik chart, I am getting following error.

    2014-11-24 10:02:01.237 CFOInfo[929:262175] Calling method which should be implemented in subclasses! Please FIX!
    2014-11-24 10:02:01.238 CFOInfo[929:262175] Calling method which should be implemented in subclasses! Please FIX!

    Following is my sample code of the view controller.


    import UIKit<br><br>class VCReportData : UIViewController, APIReportDataControllerProtocol {<br>    var strReportName: String?<br>    let kReportFormat: String = "JSON"<br>    var metaDataInfo : [ModelMetaData] =  [ModelMetaData]()<br>    var reportDataInfo: [ModelReportData] = [ModelReportData]()<br>    var chartView: UIView!<br><br>    var api : APIReportDataController?<br><br>    @IBOutlet weak var labelReportName: UILabel!<br>    var chart = TKChart()<br><br>    required init(coder aDecoder: NSCoder) {<br>        super.init(coder: aDecoder)<br>    }<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        api = APIReportDataController(delegate : self)<br>        api?.getReportData(strReportName: strReportName!, strReportFormat: kReportFormat)<br>        labelReportName.text = strReportName!<br>      <br><br>    }<br><br>    func didReceiveAPIResults(results : NSDictionary) {<br>        var results : NSDictionary  = results<br>        let dataSet : NSDictionary = results["dataset"] as NSDictionary<br>        let metaData : NSDictionary  = dataSet["metadata"] as NSDictionary<br>        let metaDataItems : NSArray = metaData["item"] as NSArray<br>        let arrayItems : Array<NSDictionary> = metaDataItems as Array<NSDictionary><br>        for metaItem in arrayItems {<br>            var m1 = ModelMetaData()<br>            m1.strName = metaItem["@name"] as String<br>            m1.strType = metaItem["@type"] as String<br>            m1.strLength = metaItem["@length"] as String!<br>            m1.strPrecision = metaItem["@precision"] as String!<br>            metaDataInfo.append(m1)<br>        }<br>        let reportData: NSDictionary = dataSet["data"] as NSDictionary<br>        let reportDataRow: NSArray = reportData["row"] as NSArray<br>        let arrayValues : Array<NSDictionary> = reportDataRow as Array<NSDictionary><br>        for rowItem in arrayValues {<br>            var rd1 = ModelReportData(strReportData:rowItem["value"] as NSArray)<br>            reportDataInfo.append(rd1)<br>        }<br>        dispatch_async(dispatch_get_main_queue(), {<br>            //self.drawShinobiChart()<br>            self.drawTelerikChart()<br>            UIApplication.sharedApplication().networkActivityIndicatorVisible = false<br>        })<br>    }<br><br>  <br>    func drawTelerikChart() {<br>        chartView =  UIView(frame: CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.width, self.view.bounds.height))<br>        chart = TKChart(frame: CGRectInset(chartView.bounds, 15, 15))<br>        chart.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight<br>        chartView.addSubview(chart)<br><br>        let xAxis = TKChartAxis()<br>        xAxis.position = TKChartAxisPosition.Bottom<br>        chart.addAxis(xAxis)<br><br>        let yAxis1 = TKChartNumericAxis()<br>        yAxis1.majorTickInterval = 500_000<br>        yAxis1.position = TKChartAxisPosition.Left<br>        yAxis1.style.lineHidden = false<br>        chart.addAxis(yAxis1)<br><br><br>        var budgetData = [TKChartDataPoint]()<br>        for i in 0..<reportDataInfo.count {<br>            budgetData.append(TKChartDataPoint(x: reportDataInfo[i].strReportData[0], y: reportDataInfo[i].strReportData[1]))<br>        }<br><br>        let series = TKChartColumnSeries(items: budgetData)<br>        series.xAxis = xAxis<br>        series.yAxis = yAxis1<br>        chart.addSeries(series)<br>    }<br>}<br>

    import UIKit

    class VCReportData : UIViewController, APIReportDataControllerProtocol {
        var strReportName: String?
        let kReportFormat: String = "JSON"
        var metaDataInfo : [ModelMetaData] =  [ModelMetaData]()
        var reportDataInfo: [ModelReportData] = [ModelReportData]()
        var chartView: UIView!

        var api : APIReportDataController?

        @IBOutlet weak var labelReportName: UILabel!
        var chart = TKChart()

        required init(coder aDecoder: NSCoder) {
            super.init(coder: aDecoder)
        }
        
        override func viewDidLoad() {
            super.viewDidLoad()
            api = APIReportDataController(delegate : self)
            api?.getReportData(strReportName: strReportName!, strReportFormat: kReportFormat)
            labelReportName.text = strReportName!
         

        }

        func didReceiveAPIResults(results : NSDictionary) {
            var results : NSDictionary  = results
            let dataSet : NSDictionary = results["dataset"] as NSDictionary
            let metaData : NSDictionary  = dataSet["metadata"] as NSDictionary
            let metaDataItems : NSArray = metaData["item"] as NSArray
            let arrayItems : Array<NSDictionary> = metaDataItems as Array<NSDictionary>
            for metaItem in arrayItems {
                var m1 = ModelMetaData()
                m1.strName = metaItem["@name"] as String
                m1.strType = metaItem["@type"] as String
                m1.strLength = metaItem["@length"] as String!
                m1.strPrecision = metaItem["@precision"] as String!
                metaDataInfo.append(m1)
            }
            let reportData: NSDictionary = dataSet["data"] as NSDictionary
            let reportDataRow: NSArray = reportData["row"] as NSArray
            let arrayValues : Array<NSDictionary> = reportDataRow as Array<NSDictionary>
            for rowItem in arrayValues {
                var rd1 = ModelReportData(strReportData:rowItem["value"] as NSArray)
                reportDataInfo.append(rd1)
            }
            dispatch_async(dispatch_get_main_queue(), {
                //self.drawShinobiChart()
                self.drawTelerikChart()
                UIApplication.sharedApplication().networkActivityIndicatorVisible = false
            })
        }

     
        func drawTelerikChart() {
            chartView =  UIView(frame: CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.width, self.view.bounds.height))
            chart = TKChart(frame: CGRectInset(chartView.bounds, 15, 15))
            chart.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            chartView.addSubview(chart)

            let xAxis = TKChartAxis()
            xAxis.position = TKChartAxisPosition.Bottom
            chart.addAxis(xAxis)

            let yAxis1 = TKChartNumericAxis()
            yAxis1.majorTickInterval = 500_000
            yAxis1.position = TKChartAxisPosition.Left
            yAxis1.style.lineHidden = false
            chart.addAxis(yAxis1)


            var budgetData = [TKChartDataPoint]()
            for i in 0..<reportDataInfo.count {
                budgetData.append(TKChartDataPoint(x: reportDataInfo[i].strReportData[0], y: reportDataInfo[i].strReportData[1]))
            }

            let series = TKChartColumnSeries(items: budgetData)
            series.xAxis = xAxis
            series.yAxis = yAxis1
            chart.addSeries(series)
        }
    }
  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 24 Nov 2014 Link to this post

    Hi Sreenivasa,

    Thank you for using our controls.

    TKChartAxis is a base class for all axes in TKChart and it should not be instantiated. You should use one of the predefined chart axes instead: TKChartNumericAxis, TKChartDateTimeAxis or TKChartCategoryAxisTKChart can create its axes automatically after you add a series, based on your data. Here is how you can achieve the described scenario writing less code:
    let yAxis1 = TKChartNumericAxis()
    yAxis1.majorTickInterval = 500_000
    yAxis1.style.lineHidden = false
    chart.yAxis = yAxis1
                     
    var budgetData = [TKChartDataPoint]()
    for i in 0..<reportDataInfo.count {
        budgetData.append(TKChartDataPoint(x: reportDataInfo[i].strReportData[0], y: reportDataInfo[i].strReportData[1]))
    }
             
    let series = TKChartColumnSeries(items: budgetData)
    chart.addSeries(series)

    You can read more about axes in TKChart in our documentation.

    I hope this helps. Should you have further questions, do not hesitate to contact us.

    Regards,
    Adrian
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
Back to Top