我想知道是否有可能在Android中复制这种图形。
直接从图像输入数据并不重要,将在之前的屏幕上输入。
如果不可能重新创建一个类似的图表(我认为其实很难)可能使用一个简单的蜘蛛图,但重要的是可以插入两个不同的系列,并且它们有自己的标签。
事实上,请注意标签大写形成一个表面,而用小写字母写的标签则形成另一个。 你说你可以做这样的事情吗?
我发现这个图书馆(https://code.google.com/p/charts4j/)也做图形蜘蛛图,但是我不能用他的“传奇”进入另一个系列!
答案 0 :(得分:2)
我在图表的设计中已经部分解决了! 现在我可以绘制完全相同的表格并正确输入数据。 特别是,我创建了一个扩展ImageView的自定义视图,并在 onDraw(Canvas画布)上添加了以下代码:(代码根本没有优化,我知道,它只是为了快速运行测试)
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
Paint paint_cibo = new Paint();
Paint paint_vino = new Paint();
Paint paint_text = new Paint();
final float x = getWidth() * 1.5f;
final float y = getHeight() * 1.5f;
final int[] valori_cibo = new int[]{2, 5, 4, 8, 3, 5};
final int[] valori_vino = new int[]{6, 7, 7, 6, 6, 6};
canvas.drawColor(Color.WHITE);
paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2f);
paint_cibo.setAntiAlias(true);
paint_cibo.setColor(Color.BLUE);
paint_cibo.setStyle(Paint.Style.STROKE);
paint_cibo.setStrokeWidth(2f);
paint_vino.setAntiAlias(true);
paint_vino.setColor(Color.RED);
paint_vino.setStyle(Paint.Style.STROKE);
paint_vino.setStrokeWidth(2f);
paint_text.setAntiAlias(true);
paint_text.setColor(Color.BLACK);
paint_text.setStyle(Paint.Style.FILL);
paint_text.setTextSize(10);
// Disegno i cerchi
for(int i = 1; i <= 110; i += 10)
canvas.drawCircle(x, y, i, paint);
// Disegno le linee di intersezione
canvas.drawLine(x + 10, y - 2.5f, (float)(x + 10 + 110 * Math.cos(returnGradi(90))), (float)(y - 2.5f - 110 * Math.sin(returnGradi(90))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(45))), (float)(y - 110 * Math.sin(returnGradi(45))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(30))), (float)(y - 110 * Math.sin(returnGradi(30))), paint);
canvas.drawLine(x + 10, y - 5, (float)(x + 10 + 110 * Math.cos(returnGradi(315))), (float)(y - 5 - 110 * Math.sin(returnGradi(315))), paint);
canvas.drawLine(x, y + 8, (float)(x + 110 * Math.cos(returnGradi(315))), (float)(y + 8 - 110 * Math.sin(returnGradi(315))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(280))), (float)(y - 110 * Math.sin(returnGradi(280))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(260))), (float)(y - 110 * Math.sin(returnGradi(260))), paint);
canvas.drawLine(x - 10, y - 5, (float)(x - 10 + 110 * Math.cos(returnGradi(225))), (float)(y - 5 - 110 * Math.sin(returnGradi(225))), paint);
canvas.drawLine(x, y + 8, (float)(x + 110 * Math.cos(returnGradi(225))), (float)(y + 8 - 110 * Math.sin(returnGradi(225))), paint);
canvas.drawLine(x - 10, y - 2.5f, (float)(x - 10 + 110 * Math.cos(returnGradi(90))), (float)(y - 2.5f - 110 * Math.sin(returnGradi(90))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(135))), (float)(y - 110 * Math.sin(returnGradi(135))), paint);
canvas.drawLine(x, y, (float)(x + 110 * Math.cos(returnGradi(150))), (float)(y - 110 * Math.sin(returnGradi(150))), paint);
// Disegno i numeri
for(int i = 1; i <= 10; i++)
canvas.drawText(String.valueOf(i), x - 2.5f, y - i * 10, paint_text);
//Inizio il disegno per il cibo
canvas.drawLine((float)(x + valori_cibo[0] * 10 * Math.cos(returnGradi(45))), (float)(y - valori_cibo[0] * 10 * Math.sin(returnGradi(45))), (float)(x + valori_cibo[1] * 10 * Math.cos(returnGradi(30))), (float)(y - valori_cibo[1] * 10 * Math.sin(returnGradi(30))), paint_cibo);
canvas.drawLine((float)(x + valori_cibo[1] * 10 * Math.cos(returnGradi(30))), (float)(y - valori_cibo[1] * 10 * Math.sin(returnGradi(30))), (float)(x + valori_cibo[2] * 10 * Math.cos(returnGradi(280))), (float)(y - valori_cibo[2] * 10 * Math.sin(returnGradi(280))), paint_cibo);
canvas.drawLine((float)(x + valori_cibo[2] * 10 * Math.cos(returnGradi(280))), (float)(y - valori_cibo[2] * 10 * Math.sin(returnGradi(280))), (float)(x + valori_cibo[3] * 10 * Math.cos(returnGradi(260))), (float)(y - valori_cibo[3] * 10 * Math.sin(returnGradi(260))), paint_cibo);
canvas.drawLine((float)(x + valori_cibo[3] * 10 * Math.cos(returnGradi(260))), (float)(y - valori_cibo[3] * 10 * Math.sin(returnGradi(260))), (float)(x + valori_cibo[4] * 10 * Math.cos(returnGradi(150))), (float)(y - valori_cibo[4] * 10 * Math.sin(returnGradi(150))), paint_cibo);
canvas.drawLine((float)(x + valori_cibo[4] * 10 * Math.cos(returnGradi(150))), (float)(y - valori_cibo[4] * 10 * Math.sin(returnGradi(150))), (float)(x + valori_cibo[5] * 10 * Math.cos(returnGradi(135))), (float)(y - valori_cibo[5] * 10 * Math.sin(returnGradi(135))), paint_cibo);
canvas.drawLine((float)(x + valori_cibo[5] * 10 * Math.cos(returnGradi(135))), (float)(y - valori_cibo[5] * 10 * Math.sin(returnGradi(135))), (float)(x + valori_cibo[0] * 10 * Math.cos(returnGradi(45))), (float)(y - valori_cibo[0] * 10 * Math.sin(returnGradi(45))), paint_cibo);
//Inizio il disegno per il vino
canvas.drawLine((float)(x + 10 + valori_vino[0] * 10 * Math.cos(returnGradi(90))), (float)(y - valori_vino[0] * 10 * Math.sin(returnGradi(90))), (float)(x + 10 + valori_vino[1] * 10 * Math.cos(returnGradi(315))), (float)(y - 5 - valori_vino[1] * 10 * Math.sin(returnGradi(315))), paint_vino);
canvas.drawLine((float)(x + 10 + valori_vino[1] * 10 * Math.cos(returnGradi(315))), (float)(y - 5 - valori_vino[1] * 10 * Math.sin(returnGradi(315))), (float)(x + 5 + valori_vino[3] * 10 * Math.cos(returnGradi(315))), (float)(y + 10 - valori_vino[3] * 10 * Math.sin(returnGradi(315))), paint_vino);
canvas.drawLine((float)(x + 5 + valori_vino[3] * 10 * Math.cos(returnGradi(315))), (float)(y + 10 - valori_vino[3] * 10 * Math.sin(returnGradi(315))), (float)(x + 5 + valori_vino[3] * 10 * Math.cos(returnGradi(225))), (float)(y + 5 - valori_vino[3] * 10 * Math.sin(returnGradi(225))), paint_vino);
canvas.drawLine((float)(x + 5 + valori_vino[3] * 10 * Math.cos(returnGradi(225))), (float)(y + 5 - valori_vino[3] * 10 * Math.sin(returnGradi(225))), (float)(x - 5 + valori_vino[4] * 10 * Math.cos(returnGradi(225))), (float)(y - 8 - valori_vino[4] * 10 * Math.sin(returnGradi(225))), paint_vino);
canvas.drawLine((float)(x - 5 + valori_vino[4] * 10 * Math.cos(returnGradi(225))), (float)(y - 8 - valori_vino[4] * 10 * Math.sin(returnGradi(225))), (float)(x - 10 + valori_vino[5] * 10 * Math.cos(returnGradi(90))), (float)(y - valori_vino[5] * 10 * Math.sin(returnGradi(90))), paint_vino);
canvas.drawLine((float)(x - 10 + valori_vino[5] * 10 * Math.cos(returnGradi(90))), (float)(y - valori_vino[5] * 10 * Math.sin(returnGradi(90))), (float)(x + 10 + valori_vino[0] * 10 * Math.cos(returnGradi(90))), (float)(y - valori_vino[0] * 10 * Math.sin(returnGradi(90))), paint_vino);
}
我再说一遍,不要考虑优化不佳的代码...... 可以实现某种缩放,使焦距变焦保持在圆心的中心吗?
答案 1 :(得分:0)
查看GitHub上的Android-Charts项目。