本文整理匯總了Java中com.github.mikephil.charting.charts.PieChart.setBackgroundColor方法的典型用法代碼示例。如果您正苦於以下問題:Java PieChart.setBackgroundColor方法的具體用法?Java PieChart.setBackgroundColor怎麽用?Java PieChart.setBackgroundColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.charts.PieChart
的用法示例。
在下文中一共展示了PieChart.setBackgroundColor方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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);
}