本文整理汇总了Java中com.github.mikephil.charting.data.PieDataSet.setValueTextSize方法的典型用法代码示例。如果您正苦于以下问题:Java PieDataSet.setValueTextSize方法的具体用法?Java PieDataSet.setValueTextSize怎么用?Java PieDataSet.setValueTextSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.PieDataSet
的用法示例。
在下文中一共展示了PieDataSet.setValueTextSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePieData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* generates less data (1 DataSet, 4 values)
* @return
*/
protected PieData generatePieData() {
int count = 4;
ArrayList<PieEntry> entries1 = new ArrayList<PieEntry>();
for(int i = 0; i < count; i++) {
entries1.add(new PieEntry((float) ((Math.random() * 60) + 40), "Quarter " + (i+1)));
}
PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015");
ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
ds1.setSliceSpace(2f);
ds1.setValueTextColor(Color.WHITE);
ds1.setValueTextSize(12f);
PieData d = new PieData(ds1);
d.setValueTypeface(tf);
return d;
}
示例2: populatePieData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* Set the pie chart data source
*/
public static PieData populatePieData(List<PieEntry> entries, String label){
PieDataSet dataSet = new PieDataSet(entries, label);
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
//dataSet.setColors(populateColors());// add a lot of colors
dataSet.setColors(ColorTemplate.MATERIAL_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.setValueTextSize(11f);
return new PieData(dataSet);
}
示例3: createPieChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void createPieChart(ArrayList<PieEntry> yEntrys, ArrayList<Integer> colors) {
//create the data set
PieDataSet pieDataSet = new PieDataSet(yEntrys, "");
pieDataSet.setSliceSpace(2);
pieDataSet.setValueTextSize(12);
pieDataSet.setColors(colors);
pieChart.setCenterText(start.toString() + "\n" + end.toString());
pieChart.setCenterTextColor(Color.BLACK);
pieChart.setCenterTextSize(20);
pieChart.animateY(2000);
pieChart.animateX(2000);
pieChart.getLegend().setEnabled(true);
Description description = new Description();
description.setText("");
pieChart.setDescription(description);
//create pie data object
PieData pieData = new PieData();
pieData.addDataSet(pieDataSet);
pieChart.setData(pieData);
pieChart.invalidate();
}
示例4: defaultLanguageChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public static PieChart defaultLanguageChart(List<Language> languages, PieChart chart, Linguist linguist) {
chart.setCenterText(chart.getContext().getString(R.string.title_languages));
List<PieEntry> dataSet = new ArrayList<>(languages.size());
List<Integer> colors = new ArrayList<>(languages.size());
for (Language language : languages) {
dataSet.add(new PieEntry(language.getPercent(), language.getName()));
int color = linguist.decode(language.getName());
colors.add(color);
}
PieDataSet pieDataSet = new PieDataSet(dataSet, chart.getContext().getString(R.string.title_languages));
pieDataSet.setValueTextColor(Color.WHITE);
pieDataSet.setSliceSpace(3f);
pieDataSet.setSelectionShift(5f);
pieDataSet.setColors(colors);
pieDataSet.setValueTextSize(14f);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
chart.setData(pieData);
return chart;
}
示例5: defaultOSChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public static PieChart defaultOSChart(List<OperatingSystem> operatingSystems, PieChart chart, Linguist linguist) {
chart.setCenterText(chart.getContext().getString(R.string.title_os));
List<PieEntry> entries = new ArrayList<>(operatingSystems.size());
List<Integer> colors = new ArrayList<>(operatingSystems.size());
for (OperatingSystem operatingSystem : operatingSystems) {
entries.add(new PieEntry(operatingSystem.getPercent(), operatingSystem.getName()));
colors.add(linguist.decodeOS(operatingSystem.getName()));
}
PieDataSet pieDataSet = new PieDataSet(entries, chart.getContext().getString(R.string.title_os));
pieDataSet.setColors(colors);
pieDataSet.setSliceSpace(3f);
pieDataSet.setSelectionShift(5f);
pieDataSet.setValueTextSize(14f);
pieDataSet.setValueTextColor(Color.WHITE);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
chart.setData(pieData);
return chart;
}
示例6: defaultEditorsChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
public static PieChart defaultEditorsChart(List<Editor> editors, PieChart chart) {
chart.setCenterText(chart.getContext().getString(R.string.title_editors));
int size = 0;
if (editors != null) {
size = editors.size();
}
List<PieEntry> dataSet = new ArrayList<>(size);
//noinspection Convert2streamapi
for (Editor editor : editors) {
dataSet.add(new PieEntry(editor.getPercent(), editor.getName()));
}
PieDataSet pieDataSet = new PieDataSet(dataSet, chart.getContext().getString(R.string.title_editors));
pieDataSet.setColors(ColorTemplate.JOYFUL_COLORS);
pieDataSet.setValueTextColor(Color.WHITE);
pieDataSet.setValueTextSize(14f);
pieDataSet.setSliceSpace(3f);
pieDataSet.setSelectionShift(5f);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
chart.setData(pieData);
return chart;
}
示例7: addData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void addData() {
ArrayList<PieEntry> yEntrys = new ArrayList<>();
ArrayList<String> xEntrys = new ArrayList<>();
for(int i = 0; i < yData.length; i++){
yEntrys.add(new PieEntry(yData[i] , i));
xEntrys.add(xData[i]);
}
PieDataSet pieDataSet = new PieDataSet(yEntrys, "Category History");
pieDataSet.setSliceSpace(2);
pieDataSet.setValueTextSize(12);
pieDataSet.setValueTextColor(Color.WHITE);
ArrayList<Integer> colors = new ArrayList<>();
colors.add(Color.RED);
colors.add(Color.BLUE);
pieDataSet.setColors(colors);
Legend legend = pieChart.getLegend();
List<LegendEntry> legends = new ArrayList<>();
LegendEntry red = new LegendEntry();
red.label = "Missed";
red.formColor = Color.RED;
legends.add(red);
LegendEntry blue = new LegendEntry();
blue.label = "Completed";
blue.formColor = Color.BLUE;
legends.add(blue);
pieChart.getLegend().setCustom(legends);
legend.setForm(Legend.LegendForm.CIRCLE);
PieData pieData = new PieData(pieDataSet);
pieChart.setData(pieData);
pieChart.invalidate();
pieChart.getDescription().setEnabled(false);
}
示例8: applyDataSetSettings
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* Applies the specified format to the PieDataSet Object.
*
* @param dataset the dataset which will be formatted
* @param type the statistic type of the chart the format is applied to
*/
public void applyDataSetSettings(PieDataSet dataset, StatisticType type) {
dataset.setSliceSpace(SLICE_SPACE);
dataset.setValueTextSize(VALUE_TEXT_SIZE);
dataset.setSelectionShift(SELECTION_SHIFT);
if (type == StatisticType.TYPE_STAGE) {
dataset.setColors(mColorsetStage);
} else if (type == StatisticType.TYPE_DUE) {
dataset.setColors(mColorsetDue);
} else {
dataset.setColors(mColorsetPlayed);
}
dataset.setValueFormatter(new CustomizedFormatter());
}
示例9: generatePieData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* generates less data (1 DataSet, 4 values)
* @return
*/
protected PieData generatePieData() {
int count = 4;
ArrayList<Entry> entries1 = new ArrayList<Entry>();
ArrayList<String> xVals = new ArrayList<String>();
xVals.add("Quarter 1");
xVals.add("Quarter 2");
xVals.add("Quarter 3");
xVals.add("Quarter 4");
for(int i = 0; i < count; i++) {
xVals.add("entry" + (i+1));
entries1.add(new Entry((float) (Math.random() * 60) + 40, i));
}
PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2015");
ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
ds1.setSliceSpace(2f);
ds1.setValueTextColor(Color.WHITE);
ds1.setValueTextSize(12f);
PieData d = new PieData(xVals, ds1);
d.setValueTypeface(tf);
return d;
}
示例10: addDataSet
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void addDataSet() {
Log.d(TAG, "addDataSet started");
ArrayList<PieEntry> yEntrys = new ArrayList<>();
ArrayList<String> xEntrys = new ArrayList<>();
for(int i = 0; i < yData.length; i++){
yEntrys.add(new PieEntry(yData[i] , i));
}
for(int i = 1; i < xData.length; i++){
xEntrys.add(xData[i]);
}
//create the data set
PieDataSet pieDataSet = new PieDataSet(yEntrys, "Төлөвлөгөөний үзүүлэлтлл");
pieDataSet.setSliceSpace(2);
pieDataSet.setValueTextSize(12);
//add colors to dataset
ArrayList<Integer> colors = new ArrayList<>();
colors.add(Color.GRAY);
colors.add(Color.BLUE);
colors.add(Color.RED);
colors.add(Color.GREEN);
colors.add(Color.CYAN);
colors.add(Color.YELLOW);
colors.add(Color.MAGENTA);
pieDataSet.setColors(colors);
//add legend to chart
Legend legend = pieChart.getLegend();
legend.setForm(Legend.LegendForm.CIRCLE);
legend.setPosition(Legend.LegendPosition.LEFT_OF_CHART);
//create pie data object
PieData pieData = new PieData(pieDataSet);
pieChart.setData(pieData);
pieChart.invalidate();
}
示例11: setChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void setChartData(List<Project> chardData) {
Typeface lato = Typeface.createFromAsset(this.getContext().getAssets(), "fonts/Lato-Regular.ttf");
this.mChartProjects.setDrawHoleEnabled(true);
this.mChartProjects.setHoleColor(Color.WHITE);
this.mChartProjects.setTransparentCircleColor(Color.WHITE);
this.mChartProjects.setTransparentCircleAlpha(110);
this.mChartProjects.setDragDecelerationFrictionCoef(0.95f);
this.mChartProjects.setHoleRadius(58f);
this.mChartProjects.setTransparentCircleRadius(61f);
this.mChartProjects.setDescription("");
this.mChartProjects.setUsePercentValues(true);
this.mChartProjects.setEntryLabelColor(Color.WHITE);
this.mChartProjects.setDrawCenterText(true);
this.mChartProjects.setCenterText(getString(R.string.title_projects));
this.mChartProjects.setCenterTextSize(18f);
this.mChartProjects.setEntryLabelTypeface(lato);
this.mChartProjects.setCenterTextTypeface(lato);
this.mChartProjects.setCenterTextColor(getColor(getActivity(), R.color.colorSecondaryText));
this.mChartProjects.animateY(1400, Easing.EasingOption.EaseInOutQuad);
enableNestingScrollForAP21();
List<PieEntry> entries = new ArrayList<>(chardData.size());
for (Project project : chardData) {
entries.add(new PieEntry(project.getPercent(), project.getName()));
}
PieDataSet pieDataSet = new PieDataSet(entries, getString(R.string.title_projects));
pieDataSet.setHighlightEnabled(true);
pieDataSet.setValueTextColor(Color.WHITE);
pieDataSet.setValueTextSize(14f);
pieDataSet.setColors(ColorTemplate.VORDIPLOM_COLORS);
pieDataSet.setSliceSpace(3f);
pieDataSet.setSelectionShift(5f);
PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
this.mChartProjects.setData(pieData);
}
示例12: prepareGraphLayout
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
private void prepareGraphLayout() {
loadingLayout.setVisibility(View.GONE);
errorLayout.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
swipeRefreshLayout.setRefreshing(false);
if (results.getCounted() > 0f) {
pieChart.setVisibility(View.VISIBLE);
emptyChart.setVisibility(View.GONE);
ArrayList<PieEntry> entries = new ArrayList<>();
entries.add(new PieEntry(results.getInvalid(), StringsManager.getString("graph_invalid")));
entries.add(new PieEntry(results.getBlank(), StringsManager.getString("graph_blank")));
entries.add(new PieEntry(results.getNo(), StringsManager.getString("graph_no")));
entries.add(new PieEntry(results.getYes(), StringsManager.getString("graph_yes")));
PieDataSet set = new PieDataSet(entries, "");
set.setColors(Color.parseColor("#43474e"), Color.parseColor("#7f7f7f"), Color.parseColor("#fc543d"), Color.parseColor("#65c258"));
// set.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
// set.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
// set.setSliceSpace(2f);
set.setValueTextSize(16f);
set.setValueTextColor(Color.WHITE);
PieData data = new PieData(set);
data.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
// write your logic here
return new DecimalFormat("##0.0").format(value) + "%"; // e.g. append a dollar-sign
}
});
pieChart.setData(data);
pieChart.getLegend().setEnabled(false);
pieChart.setUsePercentValues(true);
pieChart.setEntryLabelColor(Color.WHITE);
pieChart.setEntryLabelTextSize(16f);
pieChart.setRotationEnabled(false);
Description description = new Description();
description.setText("");
pieChart.setDescription(description);
pieChart.invalidate();
} else {
pieChart.setVisibility(View.GONE);
emptyChart.setVisibility(View.VISIBLE);
}
counted.setText(new DecimalFormat("##0.0").format(results.getCounted()) + "%");
countedBar.setProgress((int) (results.getCounted() * 10));
participation.setText(new DecimalFormat("##0.0").format(results.getParticipation()) + "%");
participationBar.setProgress((int) (results.getParticipation() * 10));
countedBar.getProgressDrawable().setColorFilter(
ResourcesCompat.getColor(getResources(), R.color.grey_dark, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);
participationBar.getProgressDrawable().setColorFilter(
ResourcesCompat.getColor(getResources(), R.color.red, getContext().getTheme()), android.graphics.PorterDuff.Mode.SRC_IN);
if (TextUtils.isEmpty(results.getMessage())) {
message.setVisibility(View.GONE);
} else {
message.setVisibility(View.VISIBLE);
message.setText(results.getMessage());
}
}
示例13: showFeedback
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
public void showFeedback(Feedback feedbackToShow) {
final List<PieEntry> entries = new ArrayList<>();
final List<Integer> colors = new ArrayList<>();
if (feedbackToShow.getStar4() > 0) {
entries.add(new PieEntry(feedbackToShow.getStar4(), "Super happy"));
colors.add(ContextCompat.getColor(this, R.color.super_happy));
}
if (feedbackToShow.getStar3() > 0) {
entries.add(new PieEntry(feedbackToShow.getStar3(), "Happy"));
colors.add(ContextCompat.getColor(this, R.color.happy));
}
if (feedbackToShow.getStar2() > 0) {
entries.add(new PieEntry(feedbackToShow.getStar2(), "Meh"));
colors.add(ContextCompat.getColor(this, R.color.meh));
}
if (feedbackToShow.getStar1() > 0) {
entries.add(new PieEntry(feedbackToShow.getStar1(), "Sad"));
colors.add(ContextCompat.getColor(this, R.color.sad));
}
final PieDataSet pieDataSet = new PieDataSet(entries, null);
pieDataSet.setValueTextSize(20f);
pieDataSet.setColors(colors);
final PieData pieData = new PieData(pieDataSet);
pieData.setValueFormatter(new PercentFormatter());
pieData.setValueTextSize(16f);
pieChart.setData(pieData);
final Description description = new Description();
description.setTextSize(16f);
description.setText("Total votes: " + feedbackToShow.getTotal());
pieChart.setDescription(description);
pieChart.setCenterText(feedbackToShow.getQuestion().getText());
pieChart.setCenterTextSize(20f);
pieChart.setCenterTextRadiusPercent(90f);
pieChart.setUsePercentValues(true);
pieChart.setEntryLabelTextSize(16f);
//Init entries:
final Legend l = pieChart.getLegend();
l.setEntries(Collections.emptyList());
pieChart.invalidate();
}