HelloChart--PieChartView(饼图)
来源:互联网 发布:汕头酒店美工招聘 编辑:程序博客网 时间:2024/05/22 01:11
在XML中的定义:
<lecho.lib.hellocharts.view.PieChartView
android:id="@+id/piechart"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</lecho.lib.hellocharts.view.PieChartView>
控件实例化:
PieChartView pieChart;
pieChart=(PieChartView)findViewById(R.id.pieChart);
chart属性设置:
pieChart.setViewportCalculationEnabled(true);//设置饼图自动适应大小
pieChart.setChartRotation(int rotation,boolean isAnimated);//设置饼图旋转角度,且是否为动画
pieChart.setChartRotationEnabled(boolean isRotationEnabled);//设置饼图是否可以手动旋转
pieChart.setCircleFillRatio(float fillRatio);//设置饼图其中的比例
pieChart.setCircleOval(RectF orginCircleOval);//设置饼图成椭圆形
pieChart.setPieChartData(PieChartData data);//为饼图设置数据
设置PieChartData属性及为chart设置数据:
PieChartData pd=new PieChartData();//实例化PieChartData对象
pd.setHasLabelsOutside(boolean hasLabelsOutside);//设置饼图外面是否显示值
pd.setHasCenterCircle(boolean hasCenterCircle);//设置饼图中间是否有第二个圈
pd.setCenterCircleColor(int centerCircleColor);//设置饼图中间圈的颜色
pd.setCenterCircleScale(float centerCircleScale);////设置第二个圈的大小比例
pd.setCenterText1(String centerText1);//设置文本
pd.setCenterText1Color(int centerText1Color);//设置文本颜色
pd.setCenterText1FontSize(int centerText1FontSize);//设置文本大小
pd.setCenterText1Typeface(Typeface text1Typeface);//设置文本字体
pd.setCenterText2(String centerText2);//设置第二个圈文本
pd.setCenterText2Color(int centerText2Color);//设置第二个圈文本颜色
pd.setCenterText2Typeface(Typeface text2Typeface);//设置第二个圈文本字体
pd.setValueLabelsTextColor(int valueLabelTextColor);//设置显示值的字体颜色
pd.setSlicesSpacing(int sliceSpacing);//设置数据间的间隙
pd.setHasLabelsOnlyForSelected(boolean hasLabelsOnlyForSelected);//设置当值被选中才显示
List<SliceValue> sliceList = new ArrayList<SliceValue>();
for(int i=0;i<10;i++){//循环为饼图设置数据
sliceList.add(new SliceValue(float value, int color).setLabel(String label));
}
pd.setValues(List<SliceValue> sliceList);//为饼图添加数据
pieChart.setPieChartData(PieChartData data);//将数据设置给饼图
<lecho.lib.hellocharts.view.PieChartView
android:id="@+id/piechart"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</lecho.lib.hellocharts.view.PieChartView>
控件实例化:
PieChartView pieChart;
pieChart=(PieChartView)findViewById(R.id.pieChart);
chart属性设置:
pieChart.setViewportCalculationEnabled(true);//设置饼图自动适应大小
pieChart.setChartRotation(int rotation,boolean isAnimated);//设置饼图旋转角度,且是否为动画
pieChart.setChartRotationEnabled(boolean isRotationEnabled);//设置饼图是否可以手动旋转
pieChart.setCircleFillRatio(float fillRatio);//设置饼图其中的比例
pieChart.setCircleOval(RectF orginCircleOval);//设置饼图成椭圆形
pieChart.setPieChartData(PieChartData data);//为饼图设置数据
设置PieChartData属性及为chart设置数据:
PieChartData pd=new PieChartData();//实例化PieChartData对象
pd.setHasLabelsOutside(boolean hasLabelsOutside);//设置饼图外面是否显示值
pd.setHasCenterCircle(boolean hasCenterCircle);//设置饼图中间是否有第二个圈
pd.setCenterCircleColor(int centerCircleColor);//设置饼图中间圈的颜色
pd.setCenterCircleScale(float centerCircleScale);////设置第二个圈的大小比例
pd.setCenterText1(String centerText1);//设置文本
pd.setCenterText1Color(int centerText1Color);//设置文本颜色
pd.setCenterText1FontSize(int centerText1FontSize);//设置文本大小
pd.setCenterText1Typeface(Typeface text1Typeface);//设置文本字体
pd.setCenterText2(String centerText2);//设置第二个圈文本
pd.setCenterText2Color(int centerText2Color);//设置第二个圈文本颜色
pd.setCenterText2Typeface(Typeface text2Typeface);//设置第二个圈文本字体
pd.setValueLabelsTextColor(int valueLabelTextColor);//设置显示值的字体颜色
pd.setSlicesSpacing(int sliceSpacing);//设置数据间的间隙
pd.setHasLabelsOnlyForSelected(boolean hasLabelsOnlyForSelected);//设置当值被选中才显示
List<SliceValue> sliceList = new ArrayList<SliceValue>();
for(int i=0;i<10;i++){//循环为饼图设置数据
sliceList.add(new SliceValue(float value, int color).setLabel(String label));
}
pd.setValues(List<SliceValue> sliceList);//为饼图添加数据
pieChart.setPieChartData(PieChartData data);//将数据设置给饼图
0 0
- HelloChart--PieChartView(饼图)
- HelloChart--PieChartView(饼图)
- HelloChart--ColumnChartView(柱形图)
- HelloChart--ColumnChartView(柱形图)
- HelloChart--LineChartView(折线图)
- HelloChart--BubbleChartView(气泡图)
- HelloChart--ComboLineColumnChartView(组合统计图)
- HelloChart--PreviewChartView(预览统计图)
- HelloChart--PreviewChartView(预览统计图)
- HelloChart--ComboLineColumnChartView(组合统计图)
- HelloChart--BubbleChartView(气泡图)
- HelloChart--LineChartView(折线图)
- hellochart详细讲解(一)折线图
- hellochart详细讲解(二)饼状图
- hellochart详细讲解(三)柱状图
- Android HelloChart开源库图表(一)之折线图
- Android HelloChart开源库图表(二)之饼图
- Android hellochart使用(可以在Eclipse中运行)
- HelloChart--ColumnChartView(柱形图)
- 图解集合4:HashMap
- Xmind默认字体的修改方法
- jsp中使用EL表达式并且在js中使用该值需要注意的地方
- CXF webService集成spring
- HelloChart--PieChartView(饼图)
- android程序报错:error:Error:String types not allowed(at 'configChanges' with value '
- android 通知栏图标变白色方格
- Google Map定位,大头针(Swift3.0)
- iOS 推送全解析,你不可不知的所有 Tips!(完整版)
- GitLab: You are not allowed to push code to protected branches on this project.
- android 基础 res文件 drawable
- POJ 2288 Islands and Bridges
- JS实现密码加密