Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
How to show value in the middle of each column of a stack3Dcolumnchart ?
posted

Hello,

 

How to show value  in the middle of each column of a stack3Dcolumnchart ?

Thanks

Regards

Parents
  • 17590
    Offline posted

    Hello arnolo,

    Thank you for posting in the community!

    In order to display labels with values in the columns of the chart what I can suggest is handling FillSceneGraph event of the chart. In this event all the columns in the graph are found and according to their coordinates the position for the value labels are calculated. Please consider that this position for every single label is calculated manually. Afterwards labels are added to the SceneGraph(please note that the position of the label depends of the chart position and its rotation angle). For example:

      protected void UltraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)     {

             TextList.Clear();

             List<MyObject> list = new List<MyObject>();

            foreach (Primitive pr in e.SceneGraph)

             {

                if (pr.Row != -1 && pr.Column != -1)

                 {

                     float xMax = ((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints.Max(p => p.X);

                     float xMin = ((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints.Min(p => p.X);

                    float yMax = ((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints.Max(p => p.Y);

                    float yMin = ((Infragistics.UltraChart.Core.Primitives.Path)(pr)).GraphicsPath.PathPoints.Min(p => p.Y);

                    string temp = pr.Value.ToString();

     

                    int x = Convert.ToInt32((xMax + xMin) / 2);

                     int y = Convert.ToInt32((yMax + yMin) / 2);

     

                    Text textLable = new Text(new Point(x, y), temp);

                     textLable.PE.Fill = Color.Black;

                    MyObject obj = new MyObject();

                    obj.IntValue = y;

                     obj.IntValue2 = x;

                     obj.TextPrimitive = textLable;

                     obj.TextValue = pr.Value.ToString();

                    list.Add(obj);

                     TextList.Add(textLable);

                 }

             }

            foreach (Text item in TextList.Distinct())

             {

                 int iii = list.Where(p => p.TextValue == item.GetTextString()).Min(s => s.IntValue);

                 int iii2 = list.Where(p => p.TextValue == item.GetTextString()).Min(s => s.IntValue2);

                MyObject obj = list.Where(s => s.IntValue == iii).First() as MyObject;

                 if (obj != null) e.SceneGraph.Add(obj.TextPrimitive);

             }

         }

    I am attaching a sample project for your reference.

    Please let me know if you have any questions. 

     

    3DColumnChart.zip
Reply Children
No Data