Skip to content

Commit

Permalink
Add identifiers to plots
Browse files Browse the repository at this point in the history
  • Loading branch information
philackm committed Jun 30, 2017
1 parent 4ce9648 commit ab3b17d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
18 changes: 7 additions & 11 deletions Classes/Plots/Plot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ public enum PlotType {
}

open class Plot {
var identifier: String

init() {
identifier = "Plot"
}
var identifier: String!
}

open class LinePlot : Plot {
Expand Down Expand Up @@ -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?] {
Expand Down Expand Up @@ -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?] {
Expand Down Expand Up @@ -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?] {
Expand Down
10 changes: 5 additions & 5 deletions graphview_example_code/GraphView/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ab3b17d

Please sign in to comment.