仿中国比特币首页趋势图,折线图,k线图

LineChart

android line chart

仿照中国比特币的首页行情趋势图 www.chbtc.com

demoview

Github Repository and Library

https://github.com/onlynight/LineChart

使用

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    compile 'com.github.onlynight:LineChart:1.0.0'
}

Step 3. in your xml layout file

<com.github.onlynight.chart.LineChartView
    android:id="@+id/chart"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    app:axisXHasScaleText="true"
    app:axisXHasVerticalLine="true"
    app:axisXMaxScaleNum="4"
    app:axisXScalePosition="center"
    app:axisYHasScaleText="true"
    app:axisYHasVerticalLine="true"
    app:axisYMaxScaleNum="4"
    app:axisYScalePosition="center"
    app:axisYScaleTextSize="10sp"
    app:contentMargin="10dp"
    app:hasAxisX="true"
    app:hasAxisY="true"
    app:lineContentMargin="10dp"/>

Step 4. in your java controller file

mLineChartView = (LineChartView) findViewById(R.id.chart);
initChartData();

private void initChartData() {
    Line line = new Line().setLineColor(Color.RED).setLineWidth(5).setCube(true);
    List<ChartPoint> chartPoints = new ArrayList<>();
    Random random = new Random();
    for (int i = 0; i < 100; i++) {
        ChartPoint cp = new ChartPoint(i, random.nextInt() * 100 % 5);
        cp.setValue(String.valueOf(i));
        chartPoints.add(cp);
    }
    line.setData(chartPoints);
    mLineChartView.setLine(line);
}

猜你喜欢

转载自blog.csdn.net/tgbus18990140382/article/details/77978667
今日推荐