请教,如何给饼状图标注百分比?
RT,比如说用连线指示来标志,或者直接在饼图相应部位标志
这是我的代码,已完成圆饼绘制
请教高人指教
for (int i = 0; i < arrValues.Length; i++) //绘制柱状图
{
objGraphics.FillRectangle(new SolidBrush(GetColor(i)), (i * 35) + 15, 400 - arrValues[i]*5, 25,
arrValues[i]*5);
objGraphics.DrawRectangle(Pens.Black, (i * 35) + 15, 400 - arrValues[i]*5, 25, arrValues[i]*5);
objGraphics.DrawString(arrValueNames[i].ToString() + "[ "+ arrValues[i].ToString()+ "] ", new Font( "黑体 ", 15), Brushes.Black,(i * 35) + 15,170 - arrValues[i], drawFormat);
}
objGraphics.FillRectangle(new SolidBrush(GetColor(6)), (6 * 35) + 15, 400 - total*5, 25,
total*5);
objGraphics.DrawRectangle(Pens.Black, (6 * 35) + 15, 400 - total*5, 25, total*5);
objGraphics.DrawString( "考试总人数 " + "[ "+ total+ "] ", new Font( "黑体 ", 15), Brushes.Black,(6 * 35) + 15,170 - total, drawFormat);
float sglCurrentAngle = 0;
float sglTotalAngle = 0;
float sglTotalValues = 0;
for (int i = 0; i <= arrValues.Length - 1; i++)
{
sglTotalValues += arrValues[i];
}
for (int i = 0; i < arrValues.Length; i++)//绘制立体饼图阴影部分
{
sglCurrentAngle = arrValues[i] / sglTotalValues * 360;
for(int j = 0; j < 20; j++)
{
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent60,GetColor(i)),350, 190 + j, 200, 55,sglTotalAngle, sglCurrentAngle);
//objGraphics.DrawLine(Pens.Black,new Point(100,300),new Point(360,190));//绘制连线
//objGraphics.DrawLine(Pens.Black,new Point(350,190),new Point(350,190+j));
}
sglTotalAngle += sglCurrentAngle;
}
sglCurrentAngle = 0;
sglTotalAngle = 0;
sglTotalValues = 0;
for (int i = 0; i <= arrValues.Length - 1; i++)
{
sglTotalValues += arrValues[i];
}
for (int i = 0; i < arrValues.Length; i++) //绘制数据饼状图
{
sglCurrentAngle = arrValues[i] / sglTotalValues * 360;
objGraphics.FillPie(new SolidBrush(GetColor(i)), 350, 190, 200, 55