我正在使用 aChartEngine 库在我的 android 应用程序中绘制甜甜圈。我想做两个甜甜圈 - 一个在另一个里面有两种不同的颜色。但我无法用两种不同的颜色制作它们。这是我在 LinearLayout 中绘制甜甜圈的甜甜圈类。
public class PunchStatGraph {
private GraphicalView mChartView2;
static int count = 2;
int[] Mycolors = new int[] { Color.parseColor("#D4272D"),
Color.parseColor("#6F1717") };
String[] average = { "SPEED", "FORCE"};
String[] max = { "SPEED", "FORCE"};
public Intent execute(Context context, LinearLayout parent, double avg_values[],double max_values[]) {
parent.removeAllViews();
int[] colors = new int[count];
for (int i = 0; i < count; i++) {
colors[i] = Mycolors[i];
}
DefaultRenderer renderer = buildCategoryRenderer(colors);
renderer.setShowLabels(false);
renderer.setBackgroundColor(Color.BLACK);
renderer.setPanEnabled(false);// Disable User Interaction
renderer.setScale((float) 1.4);
renderer.setInScroll(true); //To avoid scroll Shrink
renderer.setStartAngle(90);
renderer.setShowLegend(false);
MultipleCategorySeries categorySeries = new MultipleCategorySeries(
"Punch Graph");
categorySeries.add(average, avg_values);
categorySeries.add(max, max_values);
mChartView2 = ChartFactory.getDoughnutChartView(context,
categorySeries, renderer);
parent.addView(mChartView2);
return ChartFactory.getDoughnutChartIntent(context, categorySeries,
renderer, null);
}
protected DefaultRenderer buildCategoryRenderer(int[] colors) {
DefaultRenderer renderer = new DefaultRenderer();
for (int color : colors) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color);
renderer.addSeriesRenderer(r);
}
return renderer;
}
}
也检查图像。在此先感谢。