This is a migrated thread and some comments may be shown as answers.
Pie Chart Legends
9 Answers 144 Views
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 06 Dec 2012, 09:46 AM
I understand you have made automatic legends now work 

http://www.telerik.com/help/winforms/chartview-features-legend.html

How do I get this to work in Silverlight

<telerik:RadPieChartx:Name="PieChartStockValue"Palette="Metro">

                        <telerik:PieSeries  ShowLabels="True"RadiusFactor="0.7"ValueBinding="StockValue"ItemsSource="{Binding}">

                            <telerik:PieSeries.LabelDefinitions>

                                <telerik:ChartSeriesLabelDefinitionMargin="-30,0,0,0"/>

                            </telerik:PieSeries.LabelDefinitions>

                            <telerik:PieSeries.AngleRange>

                                <telerik:AngleRange  SweepAngle="360"/>

                            </telerik:PieSeries.AngleRange>

                        </telerik:PieSeries>

                    </telerik:RadPieChart>

9 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 11 Dec 2012, 09:48 AM
Hi Andy,

The Legend feature is currently available only for the WinForms version of the ChartView. We are planning to add support for integrated ChartLegend control with the Q1 2013 release to the WPF/Silverlight versions. 

Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tim
Top achievements
Rank 1
answered on 02 Jan 2013, 01:58 PM
Hi Petar,

this is an important feature! Is there already a date for the Q1 2013 release?
Thanks a lot and a happy new year,
Tim.
0
Petar Kirov
Telerik team
answered on 04 Jan 2013, 04:42 PM
Hi Tim,

The Q1 2013 version of our controls is expected to be released in mid-February.
 
Kind regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tim
Top achievements
Rank 1
answered on 21 Feb 2013, 11:00 AM
Hello! Good to hear that Q1 2013 was released! Unfortunately there are currently no release notes available! Do we now have pie chart legends?

Thanks a lot and cheers,
Tim.
0
Petar Kirov
Telerik team
answered on 26 Feb 2013, 12:25 PM
Hi Tim,

Here you can find the release notes for the last release.

Basically this how the RadLegend can be used:
<Grid>
  <telerik:RadPieChart x:Name="chart" Palette="Windows8"
                HoverMode="FadeOtherItems">
      <telerik:PieSeries>
          <telerik:PieSeries.LegendSettings>
              <telerik:DataPointLegendSettings />
          </telerik:PieSeries.LegendSettings>
          <telerik:PieSeries.DataPoints>
              <telerik:PieDataPoint Value="5" Label="Item 1"/>
              <telerik:PieDataPoint Value="3" Label="Item 2"/>
              <telerik:PieDataPoint Value="8" Label="Item 3"/>
              <telerik:PieDataPoint Value="1" Label="Item 4"/>
              <telerik:PieDataPoint Value="12" Label="Item 5"/>
          </telerik:PieSeries.DataPoints>
      </telerik:PieSeries>
  </telerik:RadPieChart>
     
  <telerik:RadLegend Items="{Binding ElementName=chart, Path=LegendItems}"
               HorizontalAlignment="Left" VerticalAlignment="Top"
               HoverMode="FadeOtherItems"/>     
</Grid>

I have attached a screenshot of the result, where you can see how the hover mode FadeOtherItems works across the two controls.
 
All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tim
Top achievements
Rank 1
answered on 28 Feb 2013, 06:41 AM
Hi Petar,

that's good news! Thanks a lot for your update and the detailed answer!
Cheers,
Tim.
0
Goran
Top achievements
Rank 1
answered on 06 Mar 2013, 03:20 PM
Hi Petar,

it seems that synchronization is not working properly. Example:

<telerik:RadPieChart x:Name="chart">
  <telerik:PieSeries ItemsSource="{Binding List}"
                         ShowLabels="False"
                         SliceStyleSelector="{StaticResource pieSliceStyleSelector}"
                         ValueBinding="Value">
    <telerik:PieSeries.LegendSettings>
      <telerik:DataPointLegendSettings />
    </telerik:PieSeries.LegendSettings>
  </telerik:PieSeries>
</telerik:RadPieChart>
<telerik:RadLegend Grid.Column="1"
                   BorderBrush="{StaticResource dialogItemBackground}"
                   BorderThickness="1"
                   Items="{Binding LegendItems, ElementName=chart}"
                   ItemTemplate="{StaticResource legendItemTemplate}" />

and legend item template

<DataTemplate x:Key="legendItemTemplate">
  <StackPanel Orientation="Horizontal">
    <Border Background="{Binding Presenter.DataItem.Color, Mode=OneWay, Converter={StaticResource chartItemColorToBrushConverter}}" Width="10" Height="10" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center" />
    <TextBlock Text="{Binding Presenter.DataItem.Label, Mode=OneWay}" />
  </StackPanel>
</DataTemplate>

I tried to keep things simple here and clear, so the reason why I am using Color property and color to brush converter (not to involve item types). List can contain variable number of items, and with different labels. This means that na new list can be recreated, which will contain new values. PieChart has no problem displaying the new values, but Radlegend behaves strangely. Example:

List = new ObservableCollection<ChartEntity>();
List.Add(new ChartEntity { Label = "ItemA", Value = 10, Color = Colors.Green }),
List.Add new ChartEntity { Label = "ItemB", Value = 6, Color = Colors.Orange });

Both Pie and Legend show two slices, ItemA is displayed in Green color, Iteb in Orange color. All is OK. Then we update the list:

List = new ObservableCollection<ChartEntity>();
// or List.Clear();
List.Add(new ChartEntity { Label = "ItemC", Value = 15, Color = Colors.Gray }),

On Pie, there is only one item displayed (ItemC), in Gray color - correct. Legend still shows two items, named ItemC and ItemB (!). The color for ItemC is.gray.

Why RadLegend at this point does not show  only ItemC, as Pie does, but also shows ItemB?

Regards,
Goran
0
Petar Kirov
Telerik team
answered on 11 Mar 2013, 02:41 PM
Hi Goran,

I have managed to reproduce this bug. I have logged it in our Public Issue Tracker on this link. There you can vote the PITS item and follow its progress.

Thanks for reporting. I have updated your Telerik points.
 
Kind regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Vlad
Top achievements
Rank 1
answered on 19 Mar 2013, 11:51 AM
If you need a temporary workaround you can do LegendItems.Clear() on PieChart object when you need to change ItemSource PieChart's series.
Asked by
Andrew
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Tim
Top achievements
Rank 1
Goran
Top achievements
Rank 1
Vlad
Top achievements
Rank 1
Share this question
or