将标签放在圆环图的中心
Place label at center of doughnut chart
我用 MS Chart(.net framework 2.0,visual studio 2010)开发了一个网页。
像这张图,我要把百分比标签贴在甜甜圈里面。
我能做什么?请帮我。提前致谢。
使用 PrePaint
事件将 TextAnnotation
添加到您的图表:
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);
}
}
我用 MS Chart(.net framework 2.0,visual studio 2010)开发了一个网页。 像这张图,我要把百分比标签贴在甜甜圈里面。
我能做什么?请帮我。提前致谢。
使用 PrePaint
事件将 TextAnnotation
添加到您的图表:
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);
}
}