GitXplorerGitXplorer
a

PlotKit

public
61 stars
4 forks
9 issues

Commits

List of commits on branch master.
Unverified
df662e9d5adc29986c5a09256f408eb5558c7695

Update syntax in README

aalejandro-isaza committed 8 years ago
Unverified
0e760b37f23dbcdc80ebed1fe8098d4181c97e4c

Update for Swift 3.0

aalejandro-isaza committed 8 years ago
Unverified
e25cc332c802f461675fc9761c4f4dba51d6e5de

Better popup value display

committed 9 years ago
Unverified
c70c8aab4cfe3884b29f74e9b3d58cbd781fbfa2

Pad data views to avoid clipping at the edges

committed 9 years ago
Unverified
c8bcbfcf6107595b2c5ba95df2dde49cf6be66bf

Add point conversion utility function

committed 9 years ago
Unverified
09afaa66845fb4653005c129555829abee1767bd

Update README.md

aalejandro-isaza committed 9 years ago

README

The README file for this repository.

PlotKit

CocoaPods Compatible Carthage Compatible

Plots made easy.

PlotKit Plot

Features

  • [x] 2D line and scatter plots
  • [x] Multiple axes
  • [x] Custom tick marks

Usage

To start using PlotKit quickly use the plotPoints helper function. It takes a list of points and returns a view that you can use in your app:

import PlotKit

// Generate some data to plot
let count = 1024
let t = (0..<count).map({ 2*M_PI * Double($0) / Double(count-1) })
let y = t.map({ sin($0) })

// Create a PlotView
let plotView1 = plotPoints((0..<count).map{ Point(x: t[$0], y: y[$0]) }, hTicks: .fit(6), vTicks: .fit(4))

Multiple point sets

You can have multiple curves or scatter plots in the same PlotView.

let plotView = PlotView()

let pointSet1 = PointSet(values: values1)
pointSet1.pointType = .disk(radius: 2)
pointSet2.pointColor = .red
pointSet1.lineColor = nil
plotView.addPointSet(pointSet1)

let pointSet2 = PointSet(values: values2)
pointSet2.pointType = .none
pointSet2.lineColor = .blue
plotView.addPointSet(pointSet2)

Axes

You can customize your plot axes. You can have as many axis lines as you want on the same plot.

let plotView = PlotView()

var xaxis = Axis(orientation: .horizontal, ticks: .fit(5))
xaxis.position = .value(0) 
xaxis.color = .blue
xaxis.labelAttributes = [NSForegroundColorAttributeName: NSColor.blue]
plotView.addAxis(xaxis)

var yaxis = Axis(orientation: .vertical, ticks: .distance(1))
yaxis.lineWidth = 2
plotView.addAxis(yaxis)

You can specify ticks in one of three ways:

  • fit(n): Say how many tick marks you want. PlotKit will space them evenly.
  • distance(d): Say how far appart to place tick marks.
  • list(l): Specify exactly the tick marks you want. This is the most flexible. You get to decide where to put the tick marks and also what their labels, line length and line thickness are.

Using PlotKit with Storyboards

If you want to use a PlotView in a Storyboard add an NSView and then change the class name and module like so


License

PlotKit is available under the MIT license. See the LICENSE file for more info.