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
110
Spacing in labels in ultrachart legend
posted

Hi,

Is it possible to change spacing between two labels rows inside a legend of an ultrachart. I wanted to increase the vertical spacing between two label rows inside the legendn as its inadequate and the two labels rows are nearly getting merged.

 

Thanks in advance

Parents
  • 200
    posted

    Hi maheshpanse,

    You can handle ChartDrawItem event and to change position, width and height of any primitive drawn on the chart. You need Text and Box primitives in the case with Legend labels. Here's a sample how to change these parameters. Note that Box's Column property can contain -1 that describes external box of the legend.

            private void ultraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e)
            {
                int newBoxHeight = 25;
                // try if it is a Box primitive which belongs to legend and it is not the external legend's box           
                Box box = e.Primitive as Box;           
                if (box != null && !string.IsNullOrEmpty(box.Path) && box.Path.EndsWith("Legend") != false && box.Column != -1)
                {
                    box.rect.Height = newBoxHeight;
                    if (box.Column != 0)
                    {
                        box.rect.Y = box.rect.Y + newBoxHeight * box.Column;
                    }
                }
                   
                Text text = e.Primitive as Text;
                // try if it is a Text primitive which belongs to legend and it is not the external legend's text
                if (text != null && !string.IsNullOrEmpty(text.Path) && text.Path.EndsWith("Legend") != false && text.Column != -1)
                {
                    text.bounds.Y += 8; // increase according to newBoxHeight in order to center the text
                    if (text.Column != 0)
                    {
                        text.bounds.Y = text.bounds.Y + newBoxHeight * text.Column;
                    }
                }

            }

     

    Please add screen shot of the problem legend in the case this sample will not help you.

Reply Children