问题
I've developed a web page with MS Chart (.net framework 2.0, visual studio 2010). Like this picture, I have to put the percentage label inside the doughnut.
What can I do? Please help me. Thanks in advance.
回答1:
Use the PrePaint
event to add a TextAnnotation
to your chart:
protected void Chart1_PrePaint(object sender, ChartPaintEventArgs e)
{
if (e.ChartElement is ChartArea)
{
var ta = new TextAnnotation();
ta.Text = "81%";
ta.Width = e.Position.Width;
ta.Height = e.Position.Height;
ta.X = e.Position.X;
ta.Y = e.Position.Y;
ta.Font = new Font("Ms Sans Serif", 16, FontStyle.Bold);
Chart1.Annotations.Add(ta);
}
}
来源:https://stackoverflow.com/questions/45626619/place-label-at-center-of-doughnut-chart