We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, i hope somebody could help me because i should do the Project for my work. I created a pie Chart but i dont know how i can place the Label.
In the middle of the arc (outside the Circle) there should be the Label.
for (Rohtipps g : myRohtipp) {
//PVector c = randomVector(mapped);
//draw ellipse
PVector loc = g.getLocation();
float dia = g.getDiameter();
//noFill();
float[] data={g.getColdlead(), g.getWarmlead(), g.getHotlead()};
//float[] data={50.0, 50.0, 50.0, 50.0};
float sumdata=0;
for (int i=0; i<data.length; i++) {
sumdata+=data[i];
}
//println(sumdata);
sumdata = 360/sumdata;
for (int i=0; i<data.length; i++) {
data[i] = sumdata*data[i];
}
float lastAngle=0;
for (int i=0; i<data.length; i++) {
float col=map(i, 0, data.length, 20, 255);
fill(55, 150, col, col+100);
noStroke();
arc(loc.x, loc.y, dia, dia, lastAngle, lastAngle+radians(data[i]));
lastAngle +=radians(data[i]);
}
//println(g.getKampagne()+" "+g.getColdlead()+" "+g.getWarmlead()+" "+g.getHotlead());
//pieChart(dia, loc.x, loc.y, data);
//ellipse(loc.x, loc.y, dia, dia);
fill(40, 40, 40);
//label positionieren
textSize(11);
float tw=(textWidth(g.getKampagne()))/2;
text(g.getKampagne(), loc.x-tw, loc.y+30);
//println(g.getAnzahl());
ts=ts-2;
textSize(ts);
fill(30, 30, 30);
text(g.getKampagne()+" "+g.getAnzahl(), 1400, g.getPositionText());
textSize(24);
//println(g.getColdlead());
}
Thanks Theresa
Answers
The code you posted does not run. It is missing user-defined classes, and probably your data.
Here is an example of a pie-chart with a label instead. Make sure you understand how this is drawn, and then use that understanding to draw your own pie chart and label.
Thank you guys! Great!