Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import UIKit
import PlaygroundSupport

let graphView = ScrollableGraphView(frame: CGRect.zero)

graphView.dataPointType = ScrollableGraphViewDataPointType.circle
graphView.shouldDrawBarLayer = true
graphView.shouldDrawDataPoint = false

graphView.lineColor = UIColor.clear()
graphView.barWidth = 25
graphView.barLineWidth = 1
graphView.barLineColor = UIColor.colorFromHex("#777777")
graphView.barColor = UIColor.colorFromHex("#555555")
graphView.backgroundFillColor = UIColor.colorFromHex("#333333")

graphView.referenceLineLabelFont = UIFont.boldSystemFont(ofSize: 8)
graphView.referenceLineColor = UIColor.white().withAlphaComponent(0.2)
graphView.referenceLineLabelColor = UIColor.white()
graphView.numberOfIntermediateReferenceLines = 5
graphView.dataPointLabelColor = UIColor.white().withAlphaComponent(0.5)

graphView.shouldAnimateOnStartup = true
graphView.shouldAdaptRange = true
graphView.adaptAnimationType = ScrollableGraphViewAnimationType.elastic
graphView.animationDuration = 1.5
graphView.rangeMax = 50
graphView.shouldRangeAlwaysStartAtZero = true

let data: [Double] = generateRandomData(50, max: 50)
let labels = generateSequentialLabels(50, text: "Label")

graphView.setData(data, withLabels: labels)

PlaygroundPage.current.liveView = graphView
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import UIKit
import PlaygroundSupport

let graphView = ScrollableGraphView(frame: CGRect.zero)

graphView.backgroundFillColor = UIColor.colorFromHex("#333333")

graphView.lineWidth = 1
graphView.lineColor = UIColor.colorFromHex("#777777")
graphView.lineStyle = ScrollableGraphViewLineStyle.smooth

graphView.shouldFill = true
graphView.fillType = ScrollableGraphViewFillType.gradient
graphView.fillColor = UIColor.colorFromHex("#555555")
graphView.fillGradientType = ScrollableGraphViewGradientType.linear
graphView.fillGradientStartColor = UIColor.colorFromHex("#555555")
graphView.fillGradientEndColor = UIColor.colorFromHex("#444444")

graphView.dataPointSpacing = 80
graphView.dataPointSize = 2
graphView.dataPointFillColor = UIColor.white()

graphView.referenceLineLabelFont = UIFont.boldSystemFont(ofSize: 8)
graphView.referenceLineColor = UIColor.white().withAlphaComponent(0.2)
graphView.referenceLineLabelColor = UIColor.white()
graphView.numberOfIntermediateReferenceLines = 5
graphView.dataPointLabelColor = UIColor.white().withAlphaComponent(0.5)

graphView.shouldAnimateOnStartup = true
graphView.shouldAdaptRange = true
graphView.adaptAnimationType = ScrollableGraphViewAnimationType.elastic
graphView.animationDuration = 2.5
graphView.rangeMax = 50
graphView.shouldRangeAlwaysStartAtZero = true

let data: [Double] = generateRandomData(50, max: 50)
let labels = generateSequentialLabels(50, text: "Label")

graphView.setData(data, withLabels: labels)

PlaygroundPage.current.liveView = graphView
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import UIKit
import PlaygroundSupport

let graphView = ScrollableGraphView(frame: CGRect.zero)

graphView.backgroundFillColor = UIColor.colorFromHex("#00BFFF")
graphView.lineColor = UIColor.clear()

graphView.dataPointSize = 5
graphView.dataPointSpacing = 80
graphView.dataPointLabelFont = UIFont.boldSystemFont(ofSize: 10)
graphView.dataPointLabelColor = UIColor.white()
graphView.dataPointFillColor = UIColor.white()

graphView.referenceLineLabelFont = UIFont.boldSystemFont(ofSize: 10)
graphView.referenceLineColor = UIColor.white().withAlphaComponent(0.5)
graphView.referenceLineLabelColor = UIColor.white()
graphView.referenceLinePosition = ScrollableGraphViewReferenceLinePosition.both

graphView.numberOfIntermediateReferenceLines = 9

graphView.rangeMax = 50

let data: [Double] = generateRandomData(50, max: 50)
let labels = generateSequentialLabels(50, text: "Label")

graphView.setData(data, withLabels: labels)

PlaygroundPage.current.liveView = graphView
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import UIKit
import PlaygroundSupport

let graphView = ScrollableGraphView(frame: CGRect.zero)

graphView.backgroundFillColor = UIColor.colorFromHex("#222222")
graphView.lineColor = UIColor.clear()

graphView.shouldFill = true
graphView.fillColor = UIColor.colorFromHex("#FF0080")

graphView.shouldDrawDataPoint = false
graphView.dataPointSpacing = 20
graphView.dataPointLabelFont = UIFont.boldSystemFont(ofSize: 10)
graphView.dataPointLabelColor = UIColor.white()

graphView.dataPointLabelsSparsity = 3

graphView.referenceLineThickness = 1
graphView.referenceLineLabelFont = UIFont.boldSystemFont(ofSize: 10)
graphView.referenceLineColor = UIColor.white().withAlphaComponent(0.5)
graphView.referenceLineLabelColor = UIColor.white()
graphView.referenceLinePosition = ScrollableGraphViewReferenceLinePosition.both

graphView.numberOfIntermediateReferenceLines = 1

graphView.shouldAdaptRange = true

graphView.rangeMax = 50

let data: [Double] = generateRandomData(50, max: 50)
let labels = generateSequentialLabels(50, text: "Label")

graphView.setData(data, withLabels: labels)

PlaygroundPage.current.liveView = graphView
23 changes: 23 additions & 0 deletions Scrollable-GraphView.playground/Sources/RandomData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Foundation

public func generateRandomData(_ numberOfItems: Int, max: Double) -> [Double] {
var data = [Double]()
for _ in 0 ..< numberOfItems {
var randomNumber = Double(arc4random()).truncatingRemainder(dividingBy: max)

if(arc4random() % 100 < 10) {
randomNumber *= 3
}

data.append(randomNumber)
}
return data
}

public func generateSequentialLabels(_ numberOfItems: Int, text: String) -> [String] {
var labels = [String]()
for i in 0 ..< numberOfItems {
labels.append("\(text) \(i+1)")
}
return labels
}
Loading