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

the ChartLegend items can not be displayed!

2 Answers 135 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 26 Oct 2010, 09:31 AM
hello,

I am learning RadChart to display a pie,when I place a RadChart and ChartLegend in RadDocking,the pie chart can be drawn,but the chartlegend items are missing!

I have built a sample application to show the bug,please help me!

Any help will be appreciated!

Jerry

Screen shot

xaml:
<Grid>
   <telerik:RadDocking Background="Transparent" d:IsHidden="True" >
         <telerik:RadSplitContainer telerik:DockingPanel.InitialSize="200,150" MaxWidth="600"
                              Name="leftContainer" InitialPosition="DockedLeft">
                <telerik:RadPaneGroup DropDownDisplayMode="Collapsed">
                    <telerik:RadPane x:Name="featurePane" Header="Featrues" >
                        <Controls:RadTreeView SelectionMode="Extended" IsLineEnabled="False"
                                                 ItemsOptionListType="CheckList"
                                                 IsOptionElementsEnabled="True"
                                                 IsRootLinesEnabled="True"
                                                 VerticalAlignment="Stretch" Margin="0"
                                                 x:Name="featureTree"
                                                 IsTriStateMode="True"
                                                 >
                        </Controls:RadTreeView>     
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
            <telerik:RadDocking.DocumentHost>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="100"/>
                        <RowDefinition Height="310*"/>
                    </Grid.RowDefinitions>
                    <Controls1:RadChart x:Name="radPipe" Grid.Row="0"
                                      UseDefaultLayout="False">
                        <Charting:ChartArea x:Name="pipeArea" >
 
                        </Charting:ChartArea>
                    </Controls1:RadChart>
 
           
                    <Controls1:RadChart x:Name="radStatistics" Grid.Row="1"
                                      UseDefaultLayout="False"
                                      BorderBrush="Transparent">
                        <Grid >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="165*" />
                                <ColumnDefinition Width="120" />
                            </Grid.ColumnDefinitions>
 
                            <Charting:ChartLegend  Grid.Column="1" Name="pieLegend"  />
                            <Charting:ChartArea x:Name="pieArea" Grid.Column="0"
                                               LegendName="pieLegend" />
 
                        </Grid>
                    </Controls1:RadChart>
                </Grid>          
            </telerik:RadDocking.DocumentHost>           
        </telerik:RadDocking>
        <Button Content="Button" Height="27" HorizontalAlignment="Left" Margin="62,105,0,0"
                Name="button1" VerticalAlignment="Top" Width="96" Click="button1_Click" />
    </Grid>


Behind code:
public partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();
 
    }
     
    private static DataSeries GetPieData()
    {
        DataSeries series = new DataSeries();
        for(int i=0;i<5;i++)
        {
            DataPoint dataPoint = new DataPoint("aa"+i, i);
            dataPoint.LegendLabel="aa"+i;
            series.Add(dataPoint);
        }
        return series;
    }
     
    private void ConfigurePie()
    {
        DataSeries doughnutSeries = GetPieData();
        doughnutSeries.LegendLabel = "Doughnut Series";
 
        doughnutSeries.Definition = new DoughnutSeriesDefinition();
        doughnutSeries.Definition.InteractivitySettings.HoverScope = InteractivityScope.Item;
        doughnutSeries.Definition.InteractivitySettings.SelectionScope = InteractivityScope.Item;
        doughnutSeries.Definition.InteractivitySettings.SelectionMode = ChartSelectionMode.Single;
 
        ((DoughnutSeriesDefinition)doughnutSeries.Definition).LabelSettings.LabelOffset = 0.8d;
        doughnutSeries.Definition.ItemLabelFormat = "#Y";
        pieArea.DataSeries.Clear();
        pieArea.DataSeries.Add(doughnutSeries);
        pieArea.SmartLabelsEnabled = true;
        pieLegend.Header = " ";
 
    }
 
 
    private void button1_Click(object sender, RoutedEventArgs e)
    {
          ConfigurePie();
    }
     
     
}

2 Answers, 1 is accepted

Sort by
0
Evgeni "Zammy" Petrov
Telerik team
answered on 28 Oct 2010, 05:44 PM
Hello Jerry,

 Here is a small change that will fix your problem:

<Charting:ChartArea x:Name="pieArea" Grid.Column="0"
          Legend="{Binding ElementName=pieLegend}" />

Instead of using the string property LegendName it should be used Legend and bind it with the legend.
LegendName is an old property that we should deprecate, it was used in older Silverlight versions.

Let me know if this worked for you.

Regards,
Evgeni "Zammy" Petrov
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
Jerry
Top achievements
Rank 1
answered on 29 Oct 2010, 02:09 AM
Great!
Thanks a lot!
Tags
Chart
Asked by
Jerry
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
Jerry
Top achievements
Rank 1
Share this question
or