GesturableGraph is a library that expresses values in a graph based on user touch.
![]() | ![]() |
|---|
- iOS 13.0+
Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
Xcode 11+ is required to build SnapKit using Swift Package Manager.
To integrate SnapKit into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift:
dependencies:[.package(url:"https://github.com/ohdair/GesturableGraph")]If the graph has fewer than two elements, the GesturableGraph cannot be created and returns nil.
import GesturableGraph
classViewController:UIViewController{overridefunc viewDidLoad(){letdata:[Double]=[3,8,7,4,6,9,11,12,8,7,6,10]guardlet graphView =GesturableGraph(elements: data)else{return}}}GesturableGraphEnable must be adopted to receive values for gestures. You can use the delegate pattern to receive GraphData.
classViewController:UIViewController{overridefunc viewDidLoad(){
graphView.delegate =self}}extensionViewController:GesturableGraphEnable{func gesturableGraph(_ gesturableGraph:GesturableGraph, didTapWithData data:GraphData?){
// You can use the data and present it in a UI.
}}
graph has 3 properties
- type
enumGraphType{case curve // default case straight }
- distribution
// aroundSpacing is that spacing at left/right spacing is 1/2 the size of the inner spacing. // evenSpacing is that inner spacing and left/right spacing are the same. enumDistribution{case equalSpacing // default case aroundSpacing case evenSpacing }
- padding
// Padding is a scaling factor for the height of the graph. structPadding{vartop:Double=0.3 // default varbottom:Double=0.3 // default }
enumUnitOfTime{case seconds
case minutes
case hours // default
case days
case months
}// position adjusts the position of axisY
// division display the label on the axisY axis by the value.
// decimalPlaces adjusts the position of the decimal point
structAxisY{vardataUnit:String=""vardivision:Int=8vardecimalPlaces:Int=0varposition:Position=.right
enumPosition{case left
case right
}}extraUnits only allows collection of images.
change the color and size property values.
- line
- point
- enableLine
- enablePoint
- area
structGraphLine{varwidth:Doublevarcolor:UIColor}structGraphPoint{varwidth:Doublevarcolor:UIColorvarisHidden:Bool}structGraphEnablePoint{varwidth:Doublevarcolor:UIColor}structGraphEnableLine{varwidth:Doublevarcolor:UIColor}structGraphArea{vargradientColors:[UIColor]varisFill:Bool}
