Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated for in loops to dismiss warnings #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C06F8E141962FFD7000AC9AF"
BuildableName = "linechart.app"
BlueprintName = "linechart"
ReferencedContainer = "container:linechart.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C06F8E211962FFD7000AC9AF"
BuildableName = "linechartTests.xctest"
BlueprintName = "linechartTests"
ReferencedContainer = "container:linechart.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C06F8E141962FFD7000AC9AF"
BuildableName = "linechart.app"
BlueprintName = "linechart"
ReferencedContainer = "container:linechart.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C06F8E141962FFD7000AC9AF"
BuildableName = "linechart.app"
BlueprintName = "linechart"
ReferencedContainer = "container:linechart.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C06F8E141962FFD7000AC9AF"
BuildableName = "linechart.app"
BlueprintName = "linechart"
ReferencedContainer = "container:linechart.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>linechart.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>C06F8E141962FFD7000AC9AF</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>C06F8E211962FFD7000AC9AF</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
30 changes: 18 additions & 12 deletions linechart/LineChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ public class LineChart: UIView {
}



/**
* Fill area between line chart and x-axis.
*/
Expand All @@ -445,8 +444,7 @@ public class LineChart: UIView {
path.addLineToPoint(CGPoint(x: x.axis.inset, y: self.bounds.height - self.y.scale(0) - y.axis.inset))
path.fill()
}




/**
* Draw x grid.
Expand All @@ -458,15 +456,17 @@ public class LineChart: UIView {
let y1: CGFloat = self.bounds.height - y.axis.inset
let y2: CGFloat = y.axis.inset
let (start, stop, step) = self.x.ticks
for var i: CGFloat = start; i <= stop; i += step {
x1 = self.x.scale(i) + x.axis.inset

let sequence = start.stride(to: stop, by: step)

for step in sequence {
x1 = self.x.scale(step) + x.axis.inset
path.moveToPoint(CGPoint(x: x1, y: y1))
path.addLineToPoint(CGPoint(x: x1, y: y2))
}
path.stroke()
}




/**
* Draw y grid.
Expand All @@ -478,8 +478,11 @@ public class LineChart: UIView {
let x2: CGFloat = self.bounds.width - x.axis.inset
var y1: CGFloat
let (start, stop, step) = self.y.ticks
for var i: CGFloat = start; i <= stop; i += step {
y1 = self.bounds.height - self.y.scale(i) - y.axis.inset

let sequence = start.stride(to: stop, by: step)

for step in sequence {
y1 = self.bounds.height - self.y.scale(step) - y.axis.inset
path.moveToPoint(CGPoint(x: x1, y: y1))
path.addLineToPoint(CGPoint(x: x2, y: y1))
}
Expand Down Expand Up @@ -531,12 +534,15 @@ public class LineChart: UIView {
private func drawYLabels() {
var yValue: CGFloat
let (start, stop, step) = self.y.ticks
for var i: CGFloat = start; i <= stop; i += step {
yValue = self.bounds.height - self.y.scale(i) - (y.axis.inset * 1.5)

let sequence = start.stride(to: stop, by: step)

for step in sequence {
yValue = self.bounds.height - self.y.scale(step) - (y.axis.inset * 1.5)
let label = UILabel(frame: CGRect(x: 0, y: yValue, width: y.axis.inset, height: y.axis.inset))
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleCaption2)
label.textAlignment = .Center
label.text = String(Int(round(i)))
label.text = String(Int(round(step)))
self.addSubview(label)
}
}
Expand Down