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

Changing StripLine styles

4 Answers 70 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Brennan
Top achievements
Rank 1
Brennan asked on 26 Jul 2011, 10:23 PM
<Setter Property="Template2D">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:ChartArea">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Background="{TemplateBinding Background}"
                            Margin="{TemplateBinding Margin}"
                            Padding="{TemplateBinding Padding}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>
                            <telerik:AxisX2D x:Name="PART_AxisX"
                                             Grid.Column="1"
                                             Grid.Row="2"
                                             Style="{TemplateBinding AxisXStyle}"
                                             AxisLineStyle="{StaticResource YGridLineStyle}" />
                            <telerik:AxisY2D x:Name="PART_AxisY"
                                             Grid.Column="0"
                                             Grid.Row="1"
                                             Style="{TemplateBinding AxisYStyle}"
                                             AxisLineStyle="{StaticResource XGridLineStyle}" />
                            <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalHorizontalAxesPanel"
                                                               Grid.Column="1"
                                                               Grid.Row="0"
                                                               StackOrientation="Vertical" />
                            <telerik:AdditionalAxes2DContainer x:Name="PART_AdditionalVerticalAxesPanel"
                                                               Grid.Column="2"
                                                               Grid.Row="1"
                                                               StackOrientation="Horizontal"
                                                               Visibility="Collapsed" />
                            <telerik:RadTransitionControl x:Name="PART_RadTransitionControl"
                                                          Grid.Column="1"
                                                          Grid.Row="1"
                                                          Style="{TemplateBinding TransitionControlStyle}">
                                <telerik:ClipPanel x:Name="PART_PlotAreaPanel"
                                                   Style="{TemplateBinding PlotAreaStyle}">
                                    <telerik:DragZoomLayerControl x:Name="PART_DragZoomLayer"
                                                                  Style="{TemplateBinding DragZoomLayerControlStyle}">
                                        <ItemsPresenter />
                                    </telerik:DragZoomLayerControl>
                                    <telerik:HorizontalStripLines2D x:Name="PART_HorizontalStripLines" />
                                    <telerik:VerticalStripLines2D x:Name="PART_VerticalStripLines" />
                                    <telerik:AnnotationLayer x:Name="PART_AnnotationLayer"
                                                             ItemsSource="{TemplateBinding Annotations}" />
                                    <telerik:VerticalMinorGridLines2D x:Name="PART_VerticalMinorGridLines" />
                                    <telerik:HorizontalMinorGridLines2D x:Name="PART_HorizontalMinorGridLines" />
                                    <telerik:HorizontalGridLines2D x:Name="PART_HorizontalGridLines" />
                                    <telerik:VerticalGridLines2D x:Name="PART_VerticalGridLines" />
                                    <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaHorizontalAxesPanel"
                                                                               StackOrientation="Vertical" />
                                    <telerik:AdditionalPlotAreaAxes2DContainer x:Name="PART_AdditionalPlotAreaVerticalAxesPanel"
                                                                               StackOrientation="Horizontal" />
 
                                    <telerik:PlotAreaAxisY2D x:Name="PART_PlotAreaAxisY"
                                                             Style="{TemplateBinding PlotAreaAxisYStyle}" />
                                    <telerik:PlotAreaAxisX2D x:Name="PART_PlotAreaAxisX"
                                                             Style="{TemplateBinding PlotAreaAxisXStyle}" />
                                    <telerik:LabelsPanel x:Name="PART_LabelsPanel" />
                                </telerik:ClipPanel>
                            </telerik:RadTransitionControl>
                            <telerik:NoDataControl x:Name="PART_NoData"
                                                   Grid.ColumnSpan="3"
                                                   Grid.RowSpan="3"
                                                   Style="{TemplateBinding NoDataControlStyle}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

Using this code I don't really understand how to set the style of the telerik:HorizontalStripLines2D... Where should the actual style for this be defined?

4 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 27 Jul 2011, 09:24 AM
Hello Brennan,

In order to get your strip-lines styled you need to set the following custom style:
<Style x:Key="CustomStripLines" TargetType="Rectangle">
    <Setter Property="Fill" Value="Red" />
</Style>

and apply it to the AxisY:
this.Chart.DefaultView.ChartArea.AxisY.AxisStyles.StripLineStyle = this.Resources["CustomStripLines"] as Style;

Regards,
Sia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Brennan
Top achievements
Rank 1
answered on 27 Jul 2011, 03:03 PM
Sorry, I should have been more specific in my question.  How would I apply the style to the X axis through XAML?  Thanks.
0
Accepted
Sia
Telerik team
answered on 27 Jul 2011, 03:12 PM
Hi Brennan,

Here it is:
<telerikChart:RadChart Name="Chart">
    <telerikChart:RadChart.DefaultView>
        <telerikCharting:ChartDefaultView>
            <telerikCharting:ChartDefaultView.ChartLegend>
                <telerikCharting:ChartLegend x:Name="ChartLegend" />
            </telerikCharting:ChartDefaultView.ChartLegend>
            <telerikCharting:ChartDefaultView.ChartArea>
                <telerikCharting:ChartArea Name="ChartArea" LegendName="ChartLegend">
                    <telerikCharting:ChartArea.AxisY>
                        <telerikCharting:AxisY>
                            <telerikCharting:AxisY.AxisStyles>
                                <telerikCharting:AxisStyles StripLineStyle="{StaticResource CustomStripLines}" />
                            </telerikCharting:AxisY.AxisStyles>
                        </telerikCharting:AxisY>
                    </telerikCharting:ChartArea.AxisY>
                    <telerikCharting:ChartArea.DataSeries>
                        <telerikCharting:DataSeries>
                            <telerikCharting:DataSeries.Definition>
                                <telerikCharting:BarSeriesDefinition  />
                            </telerikCharting:DataSeries.Definition>
                            <telerikCharting:DataPoint YValue="10" />
                            <telerikCharting:DataPoint YValue="10" />
                        </telerikCharting:DataSeries>
                    </telerikCharting:ChartArea.DataSeries>
                </telerikCharting:ChartArea>
            </telerikCharting:ChartDefaultView.ChartArea>
        </telerikCharting:ChartDefaultView>
    </telerikChart:RadChart.DefaultView>
</telerikChart:RadChart>


Best wishes,
Sia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Brennan
Top achievements
Rank 1
answered on 27 Jul 2011, 05:18 PM
Thank you so much!
Tags
Chart
Asked by
Brennan
Top achievements
Rank 1
Answers by
Sia
Telerik team
Brennan
Top achievements
Rank 1
Share this question
or