Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/recruit-mtl/Graphs
Light weight charts view generater for iOS. Written in Swift.
https://github.com/recruit-mtl/Graphs
Last synced: 3 months ago
JSON representation
Light weight charts view generater for iOS. Written in Swift.
- Host: GitHub
- URL: https://github.com/recruit-mtl/Graphs
- Owner: recruit-mtl
- License: mit
- Created: 2016-06-08T09:16:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-08T23:08:10.000Z (over 6 years ago)
- Last Synced: 2024-07-21T13:20:49.601Z (4 months ago)
- Language: Swift
- Homepage:
- Size: 96.7 KB
- Stars: 974
- Watchers: 39
- Forks: 63
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-ios - Graphs - Light weight charts view generator for iOS. (Charts)
- awesome-ios-star - Graphs - Light weight charts view generator for iOS. (Charts)
- fucking-awesome-ios - Graphs - Light weight charts view generator for iOS. (Charts)
- fucking-awesome-ios - Graphs - Light weight charts view generator for iOS. (Charts)
README
#
[![Badge w/ Version](https://cocoapod-badges.herokuapp.com/v/Graphs/badge.png)](https://cocoadocs.org/docsets/Graphs)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)###Light weight charts view generater for iOS. Written in Swift.
## Requirements
- iOS 8.0+
- XCode 7.3+## Installation
### [CocoaPods](https://cocoapods.org)
```bash
$ pod init
```specify it in your `Podfile`
```ruby
platform :ios, '8.0'target 'TargetName' do
use_frameworks!
pod 'Graphs', '~> 0.1.2'end
```And run `CocoaPods`
```bash
$ pod install
```--
### [Carthage](https://github.com/Carthage/Carthage)
You can install Carthage with Homebrew.```bash
$ brew update
$ brew install carthage
```
specify it in your `Cartfile````
github "recruit-mtl/Graphs"
```And run `carthage`
```bash
$ carthage update --platform ios
```## Usage
#####import Graphs
```swift
import Graphs
```##### Range -> GraphView (Bar)
```swift
let view = (1 ... 10).barGraph(GraphRange(min: 0, max: 11)).view(viewFrame)
```##### Array -> GraphView (Line)
```swift
let view = [10, 20, 4, 8, 25, 18, 21, 24, 8, 15].lineGraph(GraphRange(min: 0, max: 30)).view(viewFrame)
```##### Dictionary -> GraphView (Pie)
```swift
let view = ["a": 3, "b": 8, "c": 9, "d": 20].pieGraph().view(viewFrame)
```##### GraphData protocol -> GraphView (Pie)
```swift
import Graphsstruct Data: GraphData {
typealias GraphDataKey = T
typealias GraphDataValue = U
private let _key: T
private let _value: U
init(key: T, value: U) {
self._key = key
self._value = value
}
var key: T { get{ return self._key } }
var value: U { get{ return self._value } }
}let data = [
Data(key: "John", value: 18.9),
Data(key: "Ken", value: 32.9),
Data(key: "Taro", value: 15.3),
Data(key: "Micheal", value: 22.9),
Data(key: "Jun", value: 12.9),
Data(key: "Hanako", value: 32.2),
Data(key: "Kent", value: 3.8)
]let view = data.pieGraph() { (unit, totalValue) -> String? in
return unit.key! + "\n" + String(format: "%.0f%%", unit.value / totalValue * 100.0)
}.view(viewFrame)
```##### More detail
-> Read Playgrounds## Demo
```bash
$ git clone https://github.com/recruit-mtl/Graphs.git
$ cd /path/to/Graphs/GraphsExample
$ pod install
```
And Open ```GraphsExample.xcworkspace```## Issues
### GraphView doesn't work on Interface builder.
Interface Builder talks to code through the ObjC runtime.
And ObjC doesn't do generics.## Licence
[MIT](https://github.com/recruit-mtl/MTLLinkLabel/blob/master/LICENSE)
## Author
- [kokoron: Twitter](https://twitter.com/kokoron)
- [kokoron: github](https://github.com/kokoron)