android-kline

Professional K chart based on MPAndroidChart

The project address

This project customized the latest version of MPAndroidChart by inheritance, without modifying the source code of MPAndroidChart, so it will not affect children’s shoes already using MPAndroidChart.

  • Fixed gesture synchronization for multiple charts
  • Fix multiple chart highlight linkage issues
  • Simple to use, two lines of code can achieve professional K line effect

Demo

The demo is below and can also be downloaded here

What’s new

  • Added MACD and KDJ indicator display and switch
  • Added a 5-day timeshare chart
  • Optimizes the scale of the chart to zoom in and out (previously only supported in the initial state of the zoom)
  • The zoom function of the splicing chart (previously, if one finger is on the K-chart and the other finger is on the trading volume chart, the chart can not be zoomed)
  • An example of full-screen mode
  • The time – sharing chart increases the coordinates of the rise and fall, and the rise and fall is 0% vertically centered display
  • Add Max/min display to k-line graph

use

Add dependencies to your build.gradle project:

 allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io"Dependencies}}} {the compile com. Making. Gzw19931217: android - kline: 1.0.0'}Copy the code

xml

    <com.guoziwei.klinelib.chart.KLineView
        android:id="@+id/kline"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
Copy the code
    <com.guoziwei.klinelib.chart.TimeLineView
        android:id="@+id/timeline"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
Copy the code

java

KLineView K line diagram control public void showKdj() Displays KDJ indicators public void showMacd() displays MACD indicators public void showVolume() Displays transaction volume indicators public Void initData(List<HisData> hisDatas) initializes data, Public void addData(HisData HisData) public void refreshData(floatTimeLineView public void initData(List<HisData> hisDatas) Public void addData(HisData HisData) public void refreshData(floatPublic void initDatas(List<HisData>... HisDatas (hisDatas); hisDatas (hisDatas); hisDatas (hisDatas)setLastClose(double LastClose) set yesterday's closing price, used to calculate the coordinates of the rise and fall of two classes common API: public voidsetCount(int init, int Max, int min) Sets the initial, maximum, and minimum number of visible ICONS. For example, (100,300,50) is to start with 100 points, the minimum can be scaled to 300 points, the maximum can be enlarged to 50 pointsCopy the code

Note: we need to receive a HisData List, HisData needs the following data (open, close, high, low, buy/sell, time), the other indicators will be calculated according to the formula

In this project, the timestamp date is equivalent to a unique ID that cannot be added to the chart if repeated

  public HisData(double open, double close, double high, double low,  int vol, long date)
Copy the code

Personalization: If you need to configure colors, do so in colors.xml.