股票k线图,分时图的绘制 |
您所在的位置:网站首页 › 根据分时走势图画k线 › 股票k线图,分时图的绘制 |
一,效果图如下: 二,项目结构如下: 三,核心代码 1.项目使用了雅虎k线图的数据,数据的链接地址为: http://ichart.yahoo.com/table.csv?s=601888.SS&g=d 2.主要封装了两个ViewModle:k线图的StockKLineViewModel和分时图的StockMarketIndexViewModel 3:主要封装了两个View:StockView和StockTimeSharingView 4.StockView的核心代码如下: StockView View { = = List = ArrayList()List = ArrayList()List = ArrayList()List = ArrayList()= = = * = String[] String[] List StockKLineViewModel List = ArrayList()List = ArrayList()= * StockView(Context context) { (context)} StockView(Context contextAttributeSet attrs) { (contextattrs)} StockView(Context contextAttributeSet attrsdefStyleAttr) { (contextattrsdefStyleAttr)} StockKLineViewModel () { } (StockKLineViewModel model) { .= modelsetOrdinateData(model.getListKOrdinateData())setAbscissaData(model.getListKAbscissaData())setListKline(model.getListKline())setListF(model.getListF())} () { (!= && .> ) { (i = i ) { .get(i).setTvX(startX).get(i).setTvY(startY)} } (i == (- )) { StockLineModel lineLeft = StockLineModel(* startYpaint).add(lineLeft)StockLineModel lineRight = StockLineModel(- * - startYpaint).add(lineRight)} } } (i == (- )) { startX = startY = (- ) - (- * * ) * / * point = StockLineModel(startXstartY- startYpaint).add(point)} (i == (- )) { startY = (- ) - (- * * ) * / * / drawPoint(startY)startX = (!= && .> ) { .get(- ).setTvX(startX).get(- ).setTvY(startY)} } } StockLineModel pointyPointLeft = (- ) - (- * * ) * / * yPointRight = - point = StockLineModel(yPointRightyPointLeftpaint).add(point)point = StockLineModel(- yPointRight- yPointLeftpaint).add(point)} (pointYwidth) { startY = pointYstop = () (- )sum = (k = k ) { skdm.setColor(Color.)} { skdm.setColor(Color.)} skdm} (String high) { y = highestPrice = StockKLineViewModel.lowestPrice = StockKLineViewModel.starty = ()(*)stopy = (- * * ) * (- ) / + -()(*)per = Tools.((stopy - starty) / (highestPrice - lowestPrice))y = Tools.(stopy - per * (Float.(high) - lowestPrice))y} (String high) { y = highestVolume = StockKLineViewModel.lowestVolume = StockKLineViewModel.bottomY = - bottomHighY = (- ) - (- * * ) * / * +()(*)y = Tools.(bottomY - (((bottomY - bottomHighY) / highestVolume) * Float.(high)))y} (Canvas canvas) { startY = (- * * ) * (- ) / + startX = .add(StockTextModel([]startXstartY)).add(StockTextModel([]- startY))(i = i ) { List list = .getListMarketIndex()(list != && list.size() > ) { (i = i ) { (i = i ) { (i = i |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |