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

Rad Chart Legend Items Alignment and avoiding the Gradient

3 Answers 92 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Saravanan Thiruchabai
Top achievements
Rank 1
Saravanan Thiruchabai asked on 12 Mar 2013, 08:55 PM
Hi

     I am trying to get the Legend Items aligned to the right of the Line Series Chart using the following code

                  alChart.DefaultView.ChartLegend.HorizontalAlignment = HorizontalAlignment.Right;
                  alChart.DefaultView.ChartLegend.HorizontalContentAlignment = HorizontalAlignment.Right;

     Having these two lines of code doesn't have any effect on the Legend Items Alignment. I have attached the screen shot. In the past also this was an issue. However I went with Rectangles below the chart and had my own custom Legends. This issue now returned back because when I tried to export the chart using chart.ExportToImage the custom Legend which is not part of the chart wont get exported.

Another Issue is the background of the Default Legend Item provided by Rad Chart has the Gradient component. I would like to know how to avoid the gradient so that it show up like the one I have circled in the blue.

Thanks & Best Regards
Saran

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 13 Mar 2013, 09:12 AM
Hi Saravanan,

1. To have the Legend Items being right oriented, you'll need to modify the default ChartLegend control template as follows:

<ControlTemplate TargetType="telerikCharting:ChartLegend">
    <Border Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}" >
        <Grid Margin="{TemplateBinding Padding}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <ContentControl Foreground="{TemplateBinding Foreground}"
                       HorizontalAlignment="Stretch"
                       HorizontalContentAlignment="Stretch"
                       FontWeight="{TemplateBinding HeaderFontWeight}"
                       Content="{TemplateBinding Header}"
                       ContentTemplate="{TemplateBinding HeaderTemplate}"/>
            <ItemsPresenter Grid.Row="1"
                       HorizontalAlignment="Right"
                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
    </Border>
</ControlTemplate>

2. I suggest that you place the chart and the legend in one container and simply export this container.
3. In the original LegendItem template, there are several properties like LegendItemMarkerMask, LegendItemMarkerMaskStrokeLegendItemMarkerMaskStrokeThickness that represents the opacity mask of the mask element for the ChatLegendItem's marker. Either set those brushes to Transparent and the StrokeThickness to 0 or just remove the Path that uses them from the default control template.

All the best,
Evgenia
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Saravanan Thiruchabai
Top achievements
Rank 1
answered on 13 Mar 2013, 02:11 PM
Hi Evgenia

      Thanks for your reply.
Based on your point 2 "I suggest that you place the chart and the legend in one container and simply export this container."
Is there any specific Rad Container Control which purely can be used as a container control and still give outbox option of ExportToImage like what RadChart does.

The version I am using is 2010.2.924.1040

Thanks & Best Regards
Saran
0
Evgenia
Telerik team
answered on 14 Mar 2013, 12:38 PM
Hi Saravanan,

The container can be practically any Framework element as this is what the export-to-image extensions (part of Telerik.Windows.Controls.dll) method Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(element, stream, new Telerik.Windows.Media.Imaging.PngBitmapEncoder()); would expect as first parameter. I prepared a sample that demonstrates how you may use a sample stack panel as export container.

Hope it helps.

All the best,
Evgenia
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Saravanan Thiruchabai
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Saravanan Thiruchabai
Top achievements
Rank 1
Share this question
or