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

[Solved] Ordering RadLegendControl and BarSeries cluster entries

4 Answers 129 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.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Nov 2012, 02:46 PM
Is there a way to enforce the ordering of RadLegendControl entries? I'd like the Correct category to appear first in both the bar series cluster and the legend. If the Incorrect series is first, it appears second in the chart but first in the legend. If Incorrect is second, it's second in the cluster and first in the legend order. Any advice?

<t:RadCartesianChart Width="680" Height="300" x:Name="tChart" Palette="{StaticResource CustomPalette}">

   <t:RadCartesianChart.HorizontalAxis>

      <t:LinearAxis/>

   </t:RadCartesianChart.HorizontalAxis>

   <t:RadCartesianChart.VerticalAxis>

      <t:CategoricalAxis Title="Questions"/>

   </t:RadCartesianChart.VerticalAxis>

 
   <
t:BarSeries ItemsSource="{Binding ScoreCard}" ShowLabels="True" CombineMode="Cluster" LegendTitle="Incorrect">

      <t:BarSeries.ValueBinding>

         <t:PropertyNameDataPointBinding PropertyName="Incorrect"></t:PropertyNameDataPointBinding>

      </t:BarSeries.ValueBinding>

      <t:BarSeries.CategoryBinding>

         <t:PropertyNameDataPointBinding PropertyName="Name"></t:PropertyNameDataPointBinding>

      </t:BarSeries.CategoryBinding>

    </t:BarSeries> 

    <t:BarSeries ItemsSource="{Binding ScoreCard}" ShowLabels="True" CombineMode="Cluster" LegendTitle="Correct">

       <t:BarSeries.ValueBinding>

          <t:PropertyNameDataPointBinding PropertyName="Correct"></t:PropertyNameDataPointBinding>

       </t:BarSeries.ValueBinding>

       <t:BarSeries.CategoryBinding>

          <t:PropertyNameDataPointBinding PropertyName="Name"></t:PropertyNameDataPointBinding>

       </t:BarSeries.CategoryBinding>

    </t:BarSeries>

</t:RadCartesianChart> 

 
<tpri:RadLegendControl LegendProvider="{Binding ElementName=tChart}" Margin="5" VerticalAlignment="Center">

</tpri:RadLegendControl>

4 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 30 Nov 2012, 10:03 AM
Hi Kevin,

Thank you for using our RadControls for Windows 8!

The RadLegend control provides information for its Legend Items from the Series in the order they are defined. In the current scenario the first defined Series is this with the Incorrect values(indexing begins from (0,0) point) and this behavior is expected.
However you can modify the ItemsPanelTemplate and ItemTemplate of the RadLegend control and try to get the desired result.

I hope this information is useful. Let me know if I can assist you any further.

 

All the best,
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.
0
Kevin
Top achievements
Rank 1
answered on 30 Nov 2012, 02:29 PM
Ivaylo,

Thank you for your response. I expected that the behavior of the legend control was as designed, but it seems that BarSeries clusters work in the opposite way, displaying the last defined series in a named cluster first. I want the order of the clustered series in the chart to match the order of the series names in the legend.

To my mind, the behavior of the RadLegendControl is correct and expected, but the behavior of the  RadCartesianChart with a clustered BarSeries seems odd and unexpected. I don't much care which control I need to monkey with as long as I can get the look I want.

Do you have any guidance on the best way to do this? Do I need to provide more information?
0
Accepted
Ivaylo Gergov
Telerik team
answered on 05 Dec 2012, 02:05 PM
Hello Kevin,

Thank you for getting back to us.

In order to achieve this scenario I suggest you to create a custom class that implements the ILegendInfoProvider interface (RadCartesianChart implements it as well) and pass your custom provider to the legend control instead of the chart instance.

For your convenience I have attached a sample application that simply reverses the collection of the original chart legend items.

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

 

Regards,
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.
0
Kevin
Top achievements
Rank 1
answered on 05 Dec 2012, 10:03 PM
Thanks, I'll take a look at your solution!
Tags
Chart for XAML
Asked by
Kevin
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or