本文整理汇总了Java中lecho.lib.hellocharts.model.SliceValue.setTarget方法的典型用法代码示例。如果您正苦于以下问题:Java SliceValue.setTarget方法的具体用法?Java SliceValue.setTarget怎么用?Java SliceValue.setTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lecho.lib.hellocharts.model.SliceValue
的用法示例。
在下文中一共展示了SliceValue.setTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareDataAnimation
import lecho.lib.hellocharts.model.SliceValue; //导入方法依赖的package包/类
/**
* To animate values you have to change targets values and then call {@link Chart#startDataAnimation()}
* method(don't confuse with View.animate()).
*/
private void prepareDataAnimation() {
for (SliceValue value : data.getValues()) {
value.setTarget((float) Math.random() * 30 + 15);
}
}
示例2: refreshData
import lecho.lib.hellocharts.model.SliceValue; //导入方法依赖的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);
}