本文整理匯總了Java中com.github.mikephil.charting.charts.PieChart.getLegend方法的典型用法代碼示例。如果您正苦於以下問題:Java PieChart.getLegend方法的具體用法?Java PieChart.getLegend怎麽用?Java PieChart.getLegend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.charts.PieChart
的用法示例。
在下文中一共展示了PieChart.getLegend方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
mChart = (PieChart) v.findViewById(R.id.pieChart1);
mChart.setDescription("");
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
mChart.setCenterTextTypeface(tf);
mChart.setCenterText(generateCenterText());
mChart.setCenterTextSize(10f);
mChart.setCenterTextTypeface(tf);
// radius of the center hole in percent of maximum radius
mChart.setHoleRadius(45f);
mChart.setTransparentCircleRadius(50f);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
mChart.setData(generatePieData());
return v;
}
示例2: onCreateView
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
mChart = (PieChart) v.findViewById(R.id.pieChart1);
mChart.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
mChart.setCenterTextTypeface(tf);
mChart.setCenterText(generateCenterText());
mChart.setCenterTextSize(10f);
mChart.setCenterTextTypeface(tf);
// radius of the center hole in percent of maximum radius
mChart.setHoleRadius(45f);
mChart.setTransparentCircleRadius(50f);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
mChart.setData(generatePieData());
return v;
}
示例3: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarX.setProgress(4);
mSeekBarY.setProgress(10);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterTextTypeface(mTfLight);
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// entry label styling
mChart.setEntryLabelColor(Color.WHITE);
mChart.setEntryLabelTypeface(mTfRegular);
mChart.setEntryLabelTextSize(12f);
}
示例4: configChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void configChart(Station station, PieChart mChart) {
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
mChart.setCenterText(getString(R.string.base_state));
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setUsePercentValues(false);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setTouchEnabled(false);
mChart.setRotationEnabled(false);
mChart.setRotationAngle(0);
setData(mChart, station);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setEnabled(false);
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例5: 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();
}
示例6: 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);
}
示例7: preparePieChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
public PieChart preparePieChart(PieChart pieChart) {
pieChart.setUsePercentValues(true);
pieChart.getDescription().setEnabled(false);
pieChart.setExtraOffsets(5, 10, 5, 5);
pieChart.setDragDecelerationFrictionCoef(0.96f);
pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(android.R.color.transparent);
pieChart.setTransparentCircleColor(utilsUI.getColor(android.R.color.white));
pieChart.setTransparentCircleAlpha(50);
pieChart.setHoleRadius(40f);
pieChart.setTransparentCircleRadius(45f);
pieChart.setDrawCenterText(true);
pieChart.setCenterText("Balance");
pieChart.setRotationAngle(0);
// enable rotation of the chart by touch
pieChart.setRotationEnabled(false);
pieChart.setHighlightPerTapEnabled(true);
pieChart.setDrawEntryLabels(true);
pieChart.setEntryLabelColor(utilsUI.getColor(android.R.color.white));
pieChart.setEntryLabelTextSize(15f);
Legend l = pieChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
return pieChart;
}
示例8: getFormattedPieChart
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
/**
* Formats a pie chart in a standardized way
* @param c Context
* @param p Pie chart
* @param shouldShowLegend
* @return the PieChart, whose data must be set and invalidated
*/
public static PieChart getFormattedPieChart(Context c, PieChart p, boolean shouldShowLegend) {
Legend cLegend = p.getLegend();
if (shouldShowLegend) {
cLegend.setEnabled(true);
cLegend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
cLegend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
cLegend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
cLegend.setDrawInside(false);
cLegend.setForm(Legend.LegendForm.CIRCLE);
cLegend.setTextSize(15);
cLegend.setWordWrapEnabled(true);
} else {
cLegend.setEnabled(false);
}
p.setDrawEntryLabels(false);
p.setDescription(EMPTY_CHART_DESCRIPTION);
p.setHoleRadius(60f);
p.setTransparentCircleRadius(65f);
p.setCenterTextSize(20);
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int colorPrimaryNoir = ContextCompat.getColor(c, R.color.colorPrimaryNoir);
int colorPrimaryTextNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
p.setHoleColor(colorPrimaryNoir);
p.setTransparentCircleColor(colorPrimaryNoir);
p.setCenterTextColor(colorPrimaryTextNoir);
cLegend.setTextColor(colorPrimaryTextNoir);
}
p.setRotationEnabled(false);
p.setOnChartValueSelectedListener(new PieChartListener(p));
return p;
}
示例9: 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();
}
示例10: 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();
}
示例11: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setExtraOffsets(20.f, 0.f, 20.f, 0.f);
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
}
示例12: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart_half);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
moveOffScreen();
mChart.setUsePercentValues(true);
mChart.getDescription().setEnabled(false);
mChart.setCenterTextTypeface(mTfLight);
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationEnabled(false);
mChart.setHighlightPerTapEnabled(true);
mChart.setMaxAngle(180f); // HALF CHART
mChart.setRotationAngle(180f);
mChart.setCenterTextOffset(0, -20);
setData(4, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
// entry label styling
mChart.setEntryLabelColor(Color.WHITE);
mChart.setEntryLabelTypeface(mTfRegular);
mChart.setEntryLabelTextSize(12f);
}
示例13: 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();
}
示例14: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_piechart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(3, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
}
示例15: onCreate
import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_chart_pie);
try {
tvX = (TextView) findViewById(R.id.tvXMax);
tvY = (TextView) findViewById(R.id.tvYMax);
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
mSeekBarY.setProgress(10);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarY.setOnSeekBarChangeListener(this);
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setUsePercentValues(true);
mChart.setDescription("");
mChart.setExtraOffsets(5, 10, 5, 5);
mChart.setDragDecelerationFrictionCoef(0.95f);
tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// 設置圓盤中間區域的字體
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
mChart.setCenterText(generateCenterSpannableText());
mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(Color.WHITE);
mChart.setTransparentCircleColor(Color.WHITE);
mChart.setTransparentCircleAlpha(110);
mChart.setHoleRadius(58f);
mChart.setTransparentCircleRadius(61f);
mChart.setDrawCenterText(true);
mChart.setRotationAngle(0);
// enable rotation of the chart by touch
mChart.setRotationEnabled(true);
mChart.setHighlightPerTapEnabled(true);
// mChart.setUnit(" €");
// mChart.setDrawUnitsInChart(true);
// add a selection listener
mChart.setOnChartValueSelectedListener(this);
setData(3, 100);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
// mChart.spin(2000, 0, 360);
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(0f);
l.setYOffset(0f);
} catch (Exception e) {
e.printStackTrace();
}
}