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

[Solved] PieChart - labels in stackpanel with matching colors?

3 Answers 119 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andreas
Top achievements
Rank 2
Andreas asked on 11 Dec 2012, 09:58 PM
Hello,

Wow, that's a terrible title... However, what I'm trying to ask is whether it's possible to achieve this?
([img] tags didn't work)

http://img.ctrlv.in/50c7ae1a44f72.PNG

3 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 12 Dec 2012, 08:37 AM
Hello Andreas,

You can use the RadLegendControl to achieve the desired functionality like this:
<Page
    x:Class="App2.MainPage"
    xmlns:local="using:App2"
    xmlns:telerik="using:Telerik.UI.Xaml.Controls.Chart"
    xmlns:primitives="using:Telerik.UI.Xaml.Controls.Primitives"
    xmlns:charting="using:Telerik.Charting"
    mc:Ignorable="d">
 
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
 
        <telerik:RadPieChart x:Name="RadChart1" PaletteName="DefaultDark">
            <telerik:DoughnutSeries>
                <telerik:DoughnutSeries.DataPoints>
                    <charting:PieDataPoint Value="10" Label="Customer" />
                    <charting:PieDataPoint Value="20" Label="Partner" />
                    <charting:PieDataPoint Value="30" Label="SMTP" />
                </telerik:DoughnutSeries.DataPoints>
            </telerik:DoughnutSeries>
        </telerik:RadPieChart>
 
        <primitives:RadLegendControl Grid.Column="1" LegendProvider="{Binding ElementName=RadChart1}" />
 
    </Grid>
</Page>

You can find more information on RadLegendControl here.

Hope this helps.


Regards,
Giuseppe
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Andreas
Top achievements
Rank 2
answered on 12 Dec 2012, 02:13 PM
Thanks a bunch, Giuseppe.

How could I limit the amount of legends shown vertically, and force the second row to be set like this example?
(I assume that's common XAML, but for some reason none of my attempts has worked..)

Label1     Label2
Label3     Label4
Label5     Label6

Thanks!

EDIT:
Well of course, once you've asked the question, you solve it yourself.. Thanks anyway! :)
0
Accepted
Ivaylo Gergov
Telerik team
answered on 13 Dec 2012, 09:10 AM
Hi Andreas,

Thank you for getting back to us.

In order to achieve this result you can use the RadLegendControl.ItemsPanel property and change its ItemsPanelTemplate. By default it is a WrapGrid with MaximumRowsOrColumns="3" and Orientation="Vertical" so the LegendItems are three per column. In your case you need two LegendItems per row so you need to set MaximumRowsOrColumns="2" and Orientation="Horizontal". Here's an example:
<primitives:RadLegendControl.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapGrid MaximumRowsOrColumns="2" Orientation="Horizontal"/>
    </ItemsPanelTemplate>
</primitives:RadLegendControl.ItemsPanel>

I hope this helps. Let me know if I can assist you any further.

Greetings,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Chart for XAML
Asked by
Andreas
Top achievements
Rank 2
Answers by
Giuseppe
Telerik team
Andreas
Top achievements
Rank 2
Ivaylo Gergov
Telerik team
Share this question
or