Code Monkey home page Code Monkey logo

chklinechart's Introduction

#CHKLineChart

demo2.png

纯Swift3.0代码编写的K线图表组件,支持:MA,EMA,KDJ,MACD等技术指标显示。集成使用简单,二次开发扩展强大。

##Features

  • 完美支持Swift3.0编译
  • 支持显示蜡烛图,交易量图,及MA,EMA,KDJ,MACD等技术指标图表
  • 支持使用代码创建视图或使用xib/storyboard创建视图
  • 集成使用简单,二次开发扩展强大

##Requirements

  • iOS 9+
  • Xcode 8+
  • Swift 3.0+
  • iPhone/iPad

##Installation

###CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

You can install it with the following command:

$ gem install cocoapods

To integrate Log into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'CHKLineChart'

##Example

把项目classes文件夹导入到项目中,在使用的viewController,导入框架

var chartView: CHKLineChartView!

override func viewDidLoad() {
    self.chartView = CHKLineChartView()
    self.chartView.style = .base       //默认样式
    self.chartView.delegate = self
    self.chartView.frame = self.view.bounds
    self.view.addSubview(self.chartView)
}

实现图表的数据源代理方法

func numberOfPointsInKLineChart(_ chart: CHKLineChartView) -> Int {
    return self.klineDatas.count
}

func kLineChart(_ chart: CHKLineChartView, valueForPointAtIndex index: Int) -> CHChartItem {
    let data = self.klineDatas[index] as! [Double]
    let item = CHChartItem()
    item.time = Int(data[0] / 1000)
    item.openPrice = CGFloat(data[1])
    item.highPrice = CGFloat(data[2])
    item.lowPrice = CGFloat(data[3])
    item.closePrice = CGFloat(data[4])
    item.vol = CGFloat(data[5])
    return item
}

func kLineChart(_ chart: CHKLineChartView, labelOnYAxisForValue value: CGFloat, section: CHSection) -> String {
    var strValue = ""
    if value / 10000 > 1 {
        strValue = (value / 10000).ch_toString(maxF: 2) + ""
    } else {
        strValue = value.ch_toString(maxF: 2)
    }
    return strValue
}
    
func kLineChart(_ chart: CHKLineChartView, labelOnXAxisForIndex index: Int) -> String {
    let data = self.klineDatas[index] as! [Double]
    let timestamp = Int(data[0])
    return Date.getTimeByStamp(timestamp, format: "HH:mm")
}

更详细集成方法,根据实际的例子请查看源代码中的demo

###Donations

为了让开发者更积极分享技术,开源程序代码,我们发起数字货币捐助计划,捐款只接收以下货币。

  • BTC Address: 1HvgRTi2CmaSHUkfWUCAqkYjF7AiBohzbB

  • ETH/ETC Address: 0xc312ed502fb57e0c42f9C7663CB7A3B0A6c4f6D2

###License

Released under MIT License.

chklinechart's People

Contributors

zhiquan911 avatar

Watchers

James Cloos avatar Yufeng.Meng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.