Home

Awesome

HamsterUIKit

A simple and elegant UIKit(Chart) for iOS, written in Swift.

Carthage compatible Platform Build Status

:bar_chart: Curve and bar Charts.
:bulb: Protocols are designed based on UIKit(UITableView).
:keycap_ten: Draw a complex but elegant graph in 10 minutes.

<p align="center"> <img src="Img/CurveChart.gif" width="300" height="160" style="margin-right: 10px;margin-bottom: 10px;"><img src="Img/SimpleBarChart.gif" width="300" style="margin-left: 10px;margin-bottom: 10px;"><img src="Img/GroupedBarChart.png" width="300" style="margin-right: 10px;margin-top: 10px;"><img src="Img/StackedBarChart.png" width="300" style="margin-left: 10px;margin-top: 10px;"> </p>

Protocols

Initialize and reload

UITableViewHamsCurveChartHamsBarChart
init(frame: CGRect)samesame
init?(coder aDecoder: NSCoder)samesame
reloadDatasamesame

DataSource

UITableViewHamsCurveChartHamsBarChart
numberOfSections(in tableView: UITableView) -> IntnumberOfCharts(in curveChart: HamsCurveChart) -> IntnumberOfCharts(in barChart: HamsBarChart) -> Int
tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCellcurveChart(_ curveChart: HamsCurveChart, pointForChart indexPath: HamsIndexPath) -> HamsCurveChartPointbarChart(_ barChart: HamsBarChart, barForChart indexPath: HamsIndexPath) -> HamsBarChartRect
tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> IntcurveChart(_ curveChart: HamsCurveChart, numberOfValuesInChart chart: Int) -> IntbarChart(_ barChart: HamsBarChart, numberOfValuesInChart chart: Int) -> Int

Delegate

HamsCurveChartHamsBarChart
curveChart(_ curveChart: HamsCurveChart, configureForCharts chart: Int)barChart(_ barChart: HamsBarChart, configureForCharts chart: Int)

Installation

Carthage

github "Howardw3/HamsterUIKit"

CocoaPods

  1. Add to your Podfile:
use_frameworks!
pod 'HamsterUIKit'
  1. Type in terminal:
pod install
  1. Import the framework
import HamsterUIKit

Manually

git clone https://github.com/Haneke/HanekeSwift.git
  1. Copy and paste the above command in your terminal, it will clone the repo into your disk.
  2. Drag HamsterUIKit.xcodeproj to your project in the Project Navigator.
  3. Select your project and then your app target. Open the Build Phases panel.
  4. Expand the Target Dependencies group, and add HamsterUIKit.framework.
  5. Click on the + button at the top left of the panel and select New Copy Files Phase. Set Destination to Frameworks, and add HamsterUIKit.framework.
  6. import HamsterUIKit whenever you want to use Haneke.

Demo

Bar Chart Demo

Curve Chart Demo

Advanced Configuration

Bar Chart

Bar Chart Quick start

<p align="center"> <img src="Img/QuickStart.png" height="200" style="margin-right: 10px;margin-bottom: 10px;"></p>
import UIKit
import HamsterUIKit

class HelloBarChartViewController: UIViewController, HamsBarChartDelegate, HamsBarChartDataSource {
	var barChart:HamsBarChart = HamsBarChart()
	var dataSets = [CGFloat]()
    override func viewDidLoad() {
        super.viewDidLoad()
		barChart = HamsBarChart(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 300))

		barChart.delegate = self
		barChart.dataSource = self
		view.addSubview(barChart)
    }

	func barChart(_ barChart: HamsBarChart, numberOfValuesInChart chart: Int) -> Int {
		return dataSets.count
	}

	func numberOfCharts(in barChart: HamsBarChart) -> Int {
		return 1
	}

	func barChart(_ barChart: HamsBarChart, barForChart indexPath: HamsIndexPath) -> HamsBarChartRect {
		let rect = HamsBarChartRect()
		rect.value = .plain(dataSets[indexPath.column])
		rect.color = .plain(.white)
		return rect
	}

	override func viewWillAppear(_ animated: Bool) {
		super.viewWillAppear(animated)
		dataSets = [1,4,6,1]
		barChart.reloadData()
	}

	func barChart(_ barChart: HamsBarChart, configureForCharts view: Int) {

		barChart.title = "BarChart(plain)"
	}
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

Todo

Advanced Configuration

Created By:

Howard Wang - Hire me

Zhiye Jin(UI Designer)

Healthy Fridge Project - Hamster Fridge Management

License

HamsterUIKit is Copyright (c) 2017 Howard Wang and released as open source under the attached Apache 2.0 license.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.