Skip to content

Commit

Permalink
Merge pull request #63 from collectiveidea/example-graph-1
Browse files Browse the repository at this point in the history
Example graph 1
  • Loading branch information
be-bert committed Jan 16, 2017
2 parents a0a99b3 + 6670fd9 commit aa7b3ad
Show file tree
Hide file tree
Showing 25 changed files with 436 additions and 89 deletions.
12 changes: 12 additions & 0 deletions CollectionGraph.xcodeproj/project.pbxproj
Expand Up @@ -18,13 +18,16 @@
571B7ECA1D9D9CF500FCE88E /* GraphCollectionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 571B7EC91D9D9CF500FCE88E /* GraphCollectionView.xib */; };
571B7ECC1D9DAD4B00FCE88E /* GraphLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 571B7ECB1D9DAD4B00FCE88E /* GraphLayout.swift */; };
571B7ED21D9DBAC300FCE88E /* CollectionGraphDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 571B7ED11D9DBAC300FCE88E /* CollectionGraphDataSource.swift */; };
571F01AC1E2D03ED0053C400 /* PeopleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 571F01AB1E2D03ED0053C400 /* PeopleCollectionViewCell.swift */; };
574F020C1DE393B9001ACC27 /* CollectionGraphDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 574F020B1DE393B9001ACC27 /* CollectionGraphDelegate.swift */; };
5756122A1DB1098700F94EAF /* LabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 575612291DB1098700F94EAF /* LabelView.swift */; };
5756122C1DB109F100F94EAF /* XLabelViewAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5756122B1DB109F100F94EAF /* XLabelViewAttributes.swift */; };
5756122E1DB122C200F94EAF /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5756122D1DB122C200F94EAF /* Data.swift */; };
576457D41E008C4200FA3432 /* GraphDelegates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576457D31E008C4200FA3432 /* GraphDelegates.swift */; };
576DD7841DB55BA90084498B /* MyGraphCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 576DD7831DB55BA90084498B /* MyGraphCell.swift */; };
577853411E1EDF4A00058C19 /* RangeFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 577853401E1EDF4A00058C19 /* RangeFinder.swift */; };
579788B81E29182D000503AF /* MilesPerDayData.json in Resources */ = {isa = PBXBuildFile; fileRef = 579788B71E29182D000503AF /* MilesPerDayData.json */; };
579788F71E297C56000503AF /* ColorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 579788F61E297C56000503AF /* ColorHelper.swift */; };
57C8AD551DF9ADB50097D1A8 /* SideBarReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57C8AD541DF9ADB50097D1A8 /* SideBarReusableView.swift */; };
57EA989B1D958C82000D6C55 /* CollectionGraph.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EA989A1D958C82000D6C55 /* CollectionGraph.h */; settings = {ATTRIBUTES = (Public, ); }; };
57EA98A21D958C82000D6C55 /* CollectionGraph.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57EA98971D958C82000D6C55 /* CollectionGraph.framework */; };
Expand Down Expand Up @@ -78,13 +81,16 @@
571B7EC91D9D9CF500FCE88E /* GraphCollectionView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GraphCollectionView.xib; sourceTree = "<group>"; };
571B7ECB1D9DAD4B00FCE88E /* GraphLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphLayout.swift; sourceTree = "<group>"; };
571B7ED11D9DBAC300FCE88E /* CollectionGraphDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionGraphDataSource.swift; sourceTree = "<group>"; };
571F01AB1E2D03ED0053C400 /* PeopleCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeopleCollectionViewCell.swift; sourceTree = "<group>"; };
574F020B1DE393B9001ACC27 /* CollectionGraphDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionGraphDelegate.swift; sourceTree = "<group>"; };
575612291DB1098700F94EAF /* LabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelView.swift; sourceTree = "<group>"; };
5756122B1DB109F100F94EAF /* XLabelViewAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XLabelViewAttributes.swift; sourceTree = "<group>"; };
5756122D1DB122C200F94EAF /* Data.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = "<group>"; };
576457D31E008C4200FA3432 /* GraphDelegates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphDelegates.swift; sourceTree = "<group>"; };
576DD7831DB55BA90084498B /* MyGraphCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyGraphCell.swift; sourceTree = "<group>"; };
577853401E1EDF4A00058C19 /* RangeFinder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RangeFinder.swift; sourceTree = "<group>"; };
579788B71E29182D000503AF /* MilesPerDayData.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = MilesPerDayData.json; sourceTree = "<group>"; };
579788F61E297C56000503AF /* ColorHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorHelper.swift; sourceTree = "<group>"; };
57C8AD541DF9ADB50097D1A8 /* SideBarReusableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideBarReusableView.swift; sourceTree = "<group>"; };
57EA98971D958C82000D6C55 /* CollectionGraph.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CollectionGraph.framework; sourceTree = BUILT_PRODUCTS_DIR; };
57EA989A1D958C82000D6C55 /* CollectionGraph.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CollectionGraph.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,7 +217,10 @@
A7B2B0FB1D958F1500F3A410 /* AppDelegate.swift */,
A7B2B0FD1D958F1500F3A410 /* FirstViewController.swift */,
5756122D1DB122C200F94EAF /* Data.swift */,
579788F61E297C56000503AF /* ColorHelper.swift */,
579788B71E29182D000503AF /* MilesPerDayData.json */,
576DD7831DB55BA90084498B /* MyGraphCell.swift */,
571F01AB1E2D03ED0053C400 /* PeopleCollectionViewCell.swift */,
A7B2B0FF1D958F1500F3A410 /* SecondViewController.swift */,
A7B2B1011D958F1500F3A410 /* Main.storyboard */,
A7B2B1041D958F1500F3A410 /* Assets.xcassets */,
Expand Down Expand Up @@ -358,6 +367,7 @@
buildActionMask = 2147483647;
files = (
A7B2B1081D958F1500F3A410 /* LaunchScreen.storyboard in Resources */,
579788B81E29182D000503AF /* MilesPerDayData.json in Resources */,
A7B2B1051D958F1500F3A410 /* Assets.xcassets in Resources */,
A7B2B1031D958F1500F3A410 /* Main.storyboard in Resources */,
);
Expand Down Expand Up @@ -420,6 +430,8 @@
A7B2B0FC1D958F1500F3A410 /* AppDelegate.swift in Sources */,
A7B2B0FE1D958F1500F3A410 /* FirstViewController.swift in Sources */,
576DD7841DB55BA90084498B /* MyGraphCell.swift in Sources */,
571F01AC1E2D03ED0053C400 /* PeopleCollectionViewCell.swift in Sources */,
579788F71E297C56000503AF /* ColorHelper.swift in Sources */,
5756122E1DB122C200F94EAF /* Data.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
6 changes: 6 additions & 0 deletions CollectionGraphExample/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "user1.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "user2.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "user3.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user3@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user3@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "user4.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user4@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user4@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 19 additions & 21 deletions CollectionGraphExample/Base.lproj/Main.storyboard
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -24,36 +23,35 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lKD-sb-K3J" customClass="CollectionGraphView" customModule="CollectionGraph">
<rect key="frame" x="16" y="84" width="343" height="500"/>
<color key="backgroundColor" red="0.9599609375" green="0.9599609375" blue="0.9599609375" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<rect key="frame" x="0.0" y="59" width="375" height="500"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="textColor">
<color key="value" red="0.14752725916215198" green="0.56657927194470192" blue="0.75779632568359379" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="value" red="0.66918266508321733" green="0.66581090599883896" blue="0.77707895655714276" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="yDividerLineColor">
<color key="value" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="ySteps">
<integer key="value" value="7"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="xSteps">
<integer key="value" value="9"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="topInset">
<real key="value" value="34"/>
<color key="value" red="0.23529411759999999" green="0.23137254900000001" blue="0.36078431370000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="leftInset">
<real key="value" value="50"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Miles Ran Per Day" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JNm-ov-drY">
<rect key="frame" x="16" y="35" width="107" height="16"/>
<fontDescription key="fontDescription" type="system" weight="ultraLight" pointSize="13"/>
<color key="textColor" red="0.66918266510000002" green="0.66581090600000004" blue="0.77707895660000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.23529411759999999" green="0.23137254900000001" blue="0.36078431370000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="lKD-sb-K3J" firstAttribute="height" secondItem="tsR-hK-woN" secondAttribute="height" multiplier="0.75" id="2M5-AM-Yrm"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="trailing" secondItem="tsR-hK-woN" secondAttribute="trailingMargin" id="BW2-CT-JQc"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="centerY" secondItem="tsR-hK-woN" secondAttribute="centerY" id="Cvv-Te-YHE"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leadingMargin" id="dRH-wn-yyJ"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="top" secondItem="Ia1-K6-d13" secondAttribute="bottom" constant="39" id="Crp-8e-oSm"/>
<constraint firstAttribute="trailing" secondItem="lKD-sb-K3J" secondAttribute="trailing" id="bSX-te-O60"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="top" secondItem="JNm-ov-drY" secondAttribute="bottom" constant="8" id="fiY-SK-fj0"/>
<constraint firstItem="lKD-sb-K3J" firstAttribute="leading" secondItem="tsR-hK-woN" secondAttribute="leading" id="jWb-nf-OnL"/>
<constraint firstItem="4ug-Mw-9AY" firstAttribute="top" secondItem="lKD-sb-K3J" secondAttribute="bottom" constant="59" id="wwe-9q-CTz"/>
<constraint firstAttribute="leadingMargin" secondItem="JNm-ov-drY" secondAttribute="leading" id="z59-6G-qsc"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="First" image="first" id="acW-dT-cKf"/>
Expand Down
42 changes: 42 additions & 0 deletions CollectionGraphExample/ColorHelper.swift
@@ -0,0 +1,42 @@
//
// ColorHelper.swift
// CollectionGraph
//
// Created by Ben Lambert on 1/13/17.
// Copyright © 2017 Collective Idea. All rights reserved.
//

import UIKit

protocol ColorHelpers {
func colorForSection(section: Int) -> UIColor
}

extension ColorHelpers {

// http://www.colorhunt.co/c/43813

func colorForSection(section: Int) -> UIColor {

switch section {
case 0:
// blue
return UIColor(red: 69.0 / 255.0, green: 193.0 / 255.0, blue: 201.0 / 255.0, alpha: 1)
case 1:
// pink
return UIColor(red: 252.0 / 255.0, green: 81.0 / 255.0, blue: 133.0 / 255.0, alpha: 1)
case 2:
// yellow
return UIColor(red: 252.0 / 255.0, green: 227.0 / 255.0, blue: 138.0 / 255.0, alpha: 1)
case 3:
// purple
return UIColor(red: 187.0 / 255.0, green: 88.0 / 255.0, blue: 176.0 / 255.0, alpha: 1)
case 4:
// grey
return UIColor(red: 125.0 / 255.0, green: 124.0 / 255.0, blue: 122.0 / 255.0, alpha: 1)
default:
return UIColor.darkGray
}
}

}

0 comments on commit aa7b3ad

Please sign in to comment.