user3552603
user3552603

Reputation:

Custom pie chart by drawing circles

I need to do this: Pie chart

I have done this:

I consider my work as great success but still it is not perfect. So could you advice me how to finish it to have it look like the first picture? I need to get rid of some of that lines as you can see. Any idea?

To draw it I have used 3 circles drawArc() method. And used values of degrees from the array.

Even though you don't know the answer you could vote it up since it is hard.

Upvotes: 1

Views: 201

Answers (1)

user3552603
user3552603

Reputation:

The answer was to draw it as path:

CODE:

if (i == 0) {
            final Path path = new Path();
            paint.setColor(COLORS[i]);
            // draw 3 paths to show 3 curves  
            path.addArc(rectf, 180, value_degree[i] - 4);
            path.addArc(rectf2, 180, value_degree[i] - 5);
            path.addArc(rectf3, 180, value_degree[i] - 6);
            // draw the path
            canvas.drawPath(path, paint);

            // disagree
        } else {
            temp += (int) value_degree[i - 1];
            paint.setColor(COLORS[i]);
            final Path path = new Path();
            path.addArc(rectf, temp + 180 + 4, value_degree[i] - 4);
            path.addArc(rectf2, temp + 180 + 5, value_degree[i] - 5);
            path.addArc(rectf3, temp + 180 + 6, value_degree[i] - 6);
            // draw the path
            canvas.drawPath(path, paint);
        }

RESULT:

Upvotes: 3

Related Questions