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

Text in Legend being cut off.

1 Answer 106 Views
Chart
This is a migrated thread and some comments may be shown as answers.
GPJ
Top achievements
Rank 1
GPJ asked on 29 Apr 2009, 03:44 PM
The bottom of the text strings in my pie chart legend is being cut off....  Not sure why since I am just using the basic styles.

XAML

            <telerik:RadChart x:Name="ProgressChart"
                              Margin="4,8,4,4"
                              VerticalAlignment="Stretch"
                              HorizontalAlignment="Stretch">
                <telerik:RadChart.Background>
                    <SolidColorBrush Color="Transparent"/>
                </telerik:RadChart.Background>
            </telerik:RadChart>

Code Behind

            ProgressChart.Visibility = Visibility.Visible;
            ProgressChart.DefaultView.ChartArea.DataSeries.Clear();

            var areaSeries = new DataSeries {Definition = new PieSeriesDefinition()};

            areaSeries.LegendLabel = "test";
            areaSeries.Definition.ShowItemLabels = true;

            areaSeries.Add(new DataPoint(_dataList.Completed, _dataList.Completed));
            areaSeries.Add(new DataPoint(_dataList.Incomplete, _dataList.Incomplete));

            areaSeries[0].LegendLabel = "Completed";
            areaSeries[1].LegendLabel = "Incomplete";
            ProgressChart.DefaultView.ChartArea.DataSeries.Add(areaSeries);


1 Answer, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 30 Apr 2009, 09:56 AM
Hello Greg Peter Joyal,

Unfortunately we must admit this is a bug within the legend item control template. We have added this issue to our bugtracking system and we will make sure it is fixed for the next official release of the control. As a workaround for the moment we can suggest you to use the following template for the legend item (applied via setting ChartLegend.LegendItemStyle property in code-behind):

XAML
<control:RadChart x:Name="ProgressChart"
    <control:RadChart.Resources> 
        <Style TargetType="chart:ChartLegendItem"
            <Setter Property="Template"
                <Setter.Value> 
                    <ControlTemplate TargetType="chart:ChartLegendItem"
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top"
                            <Grid.ColumnDefinitions> 
                                <ColumnDefinition Width="Auto" /> 
                                <ColumnDefinition /> 
                            </Grid.ColumnDefinitions> 
 
                            <Rectangle x:Name="PART_LegendItemMarker" 
                            Height="15"  
                            Width="30" 
                            StrokeThickness="2" 
                            RadiusX="2" 
                            RadiusY="2" 
                            HorizontalAlignment="Left"  
                            VerticalAlignment="Bottom" 
                            Margin="0,0,0,5" 
                            Style="{TemplateBinding ItemStyle}" /> 
 
                            <TextBlock Grid.Column="1" 
                            Padding="0" 
                            Margin="5,5,5,5" 
                            VerticalAlignment="Center" 
                            Foreground="White" 
                            Text="{TemplateBinding Label}" /> 
                        </Grid> 
                    </ControlTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 
    </control:RadChart.Resources> 
</control:RadChart> 


C#
DataSeries series = new DataSeries(); 
series.Definition = new PieSeriesDefinition(); 
series.Add(new DataPoint(40)); 
series.Add(new DataPoint(21)); 
 
series[0].LegendLabel = "Completed"
series[1].LegendLabel = "Incomplete"
 
ProgressChartProgressChart.DefaultView.ChartLegend.LegendItemStyle = ProgressChart.Resources["CustomLegendItemStyle"] as Style; 
 
ProgressChart.DefaultView.ChartArea.DataSeries.Add(series); 


Hope this helps. We have updated your Telerik points for the report as well.


Kind regards,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Chart
Asked by
GPJ
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Share this question
or