栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Android开发中如何实现折线图的方法 (1),跨平台移动开发工具

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android开发中如何实现折线图的方法 (1),跨平台移动开发工具

其次,对于XCL-chart定制图表也不错,但其实较为适应固定图表,如果需要满足滑动界面操作的话就一言难尽了;再者是achartenginee,这个首先就是界面不怎么样,然后就是适应性不强,不能满足开发者的需求。

最后来说说我们今天的目标:hellochart,据说是非常适合初入门的开发者使用,简单快捷,引入也很方便,而且界面美观,尤其是自己亲历使用之后能感觉到hellochart的代码是比较清晰的,操作时对应的滑动或者是缩放都很流畅。支持饼状图、折线图、柱状图、泡泡型······ 基本可以可以说是“只要你要,只要我有”。


hellochart导入


这部分就简单的一笔带过了,因为网络上已经有很多相关的介绍了:app–>build–>dependencies,在闭包里写

dependencies{

compile ‘com.github.lecho:hellocharts-library:1.5.8@aar’

}

还有一些其他的方法,推荐大家可以到“简书”或者“知乎”上找找吧。


折线图布局部分:

折线图的布局是很简单的:

android:id="@+id/line_chart"

android:padding=“25dp”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

android:background="#ffffff"/>

android:visibility=“gone”

android:divider="@null"

android:scrollbars=“none”

android:layout_marginTop=“15dp”

android:id="@+id/listview"

android:layout_width=“match_parent”

android:layout_height=“match_parent”>

折线图部分对应java代码

public class ListActivity extends Activity {

private ListView listview;

private List stepEntityList = new ArrayList<>();

private StepDataDao stepDataDao;

private LineChartView lineChart;

private List list;

String[] date ;

float [] score;

private List mPointValues = new ArrayList();

private List mAxisXValues = new ArrayList();

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_list);

stepDataDao = new StepDataDao(this);

initView();

list = stepDataDao.getAllDatas( );

date=new String[list.size()];

score=new float[list.size()];

for (int i=0;i

date[i]=list.get(i).getCurDate();

score[i]=Float.parseFloat(list.get(i).getSteps());

}

getAxisXLables();

getAxisPoints();

initLineChart();

}

private void initLin

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

浏览器打开:qq.cn.hn/FTe 免费领取

eChart(){

Line line = new Line(mPointValues).setColor(Color.parseColor("#FFCD41"));

List lines = new ArrayList ();

line.setShape(ValueShape.CIRCLE); //折线图上每个数据点的形状,这里是圆形

line.setCubic(false);

line.setFilled(false);

line.setHasLabels(true);

line.setHasLines(true);

line.setHasPoints(true);

lines.add(line);

LineChartData data = new LineChartData();

data.setLines(lines);

//坐标轴

Axis axisX = new Axis();

axisX.setHasTiltedLabels(true);

axisX.setTextColor(Color.parseColor("#D6D6D9"));//设置字体颜色

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/463005.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号