本文整理汇总了Java中lecho.lib.hellocharts.model.PieChartData.setSlicesSpacing方法的典型用法代码示例。如果您正苦于以下问题:Java PieChartData.setSlicesSpacing方法的具体用法?Java PieChartData.setSlicesSpacing怎么用?Java PieChartData.setSlicesSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.PieChartData
的用法示例。
在下文中一共展示了PieChartData.setSlicesSpacing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initMealsPie
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
public static void initMealsPie(PieChartView pieChartView, TodayDiets todayDiets) {
List<SliceValue> values = new ArrayList();
if (todayDiets.breakfast != null && todayDiets.breakfast.percentage > 0.0f) {
values.add(new SliceValue(todayDiets.breakfast.percentage, MEALS_COLORS[0]).setLabel(
((int) (todayDiets.breakfast.percentage * 100.0f)) + "%早餐"));
}
if (todayDiets.lunch != null && todayDiets.lunch.percentage > 0.0f) {
values.add(new SliceValue(todayDiets.lunch.percentage, MEALS_COLORS[1]).setLabel((
(int) (todayDiets.lunch.percentage * 100.0f)) + "%午餐"));
}
if (todayDiets.dinner != null && todayDiets.dinner.percentage > 0.0f) {
values.add(new SliceValue(todayDiets.dinner.percentage, MEALS_COLORS[2]).setLabel((
(int) (todayDiets.dinner.percentage * 100.0f)) + "%晚餐"));
}
PieChartData data = new PieChartData(values);
data.setHasLabels(true);
data.setHasLabelsOnlyForSelected(false);
data.setHasLabelsOutside(false);
data.setHasCenterCircle(false);
data.setSlicesSpacing(3);
data.setValueLabelBackgroundColor(0);
data.setValueLabelBackgroundEnabled(true);
pieChartView.setValueSelectionEnabled(true);
pieChartView.setPieChartData(data);
pieChartView.startDataAnimation();
}
示例2: setPieDatas
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void setPieDatas() {
int numValues = 6; //把一张饼切成6块
/*===== 随机设置每块的颜色和数据 =====*/
List<SliceValue> values = new ArrayList<>();
for (int i = 0; i < numValues; ++i) {
SliceValue sliceValue = new SliceValue((float) Math.random() * 30 + 15, ChartUtils.pickColor());
values.add(sliceValue);
}
/*===== 设置相关属性 类似Line Chart =====*/
mPieChartData = new PieChartData(values);
mPieChartData.setHasLabels(isHasLabelsInside);
mPieChartData.setHasLabelsOnlyForSelected(isPiesHasSelected);
mPieChartData.setHasLabelsOutside(isHasLabelsOutside);
mPieChartData.setHasCenterCircle(isHasCenterCircle);
//是否分离
if (isExploded) {
mPieChartData.setSlicesSpacing(18); //分离间距为18
}
//是否显示单行文本
if (isHasCenterSingleText) {
mPieChartData.setCenterText1("病虫害"); //文本内容
}
//标签显示样式
mPieChartView.setCircleFillRatio(1.0f);
//是否显示双行文本
if (isHasCenterDoubleText) {
mPieChartData.setCenterText2("种类比例"); //文本内容
mPieChartData.setCenterText2FontSize(ChartUtils.px2sp(getResources().getDisplayMetrics().scaledDensity,
(int) getResources().getDimension(R.dimen.pie_chart_double_text_size)));
}
mPieChartView.setPieChartData(mPieChartData); //设置控件
}