本文整理汇总了Java中com.github.mikephil.charting.data.PieDataSet.setDrawValues方法的典型用法代码示例。如果您正苦于以下问题:Java PieDataSet.setDrawValues方法的具体用法?Java PieDataSet.setDrawValues怎么用?Java PieDataSet.setDrawValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.PieDataSet
的用法示例。
在下文中一共展示了PieDataSet.setDrawValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPieDataSet
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public PieDataSet createPieDataSet(List<PieEntry> pieEntryList,
@Nullable String label,
@Nullable List<Integer> colors) {
PieDataSet pieDataSet = new PieDataSet(pieEntryList, label);
pieDataSet.setSliceSpace(1.5f);
pieDataSet.setSelectionShift(2f);
pieDataSet.setDrawValues(true);
if (colors == null) {
colors = new ArrayList<>(3);
colors.add(utilsUI.getColor(R.color.colorPrimaryDark));
colors.add(utilsUI.getColor(R.color.colorPrimary));
colors.add(utilsUI.getColor(R.color.colorAccent));
}
pieDataSet.setColors(colors);
return pieDataSet;
}
示例2: createPieChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public PieData createPieChartData()
{
List<Entry> entries = new ArrayList<>();
entries.add(new Entry(50, 0));
entries.add(new Entry(25, 1));
entries.add(new Entry(12.5f, 2));
entries.add(new Entry(12.5f, 3));
PieDataSet data = new PieDataSet(entries, null);
data.setDrawValues(false);
data.setColors(new int[] {
0xFF673ab7, 0xFF2196f3, 0xFF4caf50, 0xFF009688
});
String[] labels = new String[] {"Blackberry", "Blueberry", "Green apple", "Seaweed"};
return new PieData(labels, data);
}
示例3: showPieChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void showPieChart(List<Exam> exams){
barChart.setVisibility(View.GONE);
pieChart.setVisibility(View.VISIBLE);
Map<String, Integer> gradeCount = calculateGradeDistribution(exams);
List<PieEntry> entries = new ArrayList<>();
for (String GRADE : GRADES) {
entries.add(new PieEntry(gradeCount.get(GRADE), GRADE));
}
PieDataSet set = new PieDataSet(entries, getString(R.string.grades_without_weight));
set.setColors(GRADE_COLORS, this);
set.setDrawValues(false);
pieChart.setData(new PieData(set));
pieChart.setDrawEntryLabels(false);
pieChart.getLegend().setWordWrapEnabled(true);
pieChart.setDescription(null);
pieChart.invalidate();
}
示例4: createProgressChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public List<PieData> createProgressChartData()
{
List<PieData> items = new ArrayList<>();
for(int i = 0, size = 12; i <= size; i++)
{
List<Entry> entries = new ArrayList<>();
entries.add(new Entry(i, 0)); // Complete
entries.add(new Entry(size - i, 1)); // Incomplete
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, - i);
String month = calendar.getDisplayName(Calendar.MONTH,
Calendar.SHORT,
Locale.getDefault());
PieDataSet data = new PieDataSet(entries, month + " '16");
data.setDrawValues(false);
data.setColors(new int[] {
ThemeUtils.getAccentColor(getContext()), 0xFFe5e5e5
});
String[] labels = new String[] {"Incomplete", "Complete"};
items.add(new PieData(labels, data));
}
return items;
}
示例5: init
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public void init(final Poll p) {
question.setText(SparkleHelper.getHtmlFormatting(p.title));
SparkleHelper.setHappeningsFormatting(context, author,
String.format(Locale.US, context.getString(R.string.poll_author), p.author));
open.setText(String.format(Locale.US, context.getString(R.string.poll_open),
SparkleHelper.getReadableDateFromUTC(context, p.startTime)));
close.setText(String.format(Locale.US, context.getString(R.string.poll_close),
SparkleHelper.getReadableDateFromUTC(context, p.stopTime)));
if (p.text != null && p.text.length() > 0) {
SparkleHelper.setStyledTextView(context, content, p.text, fm);
}
else {
content.setVisibility(View.GONE);
}
List<PollOption> results = p.options;
Collections.sort(results);
// Clear then add vote options
options.removeAllViews();
for (int i=0; i<results.size(); i++) {
inflateOption(options, i+1, results.get(i).text, results.get(i).votes, results.get(i).voters, i==p.votedOption);
}
int voteTotal = 0;
for (int i=0; i<results.size(); i++) {
voteTotal += results.get(i).votes;
}
if (voteTotal > 0) {
breakdown.setVisibility(View.VISIBLE);
nullVote.setVisibility(View.GONE);
List<PieEntry> chartEntries = new ArrayList<PieEntry>();
for (int i=0; i<results.size(); i++) {
chartEntries.add(new PieEntry((results.get(i).votes * 100f)/voteTotal, String.format(Locale.US, context.getString(R.string.region_option_index), i+1)));
}
PieDataSet dataSet = new PieDataSet(chartEntries, "");
dataSet.setDrawValues(false);
dataSet.setColors(RaraHelper.chartColours, context);
PieData dataFull = new PieData(dataSet);
breakdown = RaraHelper.getFormattedPieChart(context, breakdown, true);
breakdown.setData(dataFull);
breakdown.invalidate();
} else {
breakdown.setVisibility(View.GONE);
nullVote.setVisibility(View.VISIBLE);
}
if (p.isVotingEnabled) {
divider.setVisibility(View.VISIBLE);
voteButton.setVisibility(View.VISIBLE);
voteButtonContent.setText(context.getString(p.votedOption == Poll.NO_VOTE ? R.string.poll_vote_button_submit : R.string.poll_vote_button_change));
voteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fragment.showPollVoteDialog(p, PollCard.this);
}
});
// Set default visibilities
voteButtonIcon.setVisibility(View.VISIBLE);
voteButtonProgress.setVisibility(View.GONE);
} else {
divider.setVisibility(View.GONE);
voteButton.setVisibility(View.GONE);
voteButton.setOnClickListener(null);
}
}
示例6: initZombieChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void initZombieChart(Context c, Zombie zombieData) {
float popTotal = zombieData.survivors + zombieData.zombies + zombieData.dead;
if (popTotal > 0) {
nullData.setVisibility(View.GONE);
chart.setVisibility(View.VISIBLE);
List<PieEntry> chartEntries = new ArrayList<PieEntry>();
List<Integer> chartColours = new ArrayList<Integer>();
// Set data
if (zombieData.survivors > 0) {
float popSurvivors = (zombieData.survivors * 100f)/popTotal;
chartEntries.add(new PieEntry(popSurvivors, c.getString(R.string.zombie_survivors)));
chartColours.add(ContextCompat.getColor(context, R.color.colorChart3));
}
if (zombieData.zombies > 0) {
float popZombies = (zombieData.zombies * 100f)/popTotal;
chartEntries.add(new PieEntry(popZombies, c.getString(R.string.zombie_infected)));
chartColours.add(ContextCompat.getColor(context, R.color.colorChart1));
}
if (zombieData.dead > 0) {
float popDead = (zombieData.dead * 100f)/popTotal;
chartEntries.add(new PieEntry(popDead, c.getString(R.string.zombie_dead)));
chartColours.add(ContextCompat.getColor(context, R.color.colorChart20));
}
// Set colour and disable chart labels
PieDataSet dataSet = new PieDataSet(chartEntries, "");
dataSet.setDrawValues(false);
dataSet.setColors(chartColours);
PieData dataFull = new PieData(dataSet);
// formatting
chart = RaraHelper.getFormattedPieChart(c, chart, true);
chart.setData(dataFull);
chart.invalidate();
} else {
nullData.setVisibility(View.VISIBLE);
chart.setVisibility(View.GONE);
}
}