本文整理汇总了Java中lecho.lib.hellocharts.model.PieChartData.setHasLabels方法的典型用法代码示例。如果您正苦于以下问题:Java PieChartData.setHasLabels方法的具体用法?Java PieChartData.setHasLabels怎么用?Java PieChartData.setHasLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.PieChartData
的用法示例。
在下文中一共展示了PieChartData.setHasLabels方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generateData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void generateData() {
List<SliceValue> values = new ArrayList<SliceValue>();
String s1 = String.format("%.2f", ((double) yes / all) * 100);
SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
sliceValue1.setLabel("已报到" + s1 + "%");
values.add(sliceValue1);
String s2 = String.format("%.2f", ((double) no / all) * 100);
SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
sliceValue2.setLabel("未报到" + s2 + "%");
values.add(sliceValue2);
data = new PieChartData(values);
data.setHasLabels(true);
data.setHasLabelsOnlyForSelected(false);
data.setHasLabelsOutside(false);
chart.setValueSelectionEnabled(true);
chart.setCircleFillRatio(1.0f);
chart.setPieChartData(data);
}
示例3: generateData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void generateData() {
List<SliceValue> values = new ArrayList<SliceValue>();
String s1 = String.format("%.2f", ((double) yes / all) * 100);
SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
sliceValue1.setLabel("已报到" + s1 + "%");
values.add(sliceValue1);
String s2 = String.format("%.2f", ((double) no / all) * 100);
SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
sliceValue2.setLabel("未报到" + s2 + "%");
values.add(sliceValue2);
data = new PieChartData(values);
data.setHasLabels(true);
data.setHasLabelsOnlyForSelected(false);
data.setHasLabelsOutside(false);
chart.setValueSelectionEnabled(true);
chart.setCircleFillRatio(1.0f);
chart.setPieChartData(data);
}
示例4: generateData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void generateData() {
List<SliceValue> values = new ArrayList<SliceValue>();
String s1 = String.format("%.2f", ((double) yes / all) * 100);
SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
sliceValue1.setLabel("已报到"+s1+"%");
values.add(sliceValue1);
String s2 = String.format("%.2f", ((double) no / all) * 100);
SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
sliceValue2.setLabel("未报到"+s2+"%");
values.add(sliceValue2);
data = new PieChartData(values);
data.setHasLabels(true);
data.setHasLabelsOnlyForSelected(false);
data.setHasLabelsOutside(false);
chart.setValueSelectionEnabled(true);
chart.setCircleFillRatio(1.0f);
chart.setPieChartData(data);
}
示例5: 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); //设置控件
}
示例6: onCreateView
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
List<SliceValue> list = new ArrayList<SliceValue>();
// incomePieChart = (PieChartView) findViewById(R.id.income_chart);
incomePieChart.setOnValueTouchListener(new ValueTouchListener());
MyDBHelper myDBHelper = MyDBHelper.newInstance(null);
SQLiteDatabase db = myDBHelper.getWritableDatabase();
/*Cursor cursor = db.rawQuery("Select " + DBTablesDefinition.Records.TABLE_RECORDS_NAME + "." + DBTablesDefinition.Records.ID + "," +
DBTablesDefinition.Accounts.TABLE_ACCOUNT_NAME + "." + DBTablesDefinition.Accounts.COLUMN_ACCOUNT_NAME + "," + DBTablesDefinition.Records.TABLE_RECORDS_NAME + "." + DBTablesDefinition.Records.COLUMN_RECORDS_DATE
+ "," + DBTablesDefinition.Records.TABLE_RECORDS_NAME + "." + DBTablesDefinition.Records.COLUMN_RECORDS_AMOUNT + " from " + DBTablesDefinition.Records.TABLE_RECORDS_NAME + " left join " +
DBTablesDefinition.Accounts.TABLE_ACCOUNT_NAME + " on " + DBTablesDefinition.Records.TABLE_RECORDS_NAME + "." + DBTablesDefinition.Records.COLUMN_RECORDS_ACCOUNT_NAME_ID
+ " = " + DBTablesDefinition.Accounts.TABLE_ACCOUNT_NAME + "." + DBTablesDefinition.Accounts.ID + " where " + DBTablesDefinition.Records.TABLE_RECORDS_NAME + "." + DBTablesDefinition.Records.COLUMN_RECORDS_FLAG_OF_INCOME_OR_EXPENSE
+ " = " + DBTablesDefinition.INCOME, null);
*/
Cursor cursor = db.rawQuery("select records.id,accounts.name,records.date,SUM(records.amount),incomeOrExpenses.name from records,accounts,incomeOrExpenses where records.accountNameId=accounts.id and records.incomeOrExpense=incomeOrExpenses.id and incomeOrExpenses.flag=0 group by accounts.name", null);
// System.out.println("Cursor count is " + cursor.getCount());
while (cursor.moveToNext()) {
// System.out.println(cursor.getInt(0) + " " + cursor.getString(1) + " " + cursor.getString(2) + " " + cursor.getDouble(3) + " " + cursor.getString(4));
SliceValue sliceValue = new SliceValue((float) cursor.getDouble(3), ChartUtils.pickColor());
list.add(sliceValue);
}
incomePiedata = new PieChartData(list);
incomePiedata.setHasLabels(hasLabels);
incomePiedata.setHasLabelsOnlyForSelected(hasLabelForSelected);
incomePiedata.setHasLabelsOutside(hasLabelsOutside);
incomePiedata.setHasCenterCircle(hasCenterCircle);
incomePieChart.setPieChartData(incomePiedata);
return null;
}
示例7: generateData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void generateData() {
List<SliceValue> values = new ArrayList<SliceValue>();
if (yes != 0) {
SliceValue sliceValue1 = new SliceValue(yes, ChartUtils.pickColor());
sliceValue1.setLabel(this.pay + yes + "人");
values.add(sliceValue1);
}
if (no != 0) {
SliceValue sliceValue2 = new SliceValue(no, ChartUtils.pickColor());
sliceValue2.setLabel(this.notPay+ no + "人");
values.add(sliceValue2);
}
if (loanPay != 0) {
SliceValue sliceValue3 = new SliceValue(loanPay, ChartUtils.pickColor());
sliceValue3.setLabel(this.loanPay1 + loanPay + "人");
values.add(sliceValue3);
}
if (latePay != 0) {
SliceValue sliceValue4 = new SliceValue(latePay, ChartUtils.pickColor());
sliceValue4.setLabel(this.latePay1 + latePay + "人");
values.add(sliceValue4);
}
data = new PieChartData(values);
data.setHasLabels(true);
data.setHasLabelsOnlyForSelected(false);
data.setHasLabelsOutside(false);
chart.setValueSelectionEnabled(true);
chart.setCircleFillRatio(1.0f);
chart.setPieChartData(data);
}
示例8: setChartData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void setChartData(FoodModel food) {
List<SliceValue> values = new ArrayList<SliceValue>();
values.add(new SliceValue((float) food.getFatsPercent(), mView.getFatsColor()));
values.add(new SliceValue((float) food.getCarbohydratesPercent(), mView.getCarbohydrtesColor()));
values.add(new SliceValue((float) food.getProteinsPercent(), mView.getProteinsColor()));
PieChartData pieChartData = new PieChartData(values);
pieChartData.setHasCenterCircle(true);
pieChartData.setHasLabels(false);
mView.setPieChartData(pieChartData);
}
示例9: initPieChartDataSet
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void initPieChartDataSet(PieChartData dataSet) {
initBaseChartDataSet(dataSet);
dataSet.setCenterText1Color(mTextColorPrimary);
dataSet.setCenterText1FontSize(mTextSizePrimary);
dataSet.setCenterText2Color(mTextColorSecondary);
dataSet.setCenterText2FontSize(mTextSizeSecondary);
dataSet.setHasCenterCircle(true);
dataSet.setHasLabels(true);
dataSet.setHasLabelsOnlyForSelected(false);
}
示例10: setupChart
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private static void setupChart(Context context,
PieChartContentBinding pieChartBinding,
List<PieChartSlice> pieChartSlices) {
PieChartData data = new PieChartData();
data.setHasLabels(true);
//data.setHasLabelsOutside(true);
Collections.sort(pieChartSlices, PIE_CHART_SLICE_COMPARATOR);
while (pieChartSlices.size() > MAX_VALUES) {
pieChartSlices.remove(pieChartSlices.size() - 1);
}
List<SliceValue> sliceValues = new ArrayList<>();
pieChartBinding.legend.removeAllViews();
for (PieChartSlice pieChartSlice : pieChartSlices) {
sliceValues.add(pieChartSlice.sliceValue);
ChartUtils.addLegendEntry(context,
pieChartBinding.legend,
pieChartSlice.legendLabel,
pieChartSlice.sliceValue.getColor());
}
data.setValues(sliceValues);
PieChartView pieChartView = pieChartBinding.memberSpeakingTimeChart;
pieChartView.setPieChartData(data);
pieChartView.setInteractive(false);
pieChartView.setZoomEnabled(true);
pieChartView.setZoomType(ZoomType.HORIZONTAL_AND_VERTICAL);
// https://github.com/lecho/hellocharts-android/issues/268
//pieChartView.setCircleFillRatio(0.4f);
}
示例11: refreshData
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
public void refreshData() {
if(dao == null)
dao = new ExpenseManagerDAO(getActivity());
//Refresh list from DB
try {
creditCard = dao.getCreditCardWithCreditPeriod(activeCreditCardId, 0);
creditPeriod = creditCard.getCreditPeriods().get(0);
}catch(CreditCardNotFoundException | CreditPeriodNotFoundException e) {
Toast.makeText(getActivity(), getResources().getString(R.string.err_problem_loading_card_or_no_card_exists), Toast.LENGTH_SHORT).show();
}
//Check if there are no expenses in this period or there is no active credit card
if(creditCard == null || creditPeriod.getExpensesTotal().equals(BigDecimal.ZERO)) {
chart.setVisibility(View.GONE);
mNoExpensesContainer.setVisibility(View.VISIBLE);
return;
}
int numCategories = ExpenseCategory.values().length;
List<BigDecimal> expenseByCategory = creditPeriod.getExpensesByCategory();
List<SliceValue> sliceValues = new ArrayList<>();
for (int i = 0; i < numCategories; ++i) {
//SliceValue sliceValue = new SliceValue(expenseByCategory[i].floatValue(), ContextCompat.getColor(getContext(), ExpenseCategory.values()[i].getColor() ));
SliceValue sliceValue = new SliceValue(20, ContextCompat.getColor(getContext(), ExpenseCategory.values()[i].getColor() ));
sliceValue.setTarget(expenseByCategory.get(i).floatValue());
sliceValue.setLabel(getExpenseLabel(expenseByCategory.get(i), ExpenseCategory.values()[i].getFriendlyName()));
sliceValues.add(sliceValue);
}
//Setup chart
data = new PieChartData(sliceValues);
data.setHasLabels(true);
//data.setHasLabelsOutside(true);
chart.setPieChartData(data);
chart.startDataAnimation(10000);
}
示例12: updateLastPieChart
import lecho.lib.hellocharts.model.PieChartData; //导入方法依赖的package包/类
private void updateLastPieChart() {
List<SliceValue> arcValuesLast = new ArrayList<SliceValue>();
if (lastScaleMeasurement.getFat() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_ORANGE));
}
else {
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getFat(), ChartUtils.COLOR_ORANGE));
}
if (lastScaleMeasurement.getWater() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_BLUE));
}
else {
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getWater(), ChartUtils.COLOR_BLUE));
}
if (lastScaleMeasurement.getMuscle() == 0) {
arcValuesLast.add(new SliceValue(1, ChartUtils.COLOR_GREEN));
}
else {
arcValuesLast.add(new SliceValue(lastScaleMeasurement.getMuscle(), ChartUtils.COLOR_GREEN));
}
final Converters.WeightUnit unit = currentScaleUser.getScaleUnit();
PieChartData pieChartData = new PieChartData(arcValuesLast);
pieChartData.setHasLabels(false);
pieChartData.setHasCenterCircle(true);
pieChartData.setCenterText1(String.format("%.2f %s", lastScaleMeasurement.getConvertedWeight(unit), unit.toString()));
pieChartData.setCenterText2(DateFormat.getDateInstance(DateFormat.MEDIUM).format(lastScaleMeasurement.getDateTime()));
pieChartData.setCenterText1Color(txtTitleLastMeasurement.getCurrentTextColor());
pieChartData.setCenterText2Color(txtTitleLastMeasurement.getCurrentTextColor());
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
pieChartData.setCenterText1FontSize(20);
pieChartData.setCenterText2FontSize(14);
} else {
pieChartData.setCenterText1FontSize(15);
pieChartData.setCenterText2FontSize(12);
pieChartData.setValueLabelTextSize(12);
}
pieChartLast.setPieChartData(pieChartData);
}