ThinkGeo.com    |     Documentation    |     Premium Support

Change the size of font in pieItem label inside zedGraph

Hello



i have used from zedGraph in our Project . it works very well but the label of pieitem is very small and user cannot see anything.

how do i change the size of label in pieitem.

My code is :



        private void zedGraphStyle_ZedGraphDrawing(object sender, ZedGraphDrawingEventArgs e)
        {
            try
            {
                if (e.Feature.ColumnValues[ColumnId] != "")
                {
                    var data = collGraduatedMapData.Where(g => g.ID == Convert.ToInt64(e.Feature.ColumnValues[ColumnId])).ToList(); // Get Data from database based on Province ID
                    if (data != null && data.Where(t => t.Nos > 0).Count() > 0 && ((LayerOverlay)currentMap.CustomOverlays["PaiOverlay"]).Layers.Count > 0)
                    {
                        ChangeLabelPosition(((ShapeFileFeatureLayer)((LayerOverlay)currentMap.CustomOverlays["PaiOverlay"]).Layers["Cities"]), 100);
                        ZedGraphControl zedGraph = new ZedGraphControl();
                        zedGraph.Size = new Size(100, 100);
                        zedGraph.GraphPane.Fill.Type = FillType.None;
                        zedGraph.GraphPane.Chart.Fill.Type = FillType.None;
                        zedGraph.BringToFront();
                        zedGraph.GraphPane.Border.IsVisible = false;
                        zedGraph.GraphPane.Chart.Border.IsVisible = false;
                        zedGraph.GraphPane.XAxis.IsVisible = false;
                        zedGraph.GraphPane.YAxis.IsVisible = false;
                        zedGraph.GraphPane.Legend.IsVisible = false;
                        zedGraph.GraphPane.Title.IsVisible = false;
                      
                        PieItem pieItem1;
                        foreach (var d in data)
                        {
                            pieItem1 = null;
                            pieItem1 = zedGraph.GraphPane.AddPieSlice(Convert.ToDouble(d.Nos), 

GetColorFromGeoColor(GeoColor.FromHtml(TypeColorCollection[d.Type].ToString())), 0, d.Name);      

                              ??? the Value of d.name is very small and user cannot see anything???
                            pieItem1.LabelDetail.IsVisible = true;
                            pieItem1.Displacement = 0.1;
                      
                        }
                        zedGraph.AxisChange();
                        e.Bitmap = zedGraph.GraphPane.GetImage();
                    }
                }
            }
            catch (Exception ex)
            { }
        }

Hi Hassan,



As below is my modify for our HowDoISamples DrawUsingZedGraphStyle and it looks well.



1. zedGraph.Size = new Size(500, 100); // Adjust the size so that label can shows non-wrap



2. 
 PieItem pieItem1 = zedGraph.GraphPane.AddPieSlice(Convert.ToDouble(e.Feature.ColumnValues[“WHITE”]), GetColorFromGeoColor(GeoColor.StandardColors.LightBlue), 0, “White”);
            pieItem1.LabelDetail.IsVisible = true;            // Show label
            pieItem1.LabelDetail.FontSpec.Size = 50;          // Adjust he font size
            pieItem1.LabelDetail.FontSpec.Family = “Arial”;   // Adjust the font family






Wish that’s helpful.



Regards,



Don

Thanks so much for your Guide . you help me alot

Hassan, 
  
 Great to hear it helps. 
 Any other questions, don’t hesitate to let us know. 
  
 Thanks, 
  
 Troy

Hello Troy,
Thank you for your previous help.
it’s working very well but we have found another problem with LabelDetail. when the pieItems are small, the label of them overlap each other (Find Attached picture- Gas overlap the capacity building in this situation )




Is there a way to solve this problem?



in the other words,Is it possible to change their place



LablePostion.png (15.5 KB)

Hi Hassan, 
  
 I am sorry it looks pieItem1.LabelDetail.LayoutArea or pieItem1.LabelDetail.Location should work for your requirement but I don’t know how to use them. 
  
 Because this API is provided by ZedGraph, I think maybe you can try that or do more research. I will Google it also, if I found any useful information I will let you know. 
  
 Regards, 
  
 Don