Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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");
    }
Posted 22-Dec-10 19:54pm
Edited 22-Dec-10 23:11pm
TweakBird17.1K
v3
Comments
Sandeep Mewara at 23-Dec-10 1:07am
   
Why not check at the third party website itself?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I got the solution. Have to set labelType as percentage for all the segments. Like this...
            segment2.LabelType = PieLabelType.Percent ;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 Sergey Alexandrovich Kryukov 289
2 CPallini 275
3 DamithSL 260
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100