1 Star 0 Fork 0

jason_xiaochao@163.com / JSUStockChatDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

JSUStockChat

JSUStockChat is a easy way to make stock chart with Auto Layout And StoryBoard!

  • Xcode 7.3 / Swift 2.2 / 3.0
  • iOS 8.0 / 9.0

##Key Features 1.Standard

2.Breathing Lamp

3.Landscape

4.LongPress

5.Zoom

Usage

1.Drag JSUStockChart to your project.

2.Drag a UIView to your ViewController.

3.Change the view Custom Class to TimeLineStockChartView and Connect to @IBOutlet weak var timeView.

4.In ViewDidLoad.


class JSUTimeViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.timeView.setupChartOffsetWithLeft(16,top:10,right:16,bottom:10)
        self.timeView.drawLabelPriceInside = true
        self.timeView.drawLabelRatioInside = true
        self.timeView.gridBackgroundColor = UIColor.whiteColor()
        self.timeView.borderColor = UIColor(netHex: 0xe4e4e4, alpha: 1)
        self.timeView.borderWidth = 0.5
        self.timeView.uperChartHeightScale = 0.7;
        self.timeView.xAxisHeitht = 25
        self.timeView.countOfTimes = 242

        loadData()
        
    }

}

5.loadData,I get data from a json file,you can get it from your webservice.

    func loadData(){
        //get priceData
        let model:JSUPriceModel = readFile("timeLineData", ext: "json")
        self.setupTimeLineView(model)
    }

6.setupTimeLineView

 
    func setupTimeLineView(data:JSUPriceModel){
        var timeArray = [TimeLineEntity]()
        var lastVolume = CGFloat(0)
        
        if let shares = data.shares{
            var lastAvg = CGFloat(0)
            for dic in shares{
                let entity = TimeLineEntity()
                entity.currtTime = dic.dt?.toString("HH:mm")
                if let c = data.close{
                    entity.preClosePx = CGFloat(c)
                }
                
                if let p = dic.price{
                    entity.lastPirce = CGFloat(p)
                }
                
                if let v = dic.volume{
                    entity.volume = CGFloat(v) - lastVolume
                    lastVolume = CGFloat(v)
                    
                    if let a = dic.amount{
                        //均线
                        entity.avgPirce = CGFloat(a/v)
                    }
                }
                
                if isnan(entity.avgPirce){
                    entity.avgPirce = lastAvg
                }else{
                    lastAvg = entity.avgPirce
                }
                
                //涨跌幅
                if let r = dic.ratio{
                   entity.rate = CGFloat(r)
                }
                timeArray.append(entity)
            }
        }

        let set  = TimeDataset()
        set.data = timeArray;
        set.avgLineCorlor = UIColor(netHex: 0xffc004, alpha: 1)
        set.priceLineCorlor = UIColor(netHex: 0x0095ff, alpha: 1)
        set.lineWidth = 1;
        set.highlightLineWidth = 0.8
        set.highlightLineColor = UIColor(netHex: 0x546679, alpha: 1)
        

            
        set.volumeTieColor = UIColor(netHex: 0xaaaaaa, alpha: 1)
        set.volumeRiseColor = UIColor(netHex: 0xf24957, alpha: 1)
        set.volumeFallColor = UIColor(netHex: 0x1dbf60, alpha: 1)
        
        set.fillStartColor = UIColor(netHex: 0xe3efff, alpha: 1)
        set.fillStopColor = UIColor(netHex: 0xe3efff, alpha: 1)
        set.fillAlpha = 0.5
        set.drawFilledEnabled = true
        self.timeView.highlightLineShowEnabled = true;
        self.timeView.endPointShowEnabled = NSDate().isTradingTime()
        self.timeView.setupData(set)

    }

License

MIT license. See the LICENSE file for details.

The MIT License (MIT) Copyright (c) 2016 BestSwift Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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 OR COPYRIGHT HOLDERS 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.

简介

暂无描述 展开 收起
Swift
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Swift
1
https://gitee.com/jason.su/JSUStockChatDemo.git
git@gitee.com:jason.su/JSUStockChatDemo.git
jason.su
JSUStockChatDemo
JSUStockChatDemo
master

搜索帮助