HamsterUIKit
  • September 10, 2023

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

📊 Curve and bar Charts.
💡 Protocols are designed based on UIKit(UITableView).
🔟 Draw a complex but elegant graph in 10 minutes.

Protocols


Initialize and reload

UITableView HamsCurveChart HamsBarChart
init(frame: CGRect) same same
init?(coder aDecoder: NSCoder) same same
reloadData same same

DataSource

UITableView HamsCurveChart HamsBarChart
numberOfSections(in tableView: UITableView) -> Int numberOfCharts(in curveChart: HamsCurveChart) -> Int numberOfCharts(in barChart: HamsBarChart) -> Int
tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell curveChart(_ curveChart: HamsCurveChart, pointForChart indexPath: HamsIndexPath) -> HamsCurveChartPoint barChart(_ barChart: HamsBarChart, barForChart indexPath: HamsIndexPath) -> HamsBarChartRect
tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int curveChart(_ curveChart: HamsCurveChart, numberOfValuesInChart chart: Int) -> Int barChart(_ barChart: HamsBarChart, numberOfValuesInChart chart: Int) -> Int

Delegate

HamsCurveChart HamsBarChart
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


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()

    }

}

GitHub


View Github

#barchart #chart #chartdemo #curve #ios10 #iosui #protocol #swift #swift3 #swift4 #swiftlibrary #uikit
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...