Click here to Skip to main content
15,896,118 members

To show percentage in Zedgraphweb pie chart. ASP.net

arulvallarasi.s asked:

Open original thread
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");
   }
Tags: ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900