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

Show Label/Text for marked zone in Silverlight RadChart

2 Answers 97 Views
Chart
This is a migrated thread and some comments may be shown as answers.
D4
Top achievements
Rank 1
D4 asked on 29 Nov 2010, 07:35 AM
Hi,
  We are making use of telerik silverlight chart and want to show the label for marked zone as in the asp.net radChart here http://www.telerik.com/help/aspnet-ajax/understandingelementsplotareamarkedzones.html.
There is no property with the name Label for marked zone.
 Is there anyway that we can achieve this?

Thanks
Dev

2 Answers, 1 is accepted

Sort by
0
Accepted
Evgeni "Zammy" Petrov
Telerik team
answered on 01 Dec 2010, 01:44 PM
Hello Donlad,

 This is not a supported feature, however, it is easy to achieve this by retemplating the MarkedZone.
In XAML you will need to retemplate MarkedZone class:

<Style x:Key="NewMarkedZones" TargetType="telerik:MarkedZone">
    <Setter Property="Background" Value="#66666666" />
    <Setter Property="Template" >
        <Setter.Value>
            <ControlTemplate TargetType="telerik:MarkedZone">
                <Grid>
                    <Rectangle Grid.ColumnSpan="3"
                        Fill="{TemplateBinding Background}"
                       Stroke="{TemplateBinding Stroke}"
                       StrokeThickness="{TemplateBinding StrokeThickness}"
                       Margin="{TemplateBinding ElementMargin}"
                       Style="{TemplateBinding ElementStyle}" />
                    <TextBlock  Text="{Binding}" Margin="{TemplateBinding ElementMargin}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
I have marked the new part of the MarkedZone style in orange.
I added a grid layout wrapper and put a TextBlock together with the rectangle that actually displays the marked zone.

In code behind you need to add MarkedZone's new style together with a string for a DataContext. This string is bound to Text  property of TextBlock:

RC1.DefaultView.ChartArea.Annotations.Add(
           new MarkedZone(25, 50, 50000, 65000)
           {
               Style = this.LayoutRoot.Resources["NewMarkedZones"] as Style,
               DataContext = "Label text"
           }
       );

I hope this will help you out.

Kind regards,
Evgeni "Zammy" Petrov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
D4
Top achievements
Rank 1
answered on 01 Dec 2010, 02:13 PM
Thank you so much Evgeni.
Its working great.

Regards
Dev
Tags
Chart
Asked by
D4
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
D4
Top achievements
Rank 1
Share this question
or