Giter Site home page Giter Site logo

kdemo's Introduction

KDemo

专业k线图表组件,支持JDK,MACD,MA,VOL等指标,后续指标陆续更新

image

android studio开发工具中: 第一步:在工程build.gradle中添加如下代码

allprojects { repositories { ... maven { url "https://jitpack.io" } } } 第二步:在dependency,添加如下代码

dependencies { compile 'com.github.zhangliangzs:KDemo:1.0.0' }

项目应用: 在布局文件中添加组件: <zhangliang.view.android.klibrary.view.KView android:id="@+id/kview" android:layout_width="match_parent" android:layout_height="match_parent" />

activity中找到控件: KView mMyChartsView = (KView) findViewById(R.id.kview);

最主要的是数据的显示,数据mode的封装,主要封装在MarketChartData中:结构如下:

public class MarketChartData { long time = 0; double openPrice = 0; double closePrice = 0; double lowPrice = 0; double highPrice = 0; double vol = 0;

public MarketChartData() {

}

public long getTime() {
    return time;
}

public String getTime2() {
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    return sdf.format(time*1000);
}
public String getTime3() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sdf.format(time*1000);
}
public String getTime4() {
    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
    return sdf.format(time*1000);
}
public void setTime(long time) {
    this.time = time;
}

public double getOpenPrice() {
    return openPrice;
}

public void setOpenPrice(double openPrice) {
    this.openPrice = openPrice;
}

public double getClosePrice() {
    return closePrice;
}

public void setClosePrice(double closePrice) {
    this.closePrice = closePrice;
}

public double getLowPrice() {
    return lowPrice;
}

public void setLowPrice(double lowPrice) {
    this.lowPrice = lowPrice;
}

public double getHighPrice() {
    return highPrice;
}

public void setHighPrice(double highPrice) {
    this.highPrice = highPrice;
}

public double getVol() {
    return vol;
}

public void setVol(double vol) {
    this.vol = vol;
}

}

new 个数组装载model数据: private List marketChartDataLists = new ArrayList(); 你的activity界面请求json数据,封装在这个模型中,在代码中添加

  mMyChartsView.setOHLCData(marketChartDataLists);
  mMyChartsView.postInvalidate();

  就能将图表数据显示出来


  主要方法:
        mMyChartsView.setClose();//关闭指标
        mMyChartsView.setMACDShow();//显示macd
        mMyChartsView.setKDJShow();//显示kdj

如果有疑问请加QQ:1179980507,一起完善和做好这个控件

IOS版地址: https://github.com/zhiquan911/CHKLineChart

效果如下图: image

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.