Search code examples
androidchartspie-chartandroidplot

Remove seperator lines on Android Plot Pie Chart


I've used android plot pie chart to plot data in my application. My problem is that the separator lines in the pie chart (in image attached below). I can't seem to get rid of the black line no matter what way I have set up the chart.

Here is how I've set it up:

//Sets up the pie chart to display the user beer ratings figures visually
private void chartSetup(PieChart p){

    PieWidget pw = p.getPieWidget();

    pw.setPadding(0,0,0,0);

    SegmentFormatter sf1 = new SegmentFormatter();
    sf1.configure(getActivity(),R.xml.pie_segment_formatter1);

    sf1.getFillPaint();

    SegmentFormatter sf2 = new SegmentFormatter();

    sf2.configure(getActivity(), R.xml.pie_segment_formatter2);
    sf2.getFillPaint();

    Segment monthly = new Segment("", totalBeerCount);
    Segment total = new Segment("", monthlyBeerCount);

    p.setPlotMarginBottom(0);

    p.addSegment(monthly, sf1);
    p.addSegment(total, sf2);
    p.redraw();
    p.getBorderPaint().setColor(Color.TRANSPARENT);
    p.getBackgroundPaint().setColor(Color.TRANSPARENT);

    p.getRenderer(PieRenderer.class).setDonutSize(.90f, PieRenderer.DonutMode.PERCENT);
}

and here are the two segment formatter xml files:

pie_segment_formatter1

<?xml version="1.0" encoding="utf-8"?>
<config
    fillPaint.color="@color/appRed"
    labelPaint.textSize="5dp"
    innerEdgePaint.color = "@color/appRed"
    outerEdgePaint.color = "@color/appRed"/>

pie_segment_formatter2

<?xml version="1.0" encoding="utf-8"?>
<config
    fillPaint.color="@color/lightGrey"
    labelPaint.textSize="5dp"
    innerEdgePaint.color = "@color/lightGrey"
    outerEdgePaint.color = "@color/lightGrey"/>

I have tried including linePaint.strokeWidth="0dp" in the config files but that doesn't make any difference. If anyone could help me on this i'd greatly appreciate it.

Pie Chart


Solution

  • What you're looking for is the paint used to draw the radial edges. Add this line to each of your formatter xml cfgs:

    radialEdgePaint.color="#00000000"
    

    Or programmatically within your Java src:

    formatter.setRadialEdgePaint(null);