本文整理汇总了Java中com.github.mikephil.charting.data.PieDataSet.setSliceSpace方法的典型用法代码示例。如果您正苦于以下问题:Java PieDataSet.setSliceSpace方法的具体用法?Java PieDataSet.setSliceSpace怎么用?Java PieDataSet.setSliceSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.PieDataSet
的用法示例。
在下文中一共展示了PieDataSet.setSliceSpace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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: generateDataPie
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private PieData generateDataPie(int cnt) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
for (int i = 0; i < 4; i++) {
entries.add(new PieEntry((float) ((Math.random() * 70) + 30), "Quarter " + (i+1)));
}
PieDataSet d = new PieDataSet(entries, "");
// space between slices
d.setSliceSpace(2f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
PieData cd = new PieData(d);
return cd;
}
示例4: 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);
}
示例5: 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();
}
示例6: setPieChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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();
}
示例7: generateDataPie
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private PieData generateDataPie(int cnt) {
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int i = 0; i < 4; i++) {
entries.add(new Entry((int) (Math.random() * 70) + 30, i));
}
PieDataSet d = new PieDataSet(entries, "");
// space between slices
d.setSliceSpace(2f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
PieData cd = new PieData(getQuarters(), d);
return cd;
}
示例8: 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;
}
示例9: generateDataPie
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*/
private PieData generateDataPie() {
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int i = 0; i < 4; i++) {
entries.add(new Entry((int) (Math.random() * 70) + 30, i));
}
PieDataSet d = new PieDataSet(entries, "");
// 设置各个扇形部分之间的间距
d.setSliceSpace(12f);
// 设置各个扇形部分的颜色
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
PieData cd = new PieData(getQuarters(), d);
return cd;
}
示例10: 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;
}
示例11: 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;
}
示例12: getData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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;
}
示例13: updateChart
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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);
}
示例14: 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);
}
示例15: 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());
}