Created
September 2, 2014 22:18
-
-
Save alwold/3375a9502ab35e049eca to your computer and use it in GitHub Desktop.
ViewController with code to set length
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// CorePlotTest | |
// | |
// Created by Al Wold on 8/6/14. | |
// Copyright (c) 2014 Al Wold. All rights reserved. | |
// | |
import UIKit | |
class ViewController: UIViewController, CPTPlotDataSource { | |
@IBOutlet weak var graphView: CPTGraphHostingView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// create graph | |
var graph = CPTXYGraph(frame: CGRectZero) | |
graph.title = "Hello Graph" | |
var plot = CPTScatterPlot() | |
plot.dataSource = self | |
graph.addPlot(plot) | |
var plotSpace = graph.defaultPlotSpace as CPTXYPlotSpace | |
var xRange = plotSpace.xRange.mutableCopy() as CPTMutablePlotRange | |
var yRange = plotSpace.yRange.mutableCopy() as CPTMutablePlotRange | |
xRange.setLengthFloat(10) | |
yRange.setLengthFloat(10) | |
plotSpace.xRange = xRange | |
plotSpace.yRange = yRange | |
self.graphView.hostedGraph = graph | |
} | |
func numberOfRecordsForPlot(plot: CPTPlot!) -> UInt { | |
return 4 | |
} | |
func numberForPlot(plot: CPTPlot!, field fieldEnum: UInt, recordIndex idx: UInt) -> NSNumber! { | |
return idx+1 | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment