This is a migrated thread and some comments may be shown as answers.

PieChart legend alignmen

1 Answer 23 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Pavlo
Top achievements
Rank 1
Pavlo asked on 30 Jul 2012, 06:37 PM
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.

Thanks,
Pavlo
 

1 Answer, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 02 Aug 2012, 08:29 AM
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,
Rosko
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.
Tags
Chart (Obsolete)
Asked by
Pavlo
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Share this question
or