Rad Chart Legend Items Alignment and avoiding the Gradient

4 posts, 0 answers
  1. Saravanan Thiruchabai
    Saravanan Thiruchabai avatar
    11 posts
    Member since:
    Mar 2010

    Posted 12 Mar 2013 Link to this post

    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
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 13 Mar 2013 Link to this post

    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.

  3. DevCraft banner
  4. Saravanan Thiruchabai
    Saravanan Thiruchabai avatar
    11 posts
    Member since:
    Mar 2010

    Posted 13 Mar 2013 Link to this post

    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
  5. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 14 Mar 2013 Link to this post

    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.

Back to Top