PieChart legend alignmen

Thread is closed for posting
2 posts, 0 answers
  1. Pavlo
    Pavlo avatar
    1 posts
    Member since:
    Jul 2012

    Posted 30 Jul 2012 Link to this post

    Hi all,

    Do you have ideas, how to align  text in legend, when you have text format like {text} {value}(you can find details 
    in attached image)?

    This is simple code, how I create and fill values 
    foreach(PieChartItem item in PieChartItemCollection)
                    ChartSeriesItem chartItem = item.ChartItem;
                    chartItem.Label.TextBlock.Text = String.Format
                                    "{0} {1}"
                                    , str1
                                    , str2

    Please advice.

  2. Rosko
    Rosko avatar
    137 posts

    Posted 02 Aug 2012 Link to this post

    Hi Pavlo,

    Please, check the code snippet below to see how you can achieve the desired effect. The PadRight() method aligns to the left the string by adding the necessary number of spaces until the the total number of characters is 15. If the initial string is, for example, 5 characters long, this method will add 10 spaces on the right of the string. As you already understand, the PadLeft() method does the same but in the other direction. I hope this will help you to achieve the desired result.
    foreach (PieChartItem item in PieChartItemCollection)
       ChartSeriesItem chartItem = item.ChartItem;
       chartItem.Label.TextBlock.Text = str1.PadRight(15) + str2.PadLeft(15);

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top