Java Code Examples for com.github.mikephil.charting.charts.PieChart#setCenterTextColor()

The following examples show how to use com.github.mikephil.charting.charts.PieChart#setCenterTextColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressChartCard.java    From ResearchStack with Apache License 2.0 6 votes vote down vote up
private void initializeViews() {
    titleTextView = (TextView) findViewById(R.id.view_chart_progress_title);
    titleTextView.setText(titleText);
    titleTextView.setTextColor(titleTextColor);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleTextSize);
    titleTextView.setTypeface(Typeface.create(titleTextTypeface, Typeface.NORMAL));

    finishView = (TextView) findViewById(R.id.view_chart_progress_finish);
    finishView.setText(finishText);
    finishView.setTextColor(finishTextColor);

    tabLayout = (TabLayout) findViewById(R.id.view_chart_progress_tabs);
    tabLayout.setSelectedTabIndicatorColor(tabIndicatorColor);
    tabLayout.setTabTextColors(tabTextColor, tabSelectedTextColor);

    chart = (PieChart) findViewById(R.id.view_chart_progress_chart);
    chart.setDrawSliceText(false);
    chart.setTouchEnabled(false);
    chart.setHoleColor(Color.TRANSPARENT);
    chart.setHoleRadius(95f);
    chart.getLegend().setEnabled(false);
    chart.setDescription("");
    chart.setCenterTextColor(centerTextColor);
    chart.setCenterTextSize(centerTextSize);
    chart.setCenterTextTypeface(Typeface.create(centerTextTypeface, Typeface.NORMAL));
}
 
Example 2
Source File: ProductDetailActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
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();
    }
 
Example 3
Source File: ColorDetectionActivity.java    From FaceT with Mozilla Public License 2.0 4 votes vote down vote up
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();
    }