當前位置: 首頁>>代碼示例>>Java>>正文


Java PieChart.setUsePercentValues方法代碼示例

本文整理匯總了Java中com.github.mikephil.charting.charts.PieChart.setUsePercentValues方法的典型用法代碼示例。如果您正苦於以下問題:Java PieChart.setUsePercentValues方法的具體用法?Java PieChart.setUsePercentValues怎麽用?Java PieChart.setUsePercentValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mikephil.charting.charts.PieChart的用法示例。


在下文中一共展示了PieChart.setUsePercentValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatPieChart

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void formatPieChart(PieChart pieChart) {
    pieChart.setUsePercentValues(true);
    pieChart.getDescription().setEnabled(false);
    pieChart.setDrawHoleEnabled(true);
    pieChart.setHoleColor(context.getResources().getColor(R.color.colorPrimaryDark));
    pieChart.setTransparentCircleColor(Color.GRAY);
    pieChart.setTransparentCircleAlpha(110);

    pieChart.setRotationAngle(0);
    pieChart.setRotationEnabled(true);
    pieChart.setHighlightPerTapEnabled(true);

    pieChart.setEntryLabelColor(Color.WHITE);
    pieChart.setDrawEntryLabels(false);
    pieChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:17,代碼來源:ChartFragment.java

示例2: setDefaultPieChartConfig

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
public static PieChart setDefaultPieChartConfig(PieChart chart) {
    chart.setDrawHoleEnabled(true);
    chart.setHoleColor(Color.WHITE);
    chart.setTransparentCircleColor(Color.WHITE);
    chart.setTransparentCircleAlpha(110);
    chart.setDragDecelerationFrictionCoef(0.95f);
    chart.setHoleRadius(58f);
    chart.setTransparentCircleRadius(61f);
    chart.setDescription("");
    chart.setUsePercentValues(true);
    chart.setEntryLabelColor(Color.WHITE);
    chart.setDrawCenterText(true);
    chart.setCenterTextSize(18f);
    chart.setCenterTextColor(ContextCompat.getColor(chart.getContext(), R.color.colorSecondaryText));
    chart.setRotationAngle(0);
    chart.setRotationEnabled(true);
    chart.setHighlightPerTapEnabled(true);
    chart.setMaxHighlightDistance(400f);
    chart.setCenterTextTypeface(Typeface.createFromAsset(chart.getContext().getAssets(), "fonts/Lato-Regular.ttf"));
    chart.setEntryLabelTypeface(Typeface.createFromAsset(chart.getContext().getAssets(), "fonts/Lato-Regular.ttf"));
    chart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
    return chart;
}
 
開發者ID:omgitsjoao,項目名稱:wakatime-android-client,代碼行數:24,代碼來源:Charts.java

示例3: buildView

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View buildView(Context context, ViewGroup viewGroup, FragmentManager fragmentManager) {
    PieChart chart = new PieChart(context);
    chart.setUsePercentValues(true);
    chart.setDragDecelerationFrictionCoef(0.95f);
    chart.setDrawHoleEnabled(true);
    chart.setHoleColorTransparent(true);
    chart.setTransparentCircleColor(Color.WHITE);
    chart.setHoleRadius(58f);
    chart.setTransparentCircleRadius(61f);
    chart.setDrawCenterText(true);
    chart.setRotationAngle(0);
    chart.setRotationEnabled(true);
    chart.animateY(1500, Easing.EasingOption.EaseInOutQuad);
    return chart;
}
 
開發者ID:Tiraza,項目名稱:easy-finance,代碼行數:17,代碼來源:PanelExpenseVsIncome.java

示例4: 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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:70,代碼來源:PieChartActivity.java

示例5: 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);
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:38,代碼來源:MapFragment.java

示例6: 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();

}
 
開發者ID:graviton57,項目名稱:DOUSalaries,代碼行數:47,代碼來源:ChartHelper.java

示例7: setChartOptions

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
private void setChartOptions(PieChart chart) {
    Paint p = chart.getPaint(PieChart.PAINT_INFO);
    p.setTextSize(32);
    p.setColor(0xFF444444);
    chart.setNoDataText("Dados indisponíveis.");
    chart.setUsePercentValues(true);
    chart.setHoleColor(Color.TRANSPARENT);
    chart.setHoleRadius(40f);
    chart.setTransparentCircleRadius(40f);
    chart.setDrawCenterText(true);
    chart.setDescription("");
    chart.setRotationAngle(0);
    chart.setRotationEnabled(true);
    chart.getLegend().setEnabled(false);
}
 
開發者ID:kaiomax,項目名稱:RUSpotlight,代碼行數:16,代碼來源:StatisticsFragment.java

示例8: 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;
}
 
開發者ID:MLSDev,項目名稱:RecipeFinderJavaVersion,代碼行數:35,代碼來源:DiagramUtils.java

示例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();
    }
 
開發者ID:Sopamo,項目名稱:sleepminder,代碼行數:35,代碼來源:SingleNight.java

示例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();
    }
 
開發者ID:Sopamo,項目名稱:sleepminder,代碼行數:37,代碼來源:SingleNight.java

示例11: onCreateView

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    //return buildChart();
    mLayout = (LinearLayout) inflater.inflate(R.layout.chart_pie_fragment, container, false);

    mChart = (PieChart) mLayout.findViewById(R.id.chartPie);
    mChart.setUsePercentValues(true);

    // change the color of the center-hole
    mChart.setHoleColor(Color.TRANSPARENT);

    mChart.setHoleRadius(30f);
    mChart.setDescription("");

    mChart.setDrawCenterText(true);

    mChart.setDrawHoleEnabled(true);

    mChart.setRotationAngle(0);
    // enable rotation of the chart by touch
    mChart.setRotationEnabled(true);

    // mChart.setUnit(" €");
    // mChart.setDrawUnitsInChart(true);

    // add a selection listener
    mChart.setOnChartValueSelectedListener(this);
    // mChart.setTouchEnabled(false);

    //mChart.setCenterText("MPAndroidChart\nLibrary");

    mChart.animateXY(1500, 1500);

    return mLayout;
}
 
開發者ID:moneymanagerex,項目名稱:android-money-manager-ex,代碼行數:36,代碼來源:PieChartFragment.java

示例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);

    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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:67,代碼來源:PiePolylineChartActivity.java

示例13: 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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:55,代碼來源:HalfPieChartActivity.java

示例14: 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();
}
 
開發者ID:linzuzeng,項目名稱:Microsphere,代碼行數:60,代碼來源:MainActivity.java

示例15: onCreate

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_crop_details);

  Bundle extras=getIntent().getExtras();
  String costresp= extras.getString("cost");
  String regionresp= extras.getString("region");
  String numberresp= extras.getString("number");

  region = (TextView) findViewById(R.id.region);
  cost = (TextView) findViewById(R.id.cost);
  cropOne = (TextView) findViewById(R.id.cropOne);
  cropOneDetail = (TextView) findViewById(R.id.cropOneDetail);
  cropTwo = (TextView) findViewById(R.id.cropTwo);
  cropTwoDetail = (TextView) findViewById(R.id.cropTwoDetail);
  cropThree = (TextView) findViewById(R.id.cropThree);
  cropThreeDetail = (TextView) findViewById(R.id.cropThreeDetail);

  mChart = (PieChart) findViewById(R.id.chart);

  ArrayList<Datum> crops=getIntent().getParcelableArrayListExtra("crops");

  region.setText("Region: "+regionresp);

  cost.setText("\nTotal Cost: 2273\nNumber Of Crops: 3");

  cropOne.setText(crops.get(0).getCrop());
  cropOneDetail.setText("Cost: "+crops.get(0).getCost()+"\nIrrigation: "+crops.get(0).getIrrigation()+"\nFertilizer: "+crops.get(0).getFertilizer()+"\nSeed Cost: "+crops.get(0).getFertilizer()+"\nArea: "+crops.get(0).getArea());

  cropTwo.setText(crops.get(1).getCrop());
  cropTwoDetail.setText("Cost: "+crops.get(1).getCost()+"\nIrrigation: "+crops.get(1).getIrrigation()+"\nFertilizer: "+crops.get(1).getFertilizer()+"\nSeed Cost: "+crops.get(1).getFertilizer()+"\nArea: "+crops.get(1).getArea());

  cropThree.setText(crops.get(2).getCrop());
  cropThreeDetail.setText("Cost: "+crops.get(2).getCost()+"\nIrrigation: "+crops.get(2).getIrrigation()+"\nFertilizer: "+crops.get(2).getFertilizer()+"\nSeed Cost: "+crops.get(2).getFertilizer()+"\nArea: "+crops.get(2).getArea());


  mChart.setUsePercentValues(true);

  List<PieEntry> yvalues = new ArrayList<PieEntry>();
  yvalues.add(new PieEntry(Float.valueOf(crops.get(0).getArea()), 0));
  yvalues.add(new PieEntry(Float.valueOf(crops.get(1).getArea()), 1));
  yvalues.add(new PieEntry(Float.valueOf(crops.get(2).getArea()), 2));
  //yvalues.add(new PieEntry(15f, 1));
  //yvalues.add(new PieEntry(12f, 2));
  //yvalues.add(new PieEntry(25f, 3));
  //yvalues.add(new PieEntry(23f, 4));
  //yvalues.add(new PieEntry(17f, 5));

  PieDataSet dataSet = new PieDataSet(yvalues, "Areas");

  ArrayList<String> xVals = new ArrayList<String>();

  xVals.add(crops.get(0).getCrop());
  xVals.add(crops.get(1).getCrop());
  xVals.add(crops.get(2).getCrop());
  //xVals.add("February");
  //xVals.add("March");
  //xVals.add("April");
  //xVals.add("May");
  //xVals.add("June");

  PieData data = new PieData(dataSet);

  data.setValueFormatter(new PercentFormatter());
  mChart.setData(data);


  dataSet.setColors(ColorTemplate.VORDIPLOM_COLORS);
  mChart.setDrawHoleEnabled(true);
  mChart.setTransparentCircleRadius(30f);
  mChart.setHoleRadius(30f);

  data.setValueTextSize(13f);
  data.setValueTextColor(Color.DKGRAY);

}
 
開發者ID:Radon-MSIT,項目名稱:hackCIC,代碼行數:77,代碼來源:CropDetailsActivity.java


注:本文中的com.github.mikephil.charting.charts.PieChart.setUsePercentValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。