Skip to content

Latest commit

 

History

History
116 lines (85 loc) · 3.44 KB

README.md

File metadata and controls

116 lines (85 loc) · 3.44 KB

HITChartSwift

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

Line Chart Line Chart Landscape
K-Line Chart K-Line Chart Landscape
Pie

Requirements

  • iOS 9.0+
  • Swift: 5.3.1
  • XCode Version: 12.2+

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

Setup options

License

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