开源控件hellocharts
来源:互联网 发布:c语言 char数组 编辑:程序博客网 时间:2024/05/19 21:58
github地址:
https://github.com/lecho/hellocharts-android
jar下载地址(eclipse):
https://github.com/lecho/hellocharts-android/releases
折线图 line chart
// 1 LineChartView mChartView = (LineChartView) findViewById(R.id.linechart); // 2 LineChartData data = new LineChartData(); // 3 List<PointValue> values = new ArrayList<PointValue>(); values.add(new PointValue(0, 1)); values.add(new PointValue(1, 3)); values.add(new PointValue(2, 2)); values.add(new PointValue(3, 4)); Line line = new Line(values).setColor(Color.RED).setCubic(true); List<PointValue> values2 = new ArrayList<PointValue>(); values2.add(new PointValue(4, 3)); values2.add(new PointValue(5, 2)); values2.add(new PointValue(6, 1)); values2.add(new PointValue(7, 5)); Line line2 = new Line(values2).setColor(Color.BLUE).setCubic(true); // 4 List<Line> lines = new ArrayList<Line>(); lines.add(line); lines.add(line2); data.setLines(lines); mChartView.setLineChartData(data); // 设置不让放大(手势放大) mChartView.setZoomEnabled(false);
效果
柱状图 Column Chart
<lecho.lib.hellocharts.view.ColumnChartView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/columnchart" />
Activity
// 1 ColumnChartView mColumnChartView = (ColumnChartView) findViewById(R.id.columnchart); // 2 ColumnChartData mChartData = new ColumnChartData(); // 3 List<Column> columns = new ArrayList<Column>(); List<SubcolumnValue> values = new ArrayList<SubcolumnValue>(); // 柱状的高度,颜色 values.add(new SubcolumnValue(1,Color.RED)); values.add(new SubcolumnValue(2,Color.BLUE)); values.add(new SubcolumnValue(3,Color.YELLOW)); values.add(new SubcolumnValue(4,Color.GREEN)); Column column = new Column(values); // 4 columns.add(column); mChartData.setColumns(columns); mColumnChartView.setColumnChartData(mChartData);
效果
饼图 Pie chart
xml
<lecho.lib.hellocharts.view.PieChartView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/piechart" />
Activity
// 1 PieChartView mPieChartView = (PieChartView) findViewById(R.id.piechart); // 2 PieChartData data = new PieChartData(); // 3 比例,颜色 List<SliceValue> values = new ArrayList<SliceValue>(); values.add(new SliceValue(1, Color.RED)); values.add(new SliceValue(2,Color.BLUE)); values.add(new SliceValue(3,Color.YELLOW)); values.add(new SliceValue(4,Color.GREEN)); // 4 data.setValues(values); mPieChartView.setPieChartData(data);
效果
气泡图 Bubble chart
xml
<lecho.lib.hellocharts.view.BubbleChartView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/bubblechart" />
Activity
// 1 BubbleChartView mBubbleChartView = (BubbleChartView) findViewById(R.id.bubblechart); // 2 BubbleChartData data = new BubbleChartData(); // 3 List<BubbleValue> mBubbleValues = new ArrayList<BubbleValue>(); mBubbleValues.add(new BubbleValue(0, 3, 1, Color.RED));//(x,y,z,color) z=大小 mBubbleValues.add(new BubbleValue(1, 1, 1, Color.YELLOW)); mBubbleValues.add(new BubbleValue(2, 2, 2, Color.BLUE)); mBubbleValues.add(new BubbleValue(3, 5, 3, Color.GREEN)); mBubbleValues.add(new BubbleValue(4, 4, 2, Color.LTGRAY)); // 4 data.setValues(mBubbleValues); data.setBubbleScale(1.0f); // 缩放尺寸 mBubbleChartView.setBubbleChartData(data); // 不让点击放大 mBubbleChartView.setZoomEnabled(false);
效果
坐标轴 AXIS
Activity
// 1 LineChartView mChartView = (LineChartView) findViewById(R.id.linechart); // 2 LineChartData data = new LineChartData(); // 3 List<PointValue> values = new ArrayList<PointValue>(); values.add(new PointValue(0, 1)); values.add(new PointValue(1, 3)); values.add(new PointValue(2, 2)); values.add(new PointValue(3, 4)); values.add(new PointValue(4, 3)); values.add(new PointValue(5, 2)); values.add(new PointValue(6, 1)); values.add(new PointValue(7, 5)); Line line = new Line(values).setColor(Color.RED).setCubic(true); // 4 List<Line> lines = new ArrayList<Line>(); lines.add(line); data.setLines(lines); mChartView.setLineChartData(data); // 坐标轴 List<AxisValue> axisValues = new ArrayList<AxisValue>(); axisValues.add(new AxisValue(0)); axisValues.add(new AxisValue(1)); axisValues.add(new AxisValue(2)); axisValues.add(new AxisValue(3)); axisValues.add(new AxisValue(4)); axisValues.add(new AxisValue(5)); axisValues.add(new AxisValue(6)); axisValues.add(new AxisValue(7)); axisValues.add(new AxisValue(8)); Axis axis = new Axis(axisValues); // 小数 axis.setAutoGenerated(true); // 网格 axis.setHasLines(true); // 斜体 axis.setHasTiltedLabels(true); // 坐标轴名字 axis.setName("axis"); // data.setAxisXBottom(axis); data.setAxisYLeft(axis);
效果
/////TO BE CONTINUE
0 0
- 开源控件hellocharts
- Android开源图表控件hellocharts-android简单使用
- Android开源图表库:HelloCharts
- Android 图标控件 Hellocharts使用手册
- HelloCharts
- HelloCharts
- hellocharts-android开源图表库(效果非常好)
- hellocharts-android开源图表库(效果非常好)
- HelloCharts开源图表库(一)之折线图
- 使用HelloCharts开源图表库制作柱状图
- hellocharts-android开源图表库(效果非常好)
- hellocharts-android开源图表库(效果非常好)
- hellocharts-android开源图表库(效果非常好)
- 关于开源图表hellocharts-android的一些使用心得
- 安卓学习笔记---图表控件 HelloCharts
- android开源图表框架HelloChart的使用 (hellocharts-library-1.5.8.jar)
- 开源图表库hellocharts之最详细的使用介绍
- Android 图表开源框架HelloCharts 之 柱状图、折线图、饼状图,Fragment
- Android 删除文件
- 将所有的.jsp动态页面变成.html静态页面
- 监听返回键
- IntentService使用详解和实例介绍
- 使用AbstractProcessor遇到的一些问题
- 开源控件hellocharts
- C语言第一次课
- Palantir如何通过技术协助客户作业的,也是我看到过的讲大数据故事最精彩的一篇。
- 浅析java class文件格式
- 链表中环的入口结点
- CorelDRAW中如何实现抠图
- 【ANDROID】ASYNCTASK不回调ONPOSTEXECUTE方法的解决办法。
- hibernate 4.0模糊查询
- 回首栈与队列