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
215
Legend Item Customization
posted

Hello,

A client would like to bold the text in the legend of a pie chart for the largest slice.  Is this possible?

Parents
No Data
Reply
  • 26458
    Offline posted
    There's really no simple and effective way to do this. You have to find the right legend box primitive that matches the pie slice, then find the matching text, which luckily follows the legend box. You can try something like this:

    Text textPrimitive = null;

    private void ultraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e)
    {
       if (e.Primitive == textPrimitive)
       {
          textPrimitive.labelStyle.Font =
    new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
       }
    }

    private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
    {
       int row = 0;
       double value = 0;
       foreach (Primitive p in e.SceneGraph)
       {
          if (p is Wedge)
          {
             if ((double)p.Value > value)
             {
                row = p.Row;
                value = (
    double)p.Value;
             }
          }
       }

       foreach (Primitive p in e.SceneGraph)
       {
          if (p.Path!=null && p.Path.ToLower().IndexOf("legend") != -1)
          {
             if (p.Row == row)
             {
                textPrimitive = e.SceneGraph[e.SceneGraph.IndexOf(p) + 1]
    as Text;
             }
          }
       }
    }

Children
No Data