Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5020
Most Performant Chart Configuration with These Realm Objects
posted

I need advice on the most performant setup for a IGChartView with a line series. It's really basic, but I'm second guessing the previous designs that I've used because maybe something new has been released in the interim. Here are my realm objects:

class RecordingRow: Object {

    dynamic var createdOn:NSDate = NSDate()

    let measurements = List<Measurement>()

}

class Measurement: Object {

    dynamic var value:Double?    

}

Measurement order is guaranteed. Time interval between measurements is also static. However, measurement values are optional and should be displayed differently on the chart (i.e. not a straight line between the last known value and the next valid value). My goal is to chart one "column" of this data. I must avoid calculating timestamp strings as much as possible because they are expensive, so those should be dynamic (delegate?).
Specifically:
• Do I create a DataSourceHelper and package up my data in Arrays?
• Is there an easy delegate pattern to use here?
Parents
No Data
Reply
  • 26458
    Offline posted

    Hi,

    This should be pretty straight forward with the category line series and a datasource helper. Your options for empty values are to either interpolate between two known values or create breaks in your line. This is done with unknownValuePlotting property of the IGLineSeries. I'm not sure exactly what you plan on doing with the optional values, but if you just want to omit them, you can use the entire column of your data in the datasource helper.
     
    By default the category labels get pre-calculated, but you can turn that off by setting autoGenerateLabels to false on your datasource helper and instead use a delegate method off IGChartViewDelegate:

    optional public func chartView(chartView: IGChartView, labelForAxis axis: IGAxis, withItem item: NSObject, oldLabel: String) -> String

     

Children