本文整理汇总了Java中com.github.mikephil.charting.data.PieDataSet.setSelectionShift方法的典型用法代码示例。如果您正苦于以下问题:Java PieDataSet.setSelectionShift方法的具体用法?Java PieDataSet.setSelectionShift怎么用?Java PieDataSet.setSelectionShift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.PieDataSet
的用法示例。
在下文中一共展示了PieDataSet.setSelectionShift方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例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: 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();
}
示例4: setData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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();
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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());
}
示例12: addPieChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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();
}
示例13: dataSetConfig
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的package包/类
@Override
void dataSetConfig(IDataSet<Entry> dataSet, ReadableMap config) {
PieDataSet pieDataSet = (PieDataSet) dataSet;
ChartDataSetConfigUtils.commonConfig(pieDataSet, config);
// PieDataSet only config
if (BridgeUtils.validate(config, ReadableType.Number, "sliceSpace")) {
pieDataSet.setSliceSpace((float) config.getDouble("sliceSpace"));
}
if (BridgeUtils.validate(config, ReadableType.Number, "selectionShift")) {
pieDataSet.setSelectionShift((float) config.getDouble("selectionShift"));
}
}
示例14: setChartData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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();
}
示例15: setData
import com.github.mikephil.charting.data.PieDataSet; //导入方法依赖的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();
}