Skip to content

Commit 33b2b4f

Browse files
committed
Add comments to each variable so they are visible in the IDE
1 parent f17bee6 commit 33b2b4f

File tree

2 files changed

+88
-12
lines changed

2 files changed

+88
-12
lines changed

Classes/ScrollableGraphView.swift

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,87 +7,163 @@ import UIKit
77
// Use these to customise the graph.
88
// #################################
99

10-
// Bar styles
11-
public var shouldDrawBarLayer = false
12-
public var barLineWidth: CGFloat = 1
13-
public var barLineColor = UIColor.darkGrayColor()
14-
public var barColor = UIColor.grayColor()
15-
public var barWidth: CGFloat = 25;
16-
1710
// Line Styles
11+
// ###########
12+
13+
/// Specifies how thick the graph of the line is. In points.
1814
public var lineWidth: CGFloat = 2
15+
/// The color of the graph line. UIColor.
1916
public var lineColor = UIColor.blackColor()
17+
/// Whether or not the line should be rendered using bezier curves are straight lines.
2018
public var lineStyle = ScrollableGraphViewLineStyle.Straight
21-
19+
/// How each segment in the line should connect. Takes any of the Core Animation LineJoin values.
2220
public var lineJoin = kCALineJoinRound
21+
/// The line caps. Takes any of the Core Animation LineCap values.
2322
public var lineCap = kCALineCapRound
2423
public var lineCurviness: CGFloat = 0.5
2524

25+
// Bar styles
26+
// ##########
27+
28+
/// Whether bars should be drawn or not. If you want a bar graph, this should be set to true.
29+
public var shouldDrawBarLayer = false
30+
/// The width of an individual bar on the graph.
31+
public var barWidth: CGFloat = 25;
32+
/// The actual colour of the bar.
33+
public var barColor = UIColor.grayColor()
34+
/// The width of the outline of the bar
35+
public var barLineWidth: CGFloat = 1
36+
/// The colour of the bar outline
37+
public var barLineColor = UIColor.darkGrayColor()
38+
2639
// Fill Styles
40+
// ###########
41+
42+
/// The background colour for the entire graph view, not just the plotted graph.
2743
public var backgroundFillColor = UIColor.whiteColor()
2844

45+
/// Specifies whether or not the plotted graph should be filled with a colour or gradient.
2946
public var shouldFill = false
47+
/// Specifies whether to fill the graph with a solid colour or gradient.
3048
public var fillType = ScrollableGraphViewFillType.Solid
49+
/// If fillType is set to .Solid then this colour will be used to fill the graph.
3150
public var fillColor = UIColor.blackColor()
51+
/// If fillType is set to .Gradient then this will be the starting colour for the gradient.
3252
public var fillGradientStartColor = UIColor.whiteColor()
53+
/// If fillType is set to .Gradient, then this will be the ending colour for the gradient.
3354
public var fillGradientEndColor = UIColor.blackColor()
55+
/// If fillType is set to .Gradient, then this defines whether the gradient is rendered as a linear gradient or radial gradient.
3456
public var fillGradientType = ScrollableGraphViewGradientType.Linear
3557

3658
// Spacing
59+
// #######
60+
61+
/// How far the "maximum" reference line is from the top of the view's frame. In points.
3762
public var topMargin: CGFloat = 10
63+
/// How far the "minimum" reference line is from the bottom of the view's frame. In points.
3864
public var bottomMargin: CGFloat = 10
65+
/// How far the first point on the graph should be placed from the left hand side of the view.
3966
public var leftmostPointPadding: CGFloat = 50
67+
/// How far the final point on the graph should be placed from the right hand side of the view.
4068
public var rightmostPointPadding: CGFloat = 50
69+
/// How much space should be between each data point.
4170
public var dataPointSpacing: CGFloat = 40
71+
/// Which side of the graph the user is expected to scroll from.
4272
public var direction = ScrollableGraphViewDirection.LeftToRight
4373

4474
// Graph Range
75+
// ###########
76+
77+
/// If this is set to true, then the range will automatically be detected from the data the graph is given.
4578
public var shouldAutomaticallyDetectRange = false
79+
/// Forces the graph's minimum to always be zero. Used in conjunction with shouldAutomaticallyDetectRange or shouldAdaptRange, if you want to force the minimum to stay at 0 rather than the detected minimum.
4680
public var shouldRangeAlwaysStartAtZero = false // Used in conjunction with shouldAutomaticallyDetectRange, if you want to force the min to stay at 0.
47-
public var rangeMin: Double = 0 // Ignored when shouldAutomaticallyDetectRange or shouldAdaptRange = true
48-
public var rangeMax: Double = 100 // Ignored when shouldAutomaticallyDetectRange or shouldAdaptRange = true
81+
/// The minimum value for the y-axis. This is ignored when shouldAutomaticallyDetectRange or shouldAdaptRange = true
82+
public var rangeMin: Double = 0
83+
/// The maximum value for the y-axis. This is ignored when shouldAutomaticallyDetectRange or shouldAdaptRange = true
84+
public var rangeMax: Double = 100
4985

5086
// Data Point Drawing
87+
// ##################
88+
89+
/// Whether or not to draw a symbol for each data point.
5190
public var shouldDrawDataPoint = true
91+
/// The shape to draw for each data point.
5292
public var dataPointType = ScrollableGraphViewDataPointType.Circle
93+
/// The size of the shape to draw for each data point.
5394
public var dataPointSize: CGFloat = 5
95+
/// The colour with which to fill the shape.
5496
public var dataPointFillColor: UIColor = UIColor.blackColor()
97+
/// If dataPointType is set to .Custom then you,can provide a closure to create any kind of shape you would like to be displayed instead of just a circle or square. The closure takes a CGPoint which is the centre of the shape and it should return a complete UIBezierPath.
5598
public var customDataPointPath: ((centre: CGPoint) -> UIBezierPath)?
5699

57100
// Adapting & Animations
101+
// #####################
102+
103+
/// Whether or not the y-axis' range should adapt to the points that are visible on screen. This means if there are only 5 points visible on screen at any given time, the maximum on the y-axis will be the maximum of those 5 points. This is updated automatically as the user scrolls along the graph.
58104
public var shouldAdaptRange = false
105+
/// If shouldAdaptRange is set to true then this specifies whether or not the points on the graph should animate to their new positions. Default is set to true.
59106
public var shouldAnimateOnAdapt = true
107+
/// How long the animation should take. Affects both the startup animation and the animation when the range of the y-axis adapts to onscreen points.
60108
public var animationDuration: Double = 1
109+
/// The animation style.
61110
public var adaptAnimationType = ScrollableGraphViewAnimationType.EaseOut
111+
/// If adaptAnimationType is set to .Custom, then this is the easing function you would like applied for the animation.
62112
public var customAnimationEasingFunction: ((t: Double) -> Double)?
113+
/// Whether or not the graph should animate to their positions when the graph is first displayed.
63114
public var shouldAnimateOnStartup = true
64115

65116
// Reference Lines
117+
// ###############
118+
119+
/// Whether or not to show the y-axis reference lines and labels.
66120
public var shouldShowReferenceLines = true
121+
/// The colour for the reference lines.
67122
public var referenceLineColor = UIColor.blackColor()
123+
/// The thickness of the reference lines.
68124
public var referenceLineThickness: CGFloat = 0.5
125+
/// Where the labels should be displayed on the reference lines.
69126
public var referenceLinePosition = ScrollableGraphViewReferenceLinePosition.Left
127+
/// The type of reference lines. Currently only .Cover is available.
70128
public var referenceLineType = ScrollableGraphViewReferenceLineType.Cover
71129

130+
/// How many reference lines should be between the minimum and maximum reference lines. If you want a total of 4 reference lines, you would set this to 2. This can be set to 0 for no intermediate reference lines.This can be used to create reference lines at specific intervals. If the desired result is to have a reference line at every 10 units on the y-axis, you could, for example, set rangeMax to 100, rangeMin to 0 and numberOfIntermediateReferenceLines to 9.
72131
public var numberOfIntermediateReferenceLines: Int = 3
132+
/// Whether or not to add labels to the intermediate reference lines.
73133
public var shouldAddLabelsToIntermediateReferenceLines = true
134+
/// Whether or not to add units specified by the referenceLineUnits variable to the labels on the intermediate reference lines.
74135
public var shouldAddUnitsToIntermediateReferenceLineLabels = false
75136

76137
// Reference Line Labels
138+
// #####################
139+
140+
/// The font to be used for the reference line labels.
77141
public var referenceLineLabelFont = UIFont.systemFontOfSize(8)
142+
/// The colour of the reference line labels.
78143
public var referenceLineLabelColor = UIColor.blackColor()
79144

145+
/// Whether or not to show the units on the reference lines.
80146
public var shouldShowReferenceLineUnits = true
147+
/// The units that the y-axis is in. This string is used for labels on the reference lines.
81148
public var referenceLineUnits: String?
149+
/// The number of decimal places that should be shown on the reference line labels.
82150
public var referenceLineNumberOfDecimalPlaces: Int = 0
83151

84152
// Data Point Labels
153+
// #################
154+
155+
/// Whether or not to show the labels on the x-axis for each point.
85156
public var shouldShowLabels = true
157+
/// How far from the "minimum" reference line the data point labels should be rendered.
86158
public var dataPointLabelTopMargin: CGFloat = 10
159+
/// How far from the bottom of the view the data point labels should be rendered.
87160
public var dataPointLabelBottomMargin: CGFloat = 0
161+
/// The font for the data point labels.
88162
public var dataPointLabelColor = UIColor.blackColor()
163+
/// The colour for the data point labels.
89164
public var dataPointLabelFont: UIFont? = UIFont.systemFontOfSize(10)
90-
public var dataPointLabelsSparsity: Int = 1 // Used to force the graph to show every n-th dataPoint label (by default displaying every label)
165+
/// Used to force the graph to show every n-th dataPoint label
166+
public var dataPointLabelsSparsity: Int = 1
91167

92168
// MARK: - Private State
93169
// #####################

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Add ```pod 'ScrollableGraphView'``` to your Podfile and then make sure to ```imp
4848
1. Create a ScrollableGraphView instance and set the data and labels
4949
```swift
5050
let graphView = ScrollableGraphView(frame: someFrame)
51-
let data = [4.0, 8.0, 15.0, 16.0, 23.0, 42.0]
51+
let data: [Double] = [4, 8, 15, 16, 23, 42]
5252
let labels = ["one", "two", "three", "four", "five", "six"]
5353
graphView.setData(data, withLabels: labels)
5454
```

0 commit comments

Comments
 (0)