登录

去注册 忘记密码?

登录

注册

去登录

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

注册

解锁回答区域

  • 扫码关注公众号
  • 发送“我爱安卓

若你登陆,将永久解锁;
若未登录,仅本机解锁。

解锁回答区域

获取注册验证码

  • 扫码关注公众号
  • 发送“我爱安卓
  • 即可获取验证码

一个简单的折线图 LineChartView

Veken   2018-09-01 17:43   收藏

LineChartView

LineChartView是一个关于Android折线图的开源图表库。目前仅支持折线图,点击之后的状态变化,可以选择是画一个图片还是一个背景框。

Screens


Usage

Gradle

  • Step 1. Add LineChartView
    dependencies {
	        compile 'com.veken:linechartview:1.0.1'
	}

XML

  <com.veken.linecharviewmodule.LineChartView
            android:id="@+id/chart_view"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            app:showPicResource="@mipmap/ic_launcher"
            app:defaultStrokeWidth="0.5dp"
            app:pointClickRadius="3dp"
            app:defaultTextSize="16sp"
            app:pointDefaultRadius="2dp"
            app:isNeedBg="true"
            app:clickable="true"
            app:startColor="@color/startColor"
            app:endColor="@color/endColor" />

Java

 LineChartView chartView = findViewById(R.id.chart_view);;
 chartView.setDefaultTextSize(24);
 chartView.setyLableText("分钟");
 chartView.setClickable(true);
 chartView.setNeedBg(true);
 //画的种类,目前仅支持图片和一个背景框
 chartView.setDrawType(DrawType.DrawBackground);

Data

private List<LineChartBean> mList;
if(mList==null){
	mList = new ArrayList<>();
}
Random random = new Random();
for(int i=0;i<7;i++){
	LineChartBean lineChartBean = new LineChartBean();
	lineChartBean.setValue(String.valueOf(random.nextInt(10000)));
	lineChartBean.setDate(String.valueOf(i));
	mList.add(lineChartBean);
}

License

Copyright (C) 2018 Veken

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About Me

简书地址:https://www.jianshu.com/p/4a5949d92821

项目地址:https://github.com/Veken/LineChartView