将标签放在甜甜圈图的中心 [英] Place label at center of doughnut chart
本文介绍了将标签放在甜甜圈图的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用MS Chart(.net Framework 2.0,Visual Studio 2010)开发了一个网页。
像这张照片一样,我必须将百分比标签放在甜甜圈中。
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.
推荐答案
使用 PrePaint
事件添加 TextAnnotation
到您的图表:
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);
}
}
这篇关于将标签放在甜甜圈图的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文