Latest 0.0.6
Homepage https://github.com/hitsubunnu/HITChartSwift
License MIT
Platforms ios 9.0
Authors

A bitcoin and stock chart lib for iOS. Written in Swift.

HITChartSwift

Requirements

  • iOS 9.0+
  • Swift 4

Sample Project

Build and run the HITChartSwiftSample project in Xcode.

git clone [email protected]:hitsubunnu/HITChartSwift.git

cd HITChartSwift

open HITChartSwift.xcworkspace

Installation

CocoaPods is the recommended method of installing HITChartSwift.

The Pod Way

Simply add the following line to your Podfile:

platform :ios, '9.0'
pod 'HITChartSwift'

Usage

See HITChartSwiftSample

Source Code Way

Import HITChartSwift to your source file

import HITChartSwift

Line Chart

See Sample

data format:

(date: "2018/02/28", close: 10315.00, open: 10583.00, high: 11063.00, low: 10270.00, volume: 43.89, change: -2.40),
(date: "2018/03/01", close: 10925.00, open: 10316.00, high: 11087.00, low: 10224.00, volume: 33.87, change: 5.91)

initialize chart:

let chart = HITLineChartView(frame: CGRect(x: 0, y: 0, width: 812, height: 375))
view.addSubview(chart)
chart.draw(absMaxPercentage, 
            values: data.map{ $0.change }, 
            label: (max: "+(absMaxPercentage)%", center: "", min: "-(absMaxPercentage)%"),
            dates: dates, 
            titles: titles)

Candlestick Chart

See Sample

data format:

(date: "2018/02/28", close: 10315.00, open: 10583.00, high: 11063.00, low: 10270.00, volume: 43.89, change: -2.40),
(date: "2018/03/01", close: 10925.00, open: 10316.00, high: 11087.00, low: 10224.00, volume: 33.87, change: 5.91)

initialize chart:

let chart = HITCandlestickChartView(frame: CGRect(x: 0, y: 0, width: 812, height: 375))
view.addSubview(chart)
chart.draw(absMaxPercentage,
            values: data.map{ (close: $0.close, open: $0.open, high: $0.high, low: $0.low) },
            label: (max: "+(absMaxPercentage)%", center: "", min: "-(absMaxPercentage)%"),
            dates: dates,
            titles: titles)

Pie Chart

See Sample

let chart = HITPieChartView(frame: CGRect(x: 0, y: 0, width: 375, height: 375))
view.addSubview(chart)
chart.draw([(value: 50, color: UIColor.red), (value: 20, color: UIColor.blue), (value: 30, color: UIColor.yellow) ],
            strokeWidth: 100,
            animation: true)

Interface Builder Way

Setup custom class to HITLineChartView

HITChartSwift

Setup options

HITChartSwift

License

HITChartSwift is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "HITChartSwift",
    "version": "0.0.6",
    "summary": "A bitcoin and stock chart lib for iOS.",
    "homepage": "https://github.com/hitsubunnu/HITChartSwift",
    "license": "MIT",
    "authors": {
        "hitsubunnu": "[email protected]"
    },
    "swift_version": "4.0",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/hitsubunnu/HITChartSwift.git",
        "tag": "0.0.6"
    },
    "source_files": [
        "HITChartSwift/*",
        "HITChartSwift/**/*.swift"
    ]
}

Pin It on Pinterest

Share This