Question

I'm using AChartEngine (http://code.google.com/p/achartengine/) library to display a pie chart in an Android app.

The pie chart can have lots of slides. I want to display just on some pie slices the values, but I could not make it work (I'm not even sure it is possible).

For the DefaultRenderer I've made:

renderer.setLabelsColor(Color.BLACK);  // color of the text displayed on the chart
renderer.setLabelsTextSize(12); // size of the text displayed on the chart

and for each SimpleSeriesRenderer:

if (pieSlidesNo > 5) {
    serieRender.setDisplayChartValues(false);
} else {
    serieRender.setDisplayChartValues(true);
}

but is not working - the values are displayed on each pie slice. What I want is like in the below image (the values are displayed only on first slices, not on all).

enter image description here

Was it helpful?

Solution

For this you have to change Library Source.

Make change in draw() of PieChart.java and use renderer.setDisplayValues(true); of DefaultRenderer

 if (mRenderer.isDisplayValues()) {
        if(angle<60)
        {}
        else
        drawLabel(
            canvas,
            getLabel(mRenderer.getSeriesRendererAt(i).getChartValuesFormat(), mDataset.getValue(i)),
            mRenderer, prevLabelsBounds, mCenterX, mCenterY, shortRadius / 2, longRadius / 2,
            currentAngle, angle, left, right, mRenderer.getLabelsColor(), paint, false, true);
      }

you can change angle comparison value (angle<60) according to ur requirement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top