您的位置:首页 > 移动开发 > Android开发

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

2017-09-14 11:48 846 查看

LineChart

android line chart

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



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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息