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

Legends not showing up for RadChart

3 Answers 136 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 18 Oct 2010, 11:36 PM
Hi,

I am using a RadChart control with multiple RadChartAreas defined. I wanted to show individual legends belonging to each Chart area but they aren't visible. Even though I followed the examples but couldn't get the legends to display.

Here's my source code:

<telerik:RadChart x:Name="LineChartCusips" ScrollViewer.CanContentScroll="True">
                    
                    <Grid Margin="0,0,10,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="5*" />
                            <ColumnDefinition Width="2*" />                            
                        </Grid.ColumnDefinitions>
                        <telerik:ChartTitle Grid.Row="0"  
                                            Grid.ColumnSpan="2"
                                            Content="Year 2010"
                                            HorizontalAlignment="Center"                                            
                                            Style="{StaticResource CustomTitleStyle}"/>
                        
                        <telerik:ChartArea Grid.Row="1"
                                           Grid.Column="0"
                                           Grid.ColumnSpan="2"
                                           Padding="5,10,20,5"
                                           x:Name="splineChartArea"
                                           LegendName="splineLengend"                                           
                                           ItemToolTipOpening="splineChartArea_ItemToolTipOpening"/>

                        
                        <telerik:ChartTitle Grid.Row="2"
                                            Content="Monthly Distribution"
                                            Grid.ColumnSpan="2"
                                            HorizontalAlignment="Center"
                                            Style="{StaticResource CustomTitleStyle}"/>
                        
                        <telerik:ChartArea Grid.Row="3"
                                           Grid.Column="0"
                                           x:Name="barChartArea"
                                           LegendName="barLegend"
                                           ItemToolTipOpening="ChartArea2_ItemToolTipOpening"/>
                        
                        <telerik:ChartArea Grid.Row="3"
                                           Grid.Column="1"
                                           x:Name="pieChartArea"
                                           />
                      
                                                
                    </Grid>

For one of the chart areas, splineLengend, here's the code behind:
DataSeries newSeries = new DataSeries();
                newSeries.LegendLabel = tranchedata.Key.ToString();
                newSeries.Definition = new LineSeriesDefinition();
                newSeries.Definition.InteractivitySettings.HoverScope = InteractivityScope.Series;
                newSeries.Definition.InteractivitySettings.SelectionScope = InteractivityScope.Series;                
                newSeries.Definition.ShowItemLabels = true;
                newSeries.Definition.ShowItemToolTips = true;

Thanks,
Farhan

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Oct 2010, 09:43 AM
Hi Farhan,

At present, there can be a single legend per chart. Thus, the possible alternatives are:
  1. To use separate charts nested in the grid
  2. Customize the chart legend to contain different elements
  3. Use a separate legend-like panel next to the chart, with the relevant information inside. This may be something similar to this example:

    http://demos.telerik.com/silverlight/#Chart/SortFilter

    The righmost panel can contain additional information on the chart areas nested in the chart.

I hope these suggestions help.

Sincerely yours,

Yavor
the Telerik team

 

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Farhan
Top achievements
Rank 1
answered on 20 Oct 2010, 11:27 PM
Is there any way that I can show up a legend for a Chart Area? For example perhaps I could add the legend to the main chart's legend.
0
Yavor
Telerik team
answered on 25 Oct 2010, 08:38 AM
Hello Farhan,

The best option in a case like this would be to use separate charts, nested in a grid, for example. Nesting different elements in the chart legend would required retemplating it, which in some scenarios may require a lot of coding. Implementing the first approach is the most straightforward one, and can be easily used to match a flexible layout/look.
Give this approach a try and let me know how it meets your requirements.

Best wishes,
Yavor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Farhan
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Farhan
Top achievements
Rank 1
Share this question
or