本文整理汇总了Java中com.github.mikephil.charting.charts.PieChart.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Java PieChart.invalidate方法的具体用法?Java PieChart.invalidate怎么用?Java PieChart.invalidate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.charts.PieChart
的用法示例。
在下文中一共展示了PieChart.invalidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPieChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
/**
* Set the pie pattern
* @param pieChart chart
* @param chartData pie chart data
* @param title chart title
* @param tf Typeface font
*/
public static void setPieChart(PieChart pieChart, ChartData<?> chartData,
SpannableString title, Typeface tf) {
chartData.setValueFormatter(new PercentFormatter());
chartData.setValueTextSize(11f);
chartData.setValueTextColor(Color.BLACK);
chartData.setValueTypeface(tf);
pieChart.setUsePercentValues(true);
pieChart.getDescription().setEnabled(false);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDragDecelerationFrictionCoef(0.95f);
pieChart.setCenterTextTypeface(tf);
pieChart.setCenterText(title);
pieChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleColor(Color.WHITE);
pieChart.setTransparentCircleAlpha(110);
pieChart.setHoleRadius(58f);
pieChart.setTransparentCircleRadius(61f);
pieChart.setDrawCenterText(true);
pieChart.setRotationAngle(0);
pieChart.setRotationEnabled(true);// enable rotation of the chart by touch
pieChart.setHighlightPerTapEnabled(true);
pieChart.setEntryLabelTextSize(10f);
Legend l = pieChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
pieChart.setData((PieData) chartData);
pieChart.animateY(DURATION_MEDIUM, Easing.EasingOption.EaseInOutQuad);
pieChart.highlightValues(null);// undo all highlights
pieChart.invalidate();
}
示例2: setupPie
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setupPie(PieChart pieChart, int pos, float dados[], String labels[]) {
List<PieEntry> entries = new ArrayList<>();
int index = 0;
for (float dado : dados) {
entries.add(new PieEntry(dado, labels[index]));
index++;
}
//entries.add(new PieEntry(24.0f, "Red"));
//entries.add(new PieEntry(30.8f, "Blue"));
PieDataSet set = new PieDataSet(entries, "");
Description description = new Description();
description.setText(" ");
pieChart.setDescription(description);
set.setColors(ColorTemplate.MATERIAL_COLORS);
PieData data = new PieData(set);
pieChart.setData(data);
pieChart.invalidate();
Legend l = pieChart.getLegend();
l.setFormSize(15f); // set the size of the legend forms/shapes
l.setForm(Legend.LegendForm.CIRCLE); // set what type of form/shape should be used
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
l.setTextSize(18f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f); // set the space between the legend entries on the x-axis
l.setYEntrySpace(5f);
pieChart.animateXY(3000, 3000);
}
示例3: setChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的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();
}
示例4: seteffect
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void seteffect(PieChart colorPie) {
colorPie.animateXY(2000, 2000, Easing.EasingOption.EaseInBounce, Easing.EasingOption.EaseInBounce);
colorPie.invalidate();
colorPie.setDrawHoleEnabled(true);
colorPie.setExtraOffsets(10, 10, 10, 10);
colorPie.setContentDescription("");
colorPie.setDragDecelerationFrictionCoef(0.95f);
colorPie.setDrawCenterText(true);
colorPie.setRotationAngle(0);
// enable rotation of the chart by touch
colorPie.setRotationEnabled(true);
colorPie.setHighlightPerTapEnabled(true);
colorPie.setDrawHoleEnabled(true);
colorPie.setHoleColor(Color.WHITE);
//disable the label and description
colorPie.getDescription().setEnabled(false);
colorPie.getLegend().setEnabled(false);
colorPie.setTransparentCircleColor(Color.WHITE);
colorPie.setTransparentCircleAlpha(80);
colorPie.setElevation(10f);
colorPie.setHoleRadius(60f);
colorPie.setTransparentCircleRadius(61f);
// add a selection listener
colorPie.setOnChartValueSelectedListener(this);
}
示例5: setEffectPieChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setEffectPieChart(PieChart colorPie) {
colorPie.animateXY(1500, 1500, Easing.EasingOption.EaseInBounce, Easing.EasingOption.EaseInBounce);
colorPie.invalidate();
colorPie.setDrawHoleEnabled(true);
colorPie.setExtraOffsets(10, 10, 10, 10);
colorPie.setContentDescription("");
colorPie.setDragDecelerationFrictionCoef(0.95f);
colorPie.setDrawCenterText(true);
colorPie.setRotationAngle(0);
// enable rotation of the chart by touch
colorPie.setRotationEnabled(true);
colorPie.setHighlightPerTapEnabled(true);
colorPie.setDrawHoleEnabled(true);
colorPie.setHoleColor(Color.WHITE);
colorPie.getLegend().setFormSize(10f);
colorPie.getLegend().setFormToTextSpace(5f);
//disable the label and description
colorPie.getDescription().setEnabled(false);
colorPie.getLegend().setEnabled(false);
colorPie.setTransparentCircleColor(Color.WHITE);
colorPie.setTransparentCircleAlpha(80);
colorPie.setElevation(10f);
colorPie.setHoleRadius(90f);
colorPie.setTransparentCircleRadius(61f);
// add a selection listener
colorPie.setOnChartValueSelectedListener(this);
}
示例6: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的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();
}
示例7: updateChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的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();
}
示例8: setupSleepStagesChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的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();
}
示例9: setupLightChart
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的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();
}
示例10: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setData(PieChart mChart, Station station) {
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
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<String> xVals = new ArrayList<String>();
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<Integer> colors = new ArrayList<Integer>();
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();
}
示例11: onPostExecute
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
@Override
protected void onPostExecute(String result) {
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setVisibility(View.VISIBLE);
ProgressBar prg = (ProgressBar) findViewById(R.id.progressBar1);
prg.setVisibility(View.INVISIBLE);
//TextView rtv = (TextView) findViewById(R.id.result_text);
PieChart mChart = (PieChart) findViewById(R.id.result_text);
mChart.setVisibility(View.VISIBLE);
add_log("Generating report...");
String report= String.format("Report \n\n Single beads: %, 5d \n Dimers: %, 17d \n \n Percentage of dimer: %2.2f %%",total_single_count,total_double_count,(double)total_double_count*100.0/((double)total_double_count+(double)total_single_count)+Math.ulp(1.0));
//rtv.setText(report);
add_log(report);
List<PieEntry> entries_double = new ArrayList<>();
entries_double.add(new PieEntry(total_single_count,"Single beads"));
entries_double.add(new PieEntry(total_double_count,"Dimers"));
PieDataSet dataset_double = new PieDataSet(entries_double, "");
dataset_double.setColors(ColorTemplate.MATERIAL_COLORS);
PieData pieData = new PieData(dataset_double);
pieData.setDrawValues(true);
pieData.setValueTextColor(Color.BLUE);
pieData.setValueTextSize(20f);
pieData.setValueFormatter(new PercentFormatter());
mChart.setEntryLabelColor(Color.BLACK);
mChart.setEntryLabelTextSize(22f);
mChart.setDrawHoleEnabled(true);
mChart.setHoleRadius(40f);
mChart.setTransparentCircleRadius(48f);
mChart.setTransparentCircleColor(Color.BLACK);
mChart.setTransparentCircleAlpha(50);
mChart.setHoleColor(Color.WHITE);
mChart.setDrawCenterText(true);
mChart.setCenterText("Detection result");
mChart.setCenterTextSize(17f);
mChart.setCenterTextColor(Color.BLACK);
mChart.setUsePercentValues(true);
mChart.setDrawEntryLabels(true);
Legend l = mChart.getLegend();
l.setEnabled(true);
l.setTextSize(17f);
mChart.getDescription().setEnabled(false);
mChart.setData(pieData);
mChart.invalidate();
Snackbar.make(findViewById(android.R.id.content), "Detection finished. ", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
示例12: onCreate
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_mode_stats_page);
Intent intent = getIntent();
stats = intent.getParcelableExtra("STATS");
category = intent.getStringExtra("CATEGORY");
categoryLabel = (TextView) findViewById(R.id.categoryLabel);
if (category.equals("Random")) {
categoryLabel.setText("Category: All");
} else {
categoryLabel.setText("Category: " + category);
}
menuButton = (Button) findViewById(R.id.menuButton);
noResultsLabel = (TextView) findViewById(R.id.noResultsLabel);
pieChart = (PieChart) findViewById(R.id.pieChart);
if (stats.getNumberCorrect() == 0 && stats.getNumberIncorrect() == 0 && stats.getNumberNotAnswered() == 0) {
System.out.println("Test");
noResultsLabel.setVisibility(View.VISIBLE);
} else {
Description desc = new Description();
desc.setText("");
pieChart.setDescription(desc);
pieChart.setHoleColor(Color.TRANSPARENT);
pieChart.setTransparentCircleRadius(0);
pieChart.getLegend().setEnabled(false);
List<PieEntry> entries = new ArrayList<PieEntry>();
List<Integer> colors = new ArrayList<Integer>();
if (stats.getNumberCorrect() > 0) {
entries.add(new PieEntry(stats.getNumberCorrect(), "Correct"));
colors.add(getResources().getColor(R.color.quizStatsCorrect));
}
if (stats.getNumberIncorrect() > 0) {
entries.add(new PieEntry(stats.getNumberIncorrect(), "Incorrect"));
colors.add(getResources().getColor(R.color.quizStatsIncorrect));
}
if (stats.getNumberNotAnswered() > 0) {
entries.add(new PieEntry(stats.getNumberNotAnswered(), "Not Answered"));
colors.add(getResources().getColor(R.color.quizStatsNotAnswered));
}
PieDataSet dataSet = new PieDataSet(entries, "");
dataSet.setColors(colors);
PieData pieData = new PieData(dataSet);
pieData.setValueTextColor(Color.WHITE);
pieData.setValueTextSize(16.0f);
pieData.setValueFormatter(new QuizStatsFormatter());
pieChart.setData(pieData);
pieChart.setVisibility(View.VISIBLE);
pieChart.invalidate();
}
}
示例13: clearChartData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void clearChartData(PieChart chart) {
chart.clear();
chart.setData(null);
chart.highlightValues(null);
chart.invalidate();
}
示例14: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
private void setData(PieChart colorPie, int order, int color) {
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
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<Integer> colors = new ArrayList<Integer>();
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();
}
示例15: setData
import com.github.mikephil.charting.charts.PieChart; //导入方法依赖的package包/类
public void setData(PieChart pieChart, PieData pieData) {
pieChart.setData(pieData);
pieChart.highlightValue(null);
pieChart.invalidate();
pieChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
}