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


Java PieChart.setCenterText方法代碼示例

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


在下文中一共展示了PieChart.setCenterText方法的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;
}
 
開發者ID:rahulmaddineni,項目名稱:Stayfit,代碼行數:26,代碼來源:PieChartFrag.java

示例2: defaultLanguageChart

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
public static PieChart defaultLanguageChart(List<Language> languages, PieChart chart, Linguist linguist) {
    chart.setCenterText(chart.getContext().getString(R.string.title_languages));

    List<PieEntry> dataSet = new ArrayList<>(languages.size());
    List<Integer> 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,代碼來源:Charts.java

示例3: defaultOSChart

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
public static PieChart defaultOSChart(List<OperatingSystem> operatingSystems, PieChart chart, Linguist linguist) {
    chart.setCenterText(chart.getContext().getString(R.string.title_os));

    List<PieEntry> entries = new ArrayList<>(operatingSystems.size());
    List<Integer> 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,代碼來源:Charts.java

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

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

    mChart = (PieChart) findViewById(R.id.chart1);
    setup(mChart);

    mChart.setCenterText(generateCenterSpannableText());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:RealmDatabaseActivityPie.java

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

示例7: 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

示例8: 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

示例9: 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();
    }
 
開發者ID:clementf2b,項目名稱:FaceT,代碼行數:39,代碼來源:ProductDetailActivity.java

示例10: 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();
}
 
開發者ID:bmelnychuk,項目名稱:outlay,代碼行數:28,代碼來源:ReportAdapter.java

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

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

示例14: fillChart

import com.github.mikephil.charting.charts.PieChart; //導入方法依賴的package包/類
/**
 * Creates a PieData object containing entries with the numbers of due and not due challenges.
 *
 * @param chart the PieChart object the calculated data will be applied to
 * @param type  the type of the statistic to be created
 * @return a list of the ids of the shown challenges, if a most played / failed / succeeded
 * challenges chart is created. Otherwise null will be returned.
 */
public List<Long> fillChart(PieChart chart, StatisticType type) {
    if (chart == null) return null;

    //Clear the chart for reloading
    chart.clear();

    //Create chart data
    List<Long> shownChallenges = new ArrayList<>();
    PieData data;

    //Find chart data and apply type specific settings
    switch (type) {
        case TYPE_DUE:
            data = mDataLogic.findDueData();
            chart.setCenterText(mApplication.getString(R.string.due_chart_center_text));
            break;
        case TYPE_STAGE:
            data = mDataLogic.findStageData();
            chart.setCenterText(mApplication.getString(R.string.stage_chart_center_text));
            break;
        default:
            data = mDataLogic.findMostPlayedData(type, shownChallenges);
            chart.setCenterText("");
            chart.getLegend().setEnabled(false);
    }

    if (data != null) {
        //Add data to chart
        chart.setData(data);

        //Apply default chart settings to the chart
        mSettings.applyChartSettings(chart);
    } else {
        //Format the no data text of the chart
        mSettings.applyNoDataSettings(chart);
    }

    //If there are shown challenges in the List object return the List object, else return null
    return (shownChallenges.size() > 0) ? shownChallenges : null;
}
 
開發者ID:Kamshak,項目名稱:BrainPhaser,代碼行數:49,代碼來源:StatisticsLogic.java

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


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