diff --git a/Classes/Plots/Plot.swift b/Classes/Plots/Plot.swift index 96b76bf..c6370ca 100644 --- a/Classes/Plots/Plot.swift +++ b/Classes/Plots/Plot.swift @@ -8,11 +8,7 @@ public enum PlotType { } open class Plot { - var identifier: String - - init() { - identifier = "Plot" - } + var identifier: String! } open class LinePlot : Plot { @@ -93,9 +89,9 @@ open class LinePlot : Plot { private var fillLayer: FillDrawingLayer? private var gradientLayer: GradientDrawingLayer? - override init() { + init(identifier: String) { super.init() - self.identifier = "LinePlot" + self.identifier = identifier } func layers(forViewport viewport: CGRect) -> [ScrollableGraphViewDrawingLayer?] { @@ -149,9 +145,9 @@ open class DataPointPlot : Plot { private var dataPointLayer: DataPointDrawingLayer? - override init() { + init(identifier: String) { super.init() - self.identifier = "DataPointPlot" + self.identifier = identifier } func layers(forViewport viewport: CGRect) -> [ScrollableGraphViewDrawingLayer?] { @@ -190,9 +186,9 @@ open class BarPlot : Plot { private var barLayer: BarDrawingLayer? - override init() { + init(identifier: String) { super.init() - self.identifier = "BarPlot" + self.identifier = identifier } func layers(forViewport viewport: CGRect) -> [ScrollableGraphViewDrawingLayer?] { diff --git a/graphview_example_code/GraphView/ViewController.swift b/graphview_example_code/GraphView/ViewController.swift index f22f6f9..e1ff6f2 100644 --- a/graphview_example_code/GraphView/ViewController.swift +++ b/graphview_example_code/GraphView/ViewController.swift @@ -65,7 +65,7 @@ class ViewController: UIViewController { let graphView = ScrollableGraphView(frame: frame) // Setup the line plot. - let linePlot = LinePlot() + let linePlot = LinePlot(identifier: "line") linePlot.lineWidth = 1 linePlot.lineColor = UIColor.colorFromHex(hexString: "#777777") @@ -77,7 +77,7 @@ class ViewController: UIViewController { linePlot.fillGradientStartColor = UIColor.colorFromHex(hexString: "#555555") linePlot.fillGradientEndColor = UIColor.colorFromHex(hexString: "#444444") - let dotPlot = DataPointPlot() // Add dots as well. + let dotPlot = DataPointPlot(identifier: "dot") // Add dots as well. dotPlot.dataPointSize = 2 dotPlot.dataPointFillColor = UIColor.white @@ -115,7 +115,7 @@ class ViewController: UIViewController { let graphView = ScrollableGraphView(frame:frame) // Setup the plot - let barPlot = BarPlot() + let barPlot = BarPlot(identifier: "bar") barPlot.shouldDrawBarLayer = true barPlot.barWidth = 25 @@ -153,7 +153,7 @@ class ViewController: UIViewController { let graphView = ScrollableGraphView(frame:frame) // Setup the plot - let plot = DataPointPlot() + let plot = DataPointPlot(identifier: "dot") plot.dataPointSize = 5 plot.dataPointFillColor = UIColor.white @@ -185,7 +185,7 @@ class ViewController: UIViewController { let graphView = ScrollableGraphView(frame:frame) // Setup the plot - let linePlot = LinePlot() + let linePlot = LinePlot(identifier: "line") linePlot.lineColor = UIColor.clear linePlot.shouldFill = true