Skip to content

Commit

Permalink
Extended Realm examples
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Jan 16, 2016
1 parent 1ff2e5c commit bbacc37
Show file tree
Hide file tree
Showing 49 changed files with 1,926 additions and 217 deletions.
54 changes: 54 additions & 0 deletions Charts/Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,60 @@
5BD4C5821BCDBF6C00462351 /* ScatterChartDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD4C57B1BCDBF6C00462351 /* ScatterChartDataProvider.swift */; };
5BD8F06D1AB897D500566E05 /* ChartViewPortHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD8F06C1AB897D500566E05 /* ChartViewPortHandler.swift */; };
5BD8F06E1AB89AD800566E05 /* HorizontalBarChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6A54A01AA66B6A000F57C2 /* HorizontalBarChartView.swift */; };
659400811BF4632F004F9C27 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6594007F1BF4632F004F9C27 /* Realm.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
659400821BF4632F004F9C27 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6594007F1BF4632F004F9C27 /* Realm.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
659400831BF4632F004F9C27 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659400801BF4632F004F9C27 /* RealmSwift.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
659400841BF4632F004F9C27 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659400801BF4632F004F9C27 /* RealmSwift.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
652F554B1BDFE24B00898CFD /* BarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55301BDFE24B00898CFD /* BarChartData.swift */; };
652F554C1BDFE24B00898CFD /* BarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55301BDFE24B00898CFD /* BarChartData.swift */; };
652F554D1BDFE24B00898CFD /* BarChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55311BDFE24B00898CFD /* BarChartDataEntry.swift */; };
652F554E1BDFE24B00898CFD /* BarChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55311BDFE24B00898CFD /* BarChartDataEntry.swift */; };
652F554F1BDFE24B00898CFD /* BarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55321BDFE24B00898CFD /* BarChartDataSet.swift */; };
652F55501BDFE24B00898CFD /* BarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55321BDFE24B00898CFD /* BarChartDataSet.swift */; };
652F55511BDFE24B00898CFD /* BarLineScatterCandleBubbleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55331BDFE24B00898CFD /* BarLineScatterCandleBubbleChartData.swift */; };
652F55521BDFE24B00898CFD /* BarLineScatterCandleBubbleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55331BDFE24B00898CFD /* BarLineScatterCandleBubbleChartData.swift */; };
652F55531BDFE24B00898CFD /* BarLineScatterCandleBubbleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55341BDFE24B00898CFD /* BarLineScatterCandleBubbleChartDataSet.swift */; };
652F55541BDFE24B00898CFD /* BarLineScatterCandleBubbleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55341BDFE24B00898CFD /* BarLineScatterCandleBubbleChartDataSet.swift */; };
652F55551BDFE24B00898CFD /* BubbleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55351BDFE24B00898CFD /* BubbleChartData.swift */; };
652F55561BDFE24B00898CFD /* BubbleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55351BDFE24B00898CFD /* BubbleChartData.swift */; };
652F55571BDFE24B00898CFD /* BubbleChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55361BDFE24B00898CFD /* BubbleChartDataEntry.swift */; };
652F55581BDFE24B00898CFD /* BubbleChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55361BDFE24B00898CFD /* BubbleChartDataEntry.swift */; };
652F55591BDFE24B00898CFD /* BubbleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55371BDFE24B00898CFD /* BubbleChartDataSet.swift */; };
652F555A1BDFE24B00898CFD /* BubbleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55371BDFE24B00898CFD /* BubbleChartDataSet.swift */; };
652F555B1BDFE24B00898CFD /* CandleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55381BDFE24B00898CFD /* CandleChartData.swift */; };
652F555C1BDFE24B00898CFD /* CandleChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55381BDFE24B00898CFD /* CandleChartData.swift */; };
652F555D1BDFE24B00898CFD /* CandleChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55391BDFE24B00898CFD /* CandleChartDataEntry.swift */; };
652F555E1BDFE24B00898CFD /* CandleChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55391BDFE24B00898CFD /* CandleChartDataEntry.swift */; };
652F555F1BDFE24B00898CFD /* CandleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553A1BDFE24B00898CFD /* CandleChartDataSet.swift */; };
652F55601BDFE24B00898CFD /* CandleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553A1BDFE24B00898CFD /* CandleChartDataSet.swift */; };
652F55611BDFE24B00898CFD /* ChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553B1BDFE24B00898CFD /* ChartData.swift */; };
652F55621BDFE24B00898CFD /* ChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553B1BDFE24B00898CFD /* ChartData.swift */; };
652F55631BDFE24B00898CFD /* ChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553C1BDFE24B00898CFD /* ChartDataEntry.swift */; };
652F55641BDFE24B00898CFD /* ChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553C1BDFE24B00898CFD /* ChartDataEntry.swift */; };
652F55651BDFE24B00898CFD /* ChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553D1BDFE24B00898CFD /* ChartDataSet.swift */; };
652F55661BDFE24B00898CFD /* ChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553D1BDFE24B00898CFD /* ChartDataSet.swift */; };
652F55671BDFE24B00898CFD /* CombinedChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553E1BDFE24B00898CFD /* CombinedChartData.swift */; };
652F55681BDFE24B00898CFD /* CombinedChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553E1BDFE24B00898CFD /* CombinedChartData.swift */; };
652F55691BDFE24B00898CFD /* LineChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553F1BDFE24B00898CFD /* LineChartData.swift */; };
652F556A1BDFE24B00898CFD /* LineChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F553F1BDFE24B00898CFD /* LineChartData.swift */; };
652F556B1BDFE24B00898CFD /* LineChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55401BDFE24B00898CFD /* LineChartDataSet.swift */; };
652F556C1BDFE24B00898CFD /* LineChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55401BDFE24B00898CFD /* LineChartDataSet.swift */; };
652F556D1BDFE24B00898CFD /* LineRadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55411BDFE24B00898CFD /* LineRadarChartDataSet.swift */; };
652F556E1BDFE24B00898CFD /* LineRadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55411BDFE24B00898CFD /* LineRadarChartDataSet.swift */; };
652F556F1BDFE24B00898CFD /* LineScatterCandleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55421BDFE24B00898CFD /* LineScatterCandleChartDataSet.swift */; };
652F55701BDFE24B00898CFD /* LineScatterCandleChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55421BDFE24B00898CFD /* LineScatterCandleChartDataSet.swift */; };
652F55711BDFE24B00898CFD /* PieChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55431BDFE24B00898CFD /* PieChartData.swift */; };
652F55721BDFE24B00898CFD /* PieChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55431BDFE24B00898CFD /* PieChartData.swift */; };
652F55731BDFE24B00898CFD /* PieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55441BDFE24B00898CFD /* PieChartDataSet.swift */; };
652F55741BDFE24B00898CFD /* PieChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55441BDFE24B00898CFD /* PieChartDataSet.swift */; };
652F55751BDFE24B00898CFD /* RadarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55451BDFE24B00898CFD /* RadarChartData.swift */; };
652F55761BDFE24B00898CFD /* RadarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55451BDFE24B00898CFD /* RadarChartData.swift */; };
652F55771BDFE24B00898CFD /* RadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55461BDFE24B00898CFD /* RadarChartDataSet.swift */; };
652F55781BDFE24B00898CFD /* RadarChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55461BDFE24B00898CFD /* RadarChartDataSet.swift */; };
652F55791BDFE24B00898CFD /* ScatterChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55471BDFE24B00898CFD /* ScatterChartData.swift */; };
652F557A1BDFE24B00898CFD /* ScatterChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55471BDFE24B00898CFD /* ScatterChartData.swift */; };
652F557B1BDFE24B00898CFD /* ScatterChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55481BDFE24B00898CFD /* ScatterChartDataSet.swift */; };
652F557C1BDFE24B00898CFD /* ScatterChartDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652F55481BDFE24B00898CFD /* ScatterChartDataSet.swift */; };
659400A01BF463C1004F9C27 /* BarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659400871BF463C1004F9C27 /* BarChartData.swift */; };
659400A11BF463C1004F9C27 /* BarChartData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659400871BF463C1004F9C27 /* BarChartData.swift */; };
659400A21BF463C1004F9C27 /* BarChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659400881BF463C1004F9C27 /* BarChartDataEntry.swift */; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Realm.Dynamic

public class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDataSet
{
private func initialize()
public override func initialize()
{
self.highlightColor = UIColor.blackColor()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import UIKit
import Realm
import Realm.Dynamic

public class RealmBarLineScatterCandleBubbleDataSet: RealmDataSet, IBarLineScatterCandleBubbleChartDataSet
public class RealmBarLineScatterCandleBubbleDataSet: RealmBaseDataSet, IBarLineScatterCandleBubbleChartDataSet
{
// MARK: - Data functions and accessors

Expand Down
10 changes: 8 additions & 2 deletions Charts/Classes/Data/Implementations/Realm/RealmBaseDataSet.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// RealmDataSet.swift
// RealmBaseDataSet.swift
// Charts
//
// Created by Daniel Cohen Gindi on 23/2/15.
Expand Down Expand Up @@ -30,6 +30,8 @@ public class RealmBaseDataSet: ChartBaseDataSet

// default color
colors.append(UIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))

initialize()
}

public override init(label: String?)
Expand All @@ -40,6 +42,8 @@ public class RealmBaseDataSet: ChartBaseDataSet
colors.append(UIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))

self.label = label

initialize()
}

public init(results: RLMResults?, yValueField: String, xIndexField: String, label: String?)
Expand All @@ -56,7 +60,7 @@ public class RealmBaseDataSet: ChartBaseDataSet
_xIndexField = xIndexField
_results = _results?.sortedResultsUsingProperty(_xIndexField!, ascending: true)

notifyDataSetChanged()
initialize()
}

public convenience init(results: RLMResults?, yValueField: String, xIndexField: String)
Expand All @@ -80,6 +84,8 @@ public class RealmBaseDataSet: ChartBaseDataSet
{
loadResults(realm: realm!, modelName: modelName)
}

initialize()
}

public func loadResults(realm realm: RLMRealm, modelName: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import Realm.Dynamic

public class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleChartDataSet
{
public override func initialize()
{
}

public required init()
{
super.init()
Expand Down
17 changes: 17 additions & 0 deletions Charts/Classes/Data/Implementations/Realm/RealmCandleDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import Realm.Dynamic

public class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartDataSet
{
public override func initialize()
{

}

public required init()
{
super.init()
Expand Down Expand Up @@ -56,6 +61,18 @@ public class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChar
internal var _openField: String?
internal var _closeField: String?

internal override func buildEntryFromResultObject(object: RLMObject) -> ChartDataEntry
{
let entry = CandleChartDataEntry(
xIndex: object[_xIndexField!] as! Int,
shadowH: object[_highField!] as! Double,
shadowL: object[_lowField!] as! Double,
open: object[_openField!] as! Double,
close: object[_closeField!] as! Double)

return entry
}

public override func calcMinMax(start start: Int, end: Int)
{
let yValCount = self.entryCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Realm.Dynamic

public class RealmLineDataSet: RealmLineRadarDataSet, ILineChartDataSet
{
private func initialize()
public override func initialize()
{
circleColors.append(UIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import UIKit
import Realm
import Realm.Dynamic

public class RealmPieDataSet: RealmDataSet, IPieChartDataSet
public class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet
{
private func initialize()
public override func initialize()
{
self.valueTextColor = UIColor.whiteColor()
self.valueFont = UIFont.systemFontOfSize(13.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Realm.Dynamic

public class RealmRadarDataSet: RealmLineRadarDataSet, IRadarChartDataSet
{
private func initialize()
public override func initialize()
{
self.valueFont = UIFont.systemFontOfSize(13.0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class RealmScatterDataSet: RealmLineScatterCandleRadarDataSet, IScatterCh
public var scatterShape = ScatterChartDataSet.ScatterShape.Square
public var customScatterShape: CGPath?

public override func initialize()
{

}

// MARK: NSCopying

public override func copyWithZone(zone: NSZone) -> AnyObject
Expand Down
Loading

0 comments on commit bbacc37

Please sign in to comment.