本文整理匯總了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方法的29個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: setData
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(int count, float range) {
ArrayList values = new ArrayList();
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();
}
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,
示例2: populatePieData
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
/**
* Set the pie chart data source
*/
public static PieData populatePieData(List 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);
}
開發者ID:graviton57,項目名稱:DOUSalaries,代碼行數:18,
示例3: setPieChartData
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setPieChartData(int count, float range) {
ArrayList 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 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();
}
開發者ID:VidyaSastry,項目名稱:Opal-Chat-AnalyticsDashboard,代碼行數:24,
示例4: setData
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(long tips, long transactionsToRequest) {
ArrayList 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 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();
}
開發者ID:iotaledger,項目名稱:android-wallet-app,代碼行數:39,
示例5: createPieDataSet
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
public PieDataSet createPieDataSet(List pieEntryList,
@Nullable String label,
@Nullable List 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;
}
開發者ID:MLSDev,項目名稱:RecipeFinderJavaVersion,代碼行數:20,
示例6: getData
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
@NonNull
private PieData getData(Leader leader) {
RealmList languages = leader.getRunningTotal().getLanguages();
List entries = new ArrayList<>(languages.size());
List 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;
}
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:21,
示例7: defaultLanguageChart
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
public static PieChart defaultLanguageChart(List languages, PieChart chart, Linguist linguist) {
chart.setCenterText(chart.getContext().getString(R.string.title_languages));
List dataSet = new ArrayList<>(languages.size());
List 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;
}
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:23,
示例8: defaultOSChart
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
public static PieChart defaultOSChart(List operatingSystems, PieChart chart, Linguist linguist) {
chart.setCenterText(chart.getContext().getString(R.string.title_os));
List entries = new ArrayList<>(operatingSystems.size());
List 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;
}
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:21,
示例9: defaultEditorsChart
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
public static PieChart defaultEditorsChart(List editors, PieChart chart) {
chart.setCenterText(chart.getContext().getString(R.string.title_editors));
int size = 0;
if (editors != null) {
size = editors.size();
}
List 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;
}
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:24,
示例10: updateChart
點讚 3
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void updateChart(String totalSpace, List 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);
}
開發者ID:TeamAmaze,項目名稱:AmazeFileManager,代碼行數:20,
示例11: applyDataSetSettings
點讚 2
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());
}
開發者ID:Kamshak,項目名稱:BrainPhaser,代碼行數:21,
示例12: addPieChartData
點讚 2
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 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 yValues = new ArrayList<>();
for (int i = 0; i < yData.length; i++)
yValues.add(new Entry(yData[i], i));
ArrayList 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();
}
開發者ID:blstream,項目名稱:StudyBox_Android,代碼行數:40,
示例13: dataSetConfig
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
@Override
void dataSetConfig(IDataSet 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"));
}
}
開發者ID:mskec,項目名稱:react-native-mp-android-chart,代碼行數:15,
示例14: setChartData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setChartData(PieChart chart, List yData) {
ArrayList yVals = new ArrayList<>();
for (int i = 0; i < yData.size(); ++i) {
yVals.add(new Entry(yData.get(i), i));
}
ArrayList 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 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();
}
開發者ID:kaiomax,項目名稱:RUSpotlight,代碼行數:36,
示例15: setData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(PieChart colorPie, float value) {
ArrayList entries = new ArrayList();
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 colors = new ArrayList();
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();
}
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:39,
示例16: setChartData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setChartData(List 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 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);
}
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:37,
示例17: updateChartData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void updateChartData(PieChart chart) {
ArrayList entries = new ArrayList<>();
ArrayList 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();
}
開發者ID:bmelnychuk,項目名稱:outlay,代碼行數:28,
示例18: setCategoriesPieChart
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setCategoriesPieChart() {
List categoriesNames = new ArrayList<>();
List categoryPercentagesEntries = new ArrayList<>();
for (int i=0; i < mCategoryList.size(); i++) {
float percentage = Expense.getExpensesCategoryPercentage(DateManager.getInstance().getDateFrom(), DateManager.getInstance().getDateTo(), mCategoryList.get(i));
if( percentage > 0) {
categoriesNames.add(mCategoryList.get(i).getName());
Entry pieEntry = new Entry(percentage, categoriesNames.size()-1);
categoryPercentagesEntries.add(pieEntry);
}
}
if (categoriesNames.isEmpty()) {
tvPcCategoriesEmpty.setVisibility(View.VISIBLE);
bcCategories.setVisibility(View.GONE);
} else {
tvPcCategoriesEmpty.setVisibility(View.GONE);
bcCategories.setVisibility(View.VISIBLE);
}
PieDataSet dataSet = new PieDataSet(categoryPercentagesEntries, "Categories");
dataSet.setSliceSpace(1f);
dataSet.setSelectionShift(5f);
dataSet.setColors(Util.getListColors());
PieData data = new PieData(categoriesNames, dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(getResources().getColor(R.color.primary_dark));
pcCategories.setData(data);
pcCategories.invalidate();
}
開發者ID:PedroCarrillo,項目名稱:Expense-Tracker-App,代碼行數:36,
示例19: setData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(PieChart mChart, Station station) {
ArrayList yVals1 = new ArrayList();
float inactive = (float) Integer.parseInt(station.getNumberBases()) - Integer.parseInt(station.getBasesFree()) - Integer.parseInt(station.getBikeEngaged());
yVals1.add(new Entry(Float.parseFloat(station.getBasesFree()), 0));
yVals1.add(new Entry(Float.parseFloat(station.getBikeEngaged()), 1));
yVals1.add(new Entry(inactive, 2));
ArrayList xVals = new ArrayList();
for (int i = 0; i < mParties.length + 1; i++)
xVals.add(mParties[i % mParties.length]);
PieDataSet dataSet = new PieDataSet(yVals1, getString(R.string.base_state));
dataSet.setSliceSpace(2f);
dataSet.setSelectionShift(5f);
ArrayList colors = new ArrayList();
colors.add(ContextCompat.getColor(getActivity(), R.color.red_chart));
colors.add(ContextCompat.getColor(getActivity(), R.color.green_chart));
colors.add(ContextCompat.getColor(getActivity(), R.color.gray_chart));
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return "" + (int) value;
}
});
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
mChart.setData(data);
mChart.highlightValues(null);
mChart.invalidate();
}
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:42,
示例20: setData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(Station station) {
ArrayList yVals1 = new ArrayList();
float inactive = (float) Integer.parseInt(station.getNumberBases()) - Integer.parseInt(station.getBasesFree()) - Integer.parseInt(station.getBikeEngaged());
yVals1.add(new Entry(Float.parseFloat(station.getBasesFree()), 0));
yVals1.add(new Entry(Float.parseFloat(station.getBikeEngaged()), 1));
yVals1.add(new Entry(inactive, 2));
ArrayList xVals = new ArrayList();
mParties = context.getResources().getStringArray(R.array.states_values);
for (int i = 0; i < mParties.length + 1; i++)
xVals.add(mParties[i % mParties.length]);
PieDataSet dataSet = new PieDataSet(yVals1, context.getString(R.string.base_state));
dataSet.setSliceSpace(2f);
dataSet.setSelectionShift(5f);
ArrayList colors = new ArrayList();
colors.add(ContextCompat.getColor(context, R.color.red_chart));
colors.add(ContextCompat.getColor(context, R.color.green_chart));
colors.add(ContextCompat.getColor(context, R.color.gray_chart));
dataSet.setColors(colors);
PieData data = new PieData(xVals, dataSet);
data.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return "" + (int) value;
}
});
data.setValueTextSize(11f);
data.setValueTextColor(Color.BLACK);
mChart.setData(data);
mChart.highlightValues(null);
mChart.invalidate();
}
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:42,
示例21: setChartData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setChartData(AndiCarPieChart pieChart, String title, ArrayList chartDataEntries) {
ArrayList entries = new ArrayList<>();
int i;
int mChartTop = 3;
pieChart.setChartData(chartDataEntries);
pieChart.setTitle(title);
for (i = 0; i < (chartDataEntries.size() <= mChartTop ? chartDataEntries.size() : mChartTop); i++) {
entries.add(new PieEntry(chartDataEntries.get(i).value, chartDataEntries.get(i).label + " (" +
String.format(Locale.getDefault(), "%.2f", chartDataEntries.get(i).value2) + "%)"));
}
float otherValues = 0;
float otherValues2 = 0;
int j;
for (j = i; j < chartDataEntries.size(); j++) {
otherValues = otherValues + chartDataEntries.get(j).value;
otherValues2 = otherValues2 + chartDataEntries.get(j).value2;
}
if (j > i) {
entries.add(new PieEntry(otherValues, String.format(mCtx.getString(R.string.chart_label_others), otherValues2, "%")));
}
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setDrawIcons(false);
dataSet.setSliceSpace(3f);
// dataSet.setIconsOffset(new MPPointF(0, 40));
dataSet.setSelectionShift(5f);
// add the colors
dataSet.setColors(ConstantValues.CHART_COLORS);
//dataSet.setSelectionShift(0f);
PieData data = new PieData(dataSet);
// data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(12f);
data.setValueTextColor(Color.WHITE);
// data.setValueTypeface(mTfLight);
pieChart.setData(data);
// undo all highlights
// pieChart.highlightValues(null);
// pieChart.setBackgroundColor(ConstantValues.CHART_COLORS.get(ConstantValues.CHART_COLORS.size()-1));
pieChart.notifyDataSetChanged(); // let the chart know it's data changed
pieChart.invalidate();
}
開發者ID:mkeresztes,項目名稱:AndiCar,代碼行數:53,
示例22: getPieData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
/**
*
* @param count 分成幾部分
*/
private PieData getPieData(int count) {
ArrayList xValues = new ArrayList(); //xVals用來表示每個餅塊上的內容
xValues.add("已背單詞");
xValues.add("未背單詞");
/*
for (int i = 0; i < count; i++) {
xValues.add("Quarterly" + (i + 1)); //餅塊上顯示成Quarterly1, Quarterly2, Quarterly3, Quarterly4
}
*/
ArrayList yValues = new ArrayList(); //yVals用來表示封裝每個餅塊的實際數據
// 餅圖數據
/**
* 將一個餅形圖分成四部分, 四部分的數值比例為14:14:34:38
* 所以 14代表的百分比就是14%
float quarterly1 = 14;
float quarterly2 = 14;
float quarterly3 = 34;
float quarterly4 = 38;*/
int quarterly1 = util.getNum();
int quarterly2 = util.getTotal() - util.getNum();
yValues.add(new Entry(quarterly1, 0));
yValues.add(new Entry(quarterly2, 1));
//yValues.add(new Entry(quarterly3, 2));
//yValues.add(new Entry(quarterly4, 3));
//y軸的集合
PieDataSet pieDataSet = new PieDataSet(yValues, "圖例");
pieDataSet.setSliceSpace(0f); //設置個餅狀圖之間的距離
ArrayList colors = new ArrayList();
// 餅圖顏色
colors.add(Color.rgb(114, 188, 223));
colors.add(Color.rgb(205, 205, 205));
//colors.add(Color.rgb(255, 123, 124));
//colors.add(Color.rgb(57, 135, 200));
pieDataSet.setColors(colors);
DisplayMetrics metrics = getResources().getDisplayMetrics();
float px = 5 * (metrics.densityDpi / 160f);
pieDataSet.setSelectionShift(px); // 選中態多出的長度
PieData pieData = new PieData(xValues, pieDataSet);
return pieData;
}
開發者ID:coolspring1293,項目名稱:PunchCard,代碼行數:60,
示例23: getData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private PieData getData(int count, float range) {
ArrayList xValues = new ArrayList(); //xVals用來表示每個餅塊上的內容
xValues.add("陽比");
xValues.add("楊比");
xValues.add("鵬比");
xValues.add("炎比");
xValues.add("比比");
xValues.add("瑞比");
ArrayList yValues = new ArrayList(); //yVals用來表示封裝每個餅塊的實際數據
// 餅圖數據
/**
* 將一個餅形圖分成四部分, 四部分的數值比例為14:14:34:38
* 所以 14代表的百分比就是14%
*/
float quarterly1 = 20;
float quarterly2 = 20;
float quarterly3 = 20;
float quarterly4 = 20;
float quarterly5 = 20;
float quarterly6 = 0;
yValues.add(new Entry(quarterly1, 0));
yValues.add(new Entry(quarterly2, 1));
yValues.add(new Entry(quarterly3, 2));
yValues.add(new Entry(quarterly4, 3));
yValues.add(new Entry(quarterly5, 4));
yValues.add(new Entry(quarterly6, 5));
//y軸的集合
PieDataSet pieDataSet = new PieDataSet(yValues, "Quarterly Revenue 2016"/*顯示在比例圖上*/);
pieDataSet.setSliceSpace(0f); //設置個餅狀圖之間的距離
ArrayList colors = new ArrayList();
// 餅圖顏色
colors.add(Color.YELLOW);
colors.add(Color.GREEN);
colors.add(Color.BLUE);
colors.add(Color.BLACK);
colors.add(Color.GRAY);
colors.add(Color.RED);
pieDataSet.setColors(colors);
DisplayMetrics metrics = getResources().getDisplayMetrics();
float px = 5 * (metrics.densityDpi / 160f);
pieDataSet.setSelectionShift(px); // 選中態多出的長度
PieData pieData = new PieData(xValues, pieDataSet);
pieData.setValueTypeface(tf);
return pieData;
}
開發者ID:zhangxx0,項目名稱:FirstCodeUtil,代碼行數:56,
示例24: setData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData(PieChart colorPie, int order, int color) {
ArrayList entries = new ArrayList();
float colorValue = color / 255f;
entries.add(new PieEntry(colorValue, 0));
entries.add(new PieEntry(1 - colorValue, 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);
colorPie.setCenterTextColor(ColorTemplate.getHoloBlue());
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(3f);
// add a lot of colors
ArrayList colors = new ArrayList();
colors.clear();
switch (order) {
case 0:
colors.add(Color.argb(100, color, 0, 0));
colorPie.setCenterText("Red");
break;
case 1:
colors.add(Color.argb(100, 0, color, 0));
colorPie.setCenterText("Green");
break;
case 2:
colors.add(Color.argb(100, 0, 0, color));
colorPie.setCenterText("Blue");
break;
}
colors.add(Color.argb(80, 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();
}
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:48,
示例25: setPieChartData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setPieChartData() {
// Calculate macronutrient percentages.
double totalCalories = 4 * totalProtein + 4 * totalCarbs + 9 * totalFat;
float proteinRate = (float) (100 * 4 * totalProtein / totalCalories);
float carbsRate = (float) (100 * 4 * totalCarbs / totalCalories);
float fatRate = (float) (100 * 9 * totalFat / totalCalories);
// Y Axis (Pie Chart entries).
ArrayList macronutrientEntries = new ArrayList<>();
macronutrientEntries.add(new Entry(proteinRate, 0));
macronutrientEntries.add(new Entry(carbsRate, 1));
macronutrientEntries.add(new Entry(fatRate, 2));
// Pie Chart Data Set.
PieDataSet macrosDataSet = new PieDataSet(macronutrientEntries, "");
macrosDataSet.setSliceSpace(3f);
macrosDataSet.setSelectionShift(5f);
//macrosDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
// Add colors to data set.
ArrayList colors = new ArrayList<>();
colors.add(getResources().getColor(R.color.color_protein));
colors.add(getResources().getColor(R.color.color_carbs));
colors.add(getResources().getColor(R.color.color_fat));
macrosDataSet.setColors(colors);
// X Axis (Legends).
ArrayList legendMacros = new ArrayList<>();
legendMacros.add("Protein");
legendMacros.add("Carbohydrates");
legendMacros.add("Fat");
// Data for the chart.
PieData pieData = new PieData(legendMacros, macrosDataSet);
pieData.setValueFormatter(new PercentFormatter());
pieData.setValueTextSize(12f);
pieChart.setData(pieData);
// Hide Chart legend and labels.
pieChart.getLegend().setEnabled(false);
/* pieChart.setDrawSliceText(false);*/
// Set center text (total energy + units).
pieChart.setCenterText(decimalFormat.format(totalEnergy) + " " + energyUnits);
// Refresh chart.
pieChart.invalidate();
// Animate the chart.
//pieChart.animateY(800, Easing.EasingOption.EaseInQuad);
pieChart.animateXY(1200, 1200);
}
開發者ID:miguelpalacio,項目名稱:MyMacros,代碼行數:58,
示例26: chartUpdate
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
public void chartUpdate(JSONObject object) throws JSONException {
this.object = object;
ArrayList values = new ArrayList();
dataset_index = new ArrayList();
JSONObject object_tree = object;
LinkedList nt = new LinkedList();
for (String name : tree) {
try {
object_tree = object_tree.getJSONObject(name);
nt.addLast(name);
} catch (JSONException e) {} //Not a JSON object
}
tree = nt;
Iterator keys = object_tree.keys();
int ind = 0;
while (keys.hasNext()) {
String key = keys.next();
dataset_index.add(key);
Object obj = object_tree.get(key);
if (obj instanceof JSONObject) {
values.add(new Entry((float)Math.floor(count((JSONObject) obj) / 1000000), ind));
} else {
values.add(new Entry((float)Math.floor(object_tree.getLong(key) / 1000000), ind));
}
ind++;
}
PieDataSet ds = new PieDataSet(values, "Profiler");
ds.setColors(ColorTemplate.COLORFUL_COLORS);
ds.setSelectionShift(0);
PieData data = new PieData(dataset_index, ds);
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
mChart.setData(data);
mChart.invalidate();
}
開發者ID:Open-RIO,項目名稱:ToastDroid,代碼行數:44,
示例27: setData
點讚 2
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData() {
llMortgage.setVisibility(View.VISIBLE);
mPieChart.setUsePercentValues(true);
mPieChart.setDescription("Hello");
mPieChart.setDrawHoleEnabled(false);
// mPieChart.setDragDecelerationFrictionCoef(0.95f);
ArrayList yVals1 = new ArrayList<>();
for (int i = 0; i < 3; i++) {
yVals1.add(new Entry(30, i));
}
ArrayList xVals = new ArrayList<>();
for (int i = 0; i < 3; i++) {
xVals.add(mParties[i % mParties.length]);
}
ArrayList colors = new ArrayList<>();
for (int i = 0; i < COLORFUL_COLORS.length; i++) {
colors.add(COLORFUL_COLORS[i]);
}
PieDataSet dataSet = new PieDataSet(yVals1, "Biu");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(colors);
// PieData data = new PieData(xVals, dataSet);
// data.setValueFormatter(new PercentFormatter());
// data.setValueTextSize(11f);
// data.setValueTextColor(Color.WHITE);
//
// mPieChart.setData(data);
// mPieChart.highlightValue(null);
//
// mPieChart.invalidate();
//
//
// Legend l = mPieChart.getLegend();
// l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
// l.setYOffset(10f);
}
開發者ID:yzbzz,項目名稱:beautifullife,代碼行數:45,
示例28: setData
點讚 1
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData() {
ArrayList yVals1 = new ArrayList();
yVals1.add(new Entry(DaCheLiuLiang, 0));
yVals1.add(new Entry(XiaoCheLiuLiang, 1));
ArrayList xVals = new ArrayList();
xVals.add("大車");
xVals.add("小車");
PieDataSet dataSet = new PieDataSet(yVals1, "車型分類占比");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(getColors());
//dataSet.setSelectionShift(0f);
PieData data = new PieData(xVals, dataSet);
//設置自己的顯示數值樣式
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(tf);
mChart.setData(data);
// undo all highlights
mChart.highlightValues(null);
mChart.setUsePercentValues(true);
mChart.invalidate();
}
開發者ID:muyoumumumu,項目名稱:QuShuChe,代碼行數:37,
示例29: setData_2
點讚 1
import com.github.mikephil.charting.data.PieDataSet; //導入方法依賴的package包/類
private void setData_2() {
ArrayList yVals1 = new ArrayList();
yVals1.add(new Entry(ZuoZhuanLiuLiang, 0));
yVals1.add(new Entry(YouZhuanLiuLiang, 1));
yVals1.add(new Entry(ZhiXinLiuLiang, 2));
yVals1.add(new Entry(DiaoTouLiuLiangLiuLiang, 3));
ArrayList xVals = new ArrayList<>();
xVals.add("左轉");
xVals.add("右轉");
xVals.add("直行");
xVals.add("掉頭");
PieDataSet dataSet = new PieDataSet(yVals1, "轉向分類占比");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
dataSet.setColors(getColors());
//dataSet.setSelectionShift(0f);
PieData data = new PieData(xVals, dataSet);
//設置數值顯示樣式
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(tf);
mChart_2.setData(data);
// undo all highlights
mChart_2.highlightValues(null);
mChart_2.setUsePercentValues(true);
mChart_2.invalidate();
}
開發者ID:muyoumumumu,項目名稱:QuShuChe,代碼行數:44,
注:本文中的com.github.mikephil.charting.data.PieDataSet.setSelectionShift方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。