本文整理汇总了Java中com.github.mikephil.charting.data.PieData.setValueTextColor方法的典型用法代码示例。如果您正苦于以下问题:Java PieData.setValueTextColor方法的具体用法?Java PieData.setValueTextColor怎么用?Java PieData.setValueTextColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.PieData
的用法示例。
在下文中一共展示了PieData.setValueTextColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "label");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setLabel("Example market share");
set.setSliceSpace(2);
// create a data object with the dataset list
PieData data = new PieData(set);
styleData(data);
data.setValueTextColor(Color.WHITE);
data.setValueTextSize(12f);
// set data
mChart.setData(data);
mChart.animateY(1400);
}
示例2: setData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<PieEntry> values = new ArrayList<PieEntry>();
for (int i = 0; i < count; i++) {
values.add(new PieEntry((float) ((Math.random() * range) + range / 5), mParties[i % mParties.length]));
}
PieDataSet dataSet = new PieDataSet(values, "Election Results");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(ColorTemplate.MATERIAL_COLORS);
//dataSet.setSelectionShift(0f);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
mChart.setData(data);
mChart.invalidate();
}
示例3: generatePieData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private PieData generatePieData(List<PieChartItem> pieChartItems) {
ArrayList<PieEntry> entries = new ArrayList<>();
for (PieChartItem item : pieChartItems) {
entries.add(new PieEntry(item.getTime(), item.getName(), item.getPercent()));
}
PieDataSet pieDataSet = new PieDataSet(entries, "");
pieDataSet.setAutomaticallyDisableSliceSpacing(true);
pieDataSet.setColors(chartColors);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new CustomPercentFormatter());
pieData.setValueTextColor(Color.WHITE);
return pieData;
}
示例4: setPieChartData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setPieChartData(int count, float range) {
ArrayList<PieEntry> entries = ChartData.getPieData(count, range);
PieDataSet dataSet = new PieDataSet(entries, "Weekly spend distribution");
dataSet.setDrawIcons(false);
dataSet.setSliceSpace(3f);
dataSet.setIconsOffset(new MPPointF(0, 40));
dataSet.setSelectionShift(5f);
ArrayList<Integer> colors = new ArrayList<>();
for (int c : ColorTemplate.LIBERTY_COLORS)
colors.add(c);
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.GRAY);
pieChart.setData(data);
pieChart.highlightValues(null);
pieChart.invalidate();
}
示例5: setData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setData(long tips, long transactionsToRequest) {
ArrayList<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(tips, getString(R.string.tips) + " " + "(" + tips + ")"));
entries.add(new PieEntry(transactionsToRequest, getString(R.string.transactions_to_request) + " " + "(" + transactionsToRequest + ")"));
PieDataSet dataSet = new PieDataSet(entries, getString(R.string.transactions) + "\n(" + (tips + transactionsToRequest) + ")");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<>();
for (int c : ColorTemplate.LIBERTY_COLORS)
colors.add(c);
dataSet.setColors(colors);
dataSet.setValueLinePart1OffsetPercentage(80.f);
dataSet.setValueLinePart1Length(0.2f);
dataSet.setValueLinePart2Length(0.4f);
dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setValueTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(12f);
data.setValueTextColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary));
chart.setData(data);
// undo all highlights
chart.highlightValues(null);
chart.invalidate();
}
示例6: getData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
@NonNull
private PieData getData(Leader leader) {
RealmList<Language> languages = leader.getRunningTotal().getLanguages();
List<PieEntry> entries = new ArrayList<>(languages.size());
List<Integer> colors = new ArrayList<>(languages.size());
for (Language language : languages) {
entries.add(new PieEntry(language.getTotalSeconds(), language.getName()));
colors.add(linguist.decode(language.getName()));
}
PieDataSet pieDataSet = new PieDataSet(entries, getString(R.string.languages));
pieDataSet.setColors(colors);
pieDataSet.setSliceSpace(3f);
pieDataSet.setSelectionShift(5f);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> String.valueOf(toMinutes((long) value)));
pieData.setValueTextSize(16f);
pieData.setValueTextColor(Color.WHITE);
return pieData;
}
示例7: updateChart
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void updateChart(String totalSpace, List<PieEntry> entries) {
boolean isDarkTheme = appTheme.getMaterialDialogTheme() == Theme.DARK;
PieDataSet set = new PieDataSet(entries, null);
set.setColors(COLORS);
set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
set.setSliceSpace(5f);
set.setAutomaticallyDisableSliceSpacing(true);
set.setValueLinePart2Length(1.05f);
set.setSelectionShift(0f);
PieData pieData = new PieData(set);
pieData.setValueFormatter(new GeneralDialogCreation.SizeFormatter(context));
pieData.setValueTextColor(isDarkTheme? Color.WHITE:Color.BLACK);
chart.setCenterText(new SpannableString(context.getString(R.string.total) + "\n" + totalSpace));
chart.setData(pieData);
}
示例8: addPieChartData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void addPieChartData(int correctAnswer, int noOfQuestion) {
float[] yData;
String[] xData = {getString(R.string.correct_quantity), getString(R.string.incorrect_quantity)};
ArrayList<Integer> colors = new ArrayList<>();
colors.add(ContextCompat.getColor(getContext(), R.color.colorDarkBlue));
colors.add(ContextCompat.getColor(getContext(), R.color.colorRaspberry));
if (correctAnswer == noOfQuestion) {
yData = new float[]{100};
} else if (correctAnswer == 0) {
yData = new float[]{100};
colors.remove(0);
} else {
float good = (float) correctAnswer * 100 / noOfQuestion;
yData = new float[]{good, 100 - good};
}
ArrayList<Entry> yValues = new ArrayList<>();
for (int i = 0; i < yData.length; i++)
yValues.add(new Entry(yData[i], i));
ArrayList<String> xValues = new ArrayList<>();
Collections.addAll(xValues, xData);
PieDataSet dataSet = new PieDataSet(yValues, getString(R.string.your_score));
dataSet.setColors(colors);
dataSet.setSliceSpace(5);
dataSet.setSelectionShift(10);
PieData data = new PieData(xValues, dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextColor(ContextCompat.getColor(getContext(), R.color.colorGrey));
data.setValueTextSize(20);
pieChart.setData(data);
pieChart.highlightValues(null);
pieChart.invalidate();
}
示例9: setChartData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setChartData(PieChart chart, List<Integer> yData) {
ArrayList<Entry> yVals = new ArrayList<>();
for (int i = 0; i < yData.size(); ++i) {
yVals.add(new Entry(yData.get(i), i));
}
ArrayList<String> xVals = new ArrayList<>();
for (int i = 0; i < xData.length; ++i) {
xVals.add(xData[i]);
}
PieDataSet dataSet = new PieDataSet(yVals, "");
dataSet.setSliceSpace(3);
dataSet.setSelectionShift(5);
ArrayList<Integer> colors = new ArrayList<>();
colors.add(0xFFDD2C00);
colors.add(0xFFFF6D00);
colors.add(0xFFFFAB00);
colors.add(0xFFAEEA00);
colors.add(0xFF64DD17);
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(15f);
data.setValueTextColor(Color.BLACK);
chart.setData(data);
chart.highlightValues(null);
chart.invalidate();
}
示例10: setData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setData(PieChart colorPie, float value) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
float result = value / 5f;
Log.d(TAG + " result ", result + "");
entries.add(new PieEntry(result, 0));
entries.add(new PieEntry(1 - result, 1));
// NOTE: The order of the entries when being added to the entries array determines their position around the center of
// the chart.
// colorPie.setCenterTextTypeface(mTfLight);
int centerTextColor = android.graphics.Color.argb(255, 57, 197, 193);
colorPie.setCenterTextColor(centerTextColor);
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(3f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
colors.add(Color.argb(120, 57, 197, 193));
colorPie.setCenterText(value + "");
colorPie.setCenterTextSize(30);
colors.add(Color.argb(100, 214, 214, 214));
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(0f);
data.setValueTextColor(Color.WHITE);
colorPie.setData(data);
// undo all highlights
colorPie.highlightValues(null);
colorPie.invalidate();
}
示例11: createPieData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
public PieData createPieData(PieDataSet pieDataSet) {
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
pieData.setValueTextSize(15f);
pieData.setValueTextColor(utilsUI.getColor(android.R.color.white));
return pieData;
}
示例12: updateChartData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void updateChartData(PieChart chart) {
ArrayList<PieEntry> entries = new ArrayList<>();
ArrayList<Integer> colors = new ArrayList<>();
double sum = 0;
for (int i = 0; i < categorizedExpenses.getCategories().size(); i++) {
Category c = categorizedExpenses.getCategory(i);
Report r = categorizedExpenses.getReport(c);
sum += r.getTotalAmount().doubleValue();
entries.add(new PieEntry((int) (r.getTotalAmount().doubleValue() * 1000), c.getTitle()));
colors.add(c.getColor());
}
PieDataSet dataSet = new PieDataSet(entries, "Outlay");
dataSet.setSliceSpace(2f);
dataSet.setSelectionShift(10f);
dataSet.setColors(colors);
PieData data = new PieData(dataSet);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> NumberUtils.formatAmount((double) value / 1000));
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
chart.setData(data);
chart.setCenterText(NumberUtils.formatAmount(sum));
chart.highlightValues(null);
chart.invalidate();
}
示例13: setupSleepStagesChart
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setupSleepStagesChart(int sleep, int awake) {
PieChart pieChart = (PieChart) findViewById(R.id.sleepstages);
ArrayList<Entry> pieComp1 = new ArrayList<Entry>();
Entry c1e1 = new Entry(sleep, 0);
pieComp1.add(c1e1);
Entry c1e2 = new Entry(awake, 1);
pieComp1.add(c1e2);
PieDataSet pieDataSet = new PieDataSet(pieComp1, "Sleep stages");
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
ArrayList<String> xPieVals = new ArrayList<String>();
xPieVals.add("Deep");
xPieVals.add("Light");
PieData pieData = new PieData(xPieVals,pieDataSet);
pieData.setValueTextSize(14);
pieData.setValueTextColor(Color.WHITE);
pieChart.setData(pieData);
Legend pieLegend = pieChart.getLegend();
pieLegend.setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setDescription("Sleep stages");
pieChart.setHardwareAccelerationEnabled(true);
pieChart.setBackgroundColor(Color.parseColor("#52B19D"));
pieChart.setHoleColor(Color.parseColor("#52B09C"));
pieChart.invalidate();
}
示例14: setupLightChart
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setupLightChart(int night, int dawn, int day) {
PieChart pieChart = (PieChart) findViewById(R.id.lightquality);
ArrayList<Entry> pieComp1 = new ArrayList<Entry>();
Entry c1e1 = new Entry(night, 0);
pieComp1.add(c1e1);
Entry c1e2 = new Entry(dawn, 1);
pieComp1.add(c1e2);
Entry c1e3 = new Entry(day, 2);
pieComp1.add(c1e3);
PieDataSet pieDataSet = new PieDataSet(pieComp1, "Light quality");
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
ArrayList<String> xPieVals = new ArrayList<String>();
xPieVals.add("Night");
xPieVals.add("Dawn");
xPieVals.add("Day");
PieData pieData = new PieData(xPieVals,pieDataSet);
pieData.setValueTextSize(14);
pieData.setValueTextColor(Color.WHITE);
pieChart.setData(pieData);
Legend pieLegend = pieChart.getLegend();
pieLegend.setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setDescription("Light quality");
pieChart.setHardwareAccelerationEnabled(true);
pieChart.setHoleColor(Color.parseColor("#52B09C"));
pieChart.invalidate();
}
示例15: setRNEData
import com.github.mikephil.charting.data.PieData; //导入方法依赖的package包/类
private void setRNEData(List<Double> classRangeValue) {
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
// IMPORTANT: In a PieChart, no values (Entry) should have the same
// xIndex (even if from different DataSets), since no values can be
// drawn above each other.
catNE= getResources().getStringArray(R.array.catNE_list_array);
ArrayList<String> xVals = new ArrayList<String>();
double maxValue = 0;
int maxClassId = 0;
for (int idEntry = 0; idEntry < classRangeValue.size(); idEntry++) {
float value = classRangeValue.get(classRangeValue.size() - 1 - idEntry).floatValue();
// Fix background color issue if the pie is too thin
if(value < 0.01) {
value = 0;
}
yVals1.add(new Entry(value, idEntry));
xVals.add(catNE[idEntry]);
if (value > maxValue) {
maxClassId = idEntry;
maxValue = value;
}
}
PieDataSet dataSet = new PieDataSet(yVals1,Results.this.getString(R.string.caption_SL));
dataSet.setSliceSpace(3f);
dataSet.setColors(NE_COLORS);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new CustomPercentFormatter());
data.setValueTextSize(8f);
data.setValueTextColor(Color.BLACK);
rneChart.setData(data);
// highlight the maximum value of the RNE
// Find the maximum of the array, in order to be highlighted
Highlight h = new Highlight(maxClassId, 0);
rneChart.highlightValues(new Highlight[] { h });
rneChart.invalidate();
}