在Zedgraphweb饼图中显示百分比。 ASP.net [英] To show percentage in Zedgraphweb pie chart. ASP.net
本文介绍了在Zedgraphweb饼图中显示百分比。 ASP.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
使用ZedGraphweb控件显示饼图。我必须在每个块中显示不在图例中的百分比。在传说中我必须显示文本标签。我必须在图表中显示百分比。能帮帮我吗。
预付谢谢
我的代码看起来像这样
Hi
Am using ZedGraphweb control to show pie chart. I have to display the percentage in each block not in legend. In legend i have to show the text labels. and i have to show percentage in graph itself. Can you please help me.
Thanks in Advance
My code look like this
private void InitializeComponent()
{
this.ZedGraphWeb1.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(this.OnRenderGraph1);
}
private void OnRenderGraph1(ZedGraph.Web.ZedGraphWeb z1, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
{
GraphPane myPane = masterPane[0];
string[] labels = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
double[] x4 = { 80, 50, 20, 20, 90, 80, 30, 50, 60, 30, 80, 70 };
myPane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f);
myPane.Chart.Fill.Type = FillType.None;
myPane.Legend.Position = LegendPos.Float;
myPane.Legend.Location = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top);
myPane.Legend.FontSpec.Size = 10f;
myPane.Legend.IsHStack = false;
myPane.YAxis.MinorTic.IsOpposite = false;
myPane.XAxis.MajorGrid.DashOff = 0;
myPane.XAxis.MajorTic.Color = Color.WhiteSmoke;
myPane.YAxis.MajorGrid.DashOff = 0;
myPane.YAxis.MajorTic.Color = Color.WhiteSmoke;
myPane.XAxis.MajorGrid.Color = Color.WhiteSmoke;
myPane.YAxis.MajorGrid.Color = Color.WhiteSmoke;
myPane.XAxis.Scale.TextLabels = labels;
myPane.Legend.Position = LegendPos.InsideTopRight;
PieItem segment2 = myPane.AddPieSlice(x4[1], Color.Purple, Color.White, 45f, 0, "Feb");
PieItem segment3 = myPane.AddPieSlice(x4[2], Color.LimeGreen, Color.White, 45f, 0, "Mar");
PieItem segment4 = myPane.AddPieSlice(x4[3], Color.SandyBrown, Color.White, 45f, 0, "Apr");
PieItem segment5 = myPane.AddPieSlice(x4[4], Color.Red, Color.White, 45f, 0, "May");
PieItem segment6 = myPane.AddPieSlice(x4[5], Color.Blue, Color.White, 45f, 0, "Jun");
PieItem segment7 = myPane.AddPieSlice(x4[6], Color.Green, Color.White, 45f, 0, "Jul");
PieItem segment8 = myPane.AddPieSlice(x4[7], Color.Yellow, Color.White, 45f, 0, "Aug");
PieItem segment9 = myPane.AddPieSlice(x4[8], Color.YellowGreen, Color.White, 45f, 0, "Sep");
PieItem segment10 = myPane.AddPieSlice(x4[9], Color.AliceBlue, Color.White, 45f, 0, "Oct");
PieItem segment11 = myPane.AddPieSlice(x4[10], Color.AntiqueWhite, Color.White, 45f, 0, "Nov");
PieItem segment12 = myPane.AddPieSlice(x4[11], Color.Aqua, Color.White, 45f, 0, "Dec");
}
推荐答案
我得到了解决方案。必须将labelType设置为所有段的百分比。像这样...
segment2.LabelType = PieLabelType.Percent;
I got the solution. Have to set labelType as percentage for all the segments. Like this...
segment2.LabelType = PieLabelType.Percent ;
这篇关于在Zedgraphweb饼图中显示百分比。 ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文