CustomGridLine is not display correct with CustomStyle for more than one CustomGridLine

3 posts, 0 answers
  1. alizator
    alizator avatar
    12 posts
    Member since:
    Oct 2011

    Posted 03 Feb 2012 Link to this post

    Hello,

    I make a small project the demonstrate a possible issue: If i try to add more than one CustomGridLine with custom style is no longer working for the second, third,.... CustomGridLine added

    Is there a posibility to have more than one CustomGridLine with custom style?

    The xaml file:
    <UserControl
        x:Class="Telerik.Windows.Examples.Chart.Gallery.StackedSpline.Example"
        xmlns:vm="clr-namespace:Telerik.Windows.Examples.Chart.Gallery.ViewModel"
        xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
        xmlns:chart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
        xmlns:charting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting">
        <UserControl.DataContext>
            <vm:UserDataViewModel ItemsCount="8" SeriesCount="2" />
        </UserControl.DataContext>
        <UserControl.Resources>
            <Style x:Key="CustomGridLineStyle"
                TargetType="Line">
                <Setter Property="StrokeDashArray"
                    Value="1,1" />
            </Style>
        </UserControl.Resources>
     
        <Border telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True">
            <chart:RadChart x:Name="RadChart1" ItemsSource="{Binding CollectionData}">
                <chart:RadChart.SeriesMappings>
                    <charting:SeriesMapping LegendLabel="Stacked Spline 1" CollectionIndex="0">
                        <charting:SeriesMapping.SeriesDefinition>
                            <charting:StackedSplineSeriesDefinition />
                        </charting:SeriesMapping.SeriesDefinition>
                        <charting:ItemMapping DataPointMember="YValue" />
                    </charting:SeriesMapping>
                    <charting:SeriesMapping LegendLabel="Stacked Spline 2" CollectionIndex="1">
                        <charting:SeriesMapping.SeriesDefinition>
                            <charting:StackedSplineSeriesDefinition />
                        </charting:SeriesMapping.SeriesDefinition>
                        <charting:ItemMapping DataPointMember="YValue" />
                    </charting:SeriesMapping>
                </chart:RadChart.SeriesMappings>
     
                <chart:RadChart.DefaultView>
                    <charting:ChartDefaultView>
     
                        <charting:ChartDefaultView.ChartArea>
                             
                            <charting:ChartArea>
                                <charting:ChartArea.Annotations>
                                    <charting:CustomGridLine YIntercept="3"
                                                    Stroke="Red"
                                                    StrokeThickness="2"
                                                    ElementStyle="{StaticResource CustomGridLineStyle}" />
                                    <charting:CustomGridLine YIntercept="4"
                                                    Stroke="Red"
                                                    StrokeThickness="2"
                                                    ElementStyle="{StaticResource CustomGridLineStyle}" />
                                </charting:ChartArea.Annotations>
                            </charting:ChartArea>
                        </charting:ChartDefaultView.ChartArea>
                        <charting:ChartDefaultView.ChartLegend>
                            <charting:ChartLegend Name="legend" ReverseLegendItemsOrder="True" />
                        </charting:ChartDefaultView.ChartLegend>
                    </charting:ChartDefaultView>
                </chart:RadChart.DefaultView>
            </chart:RadChart>
        </Border>
    </UserControl>

    The model:
    using System.Collections.Generic;
     
    namespace Telerik.Windows.Examples.Chart.Gallery.ViewModel
    {
        public class UserDataViewModel
        {
            private IList<IEnumerable<double>> _data;
            private int _itemsCount;
            private int _seriesCount;
     
            public IList<IEnumerable<double>> CollectionData
            {
                get
                {
                    if (this._data == null)
                    {
                        this._data = this.FillSampleChartData();
                    }
     
                    return this._data;
                }
            }
     
            public IEnumerable<double> Data
            {
                get
                {
                    return this.CollectionData[0];
                }
            }
     
            public int ItemsCount
            {
                get
                {
                    return _itemsCount;
                }
                set
                {
                    _itemsCount = value;
                }
            }
     
            public int SeriesCount
            {
                get
                {
                    return _seriesCount;
                }
                set
                {
                    _seriesCount = value;
                }
            }
     
            protected virtual IList<IEnumerable<double>> FillSampleChartData()
            {
                List<IEnumerable<double>> itemsSource = new List<IEnumerable<double>>();
     
                itemsSource.Add(new List<double>(){1,2,3,});
                itemsSource.Add(new List<double>() { 2, 4, 6});
                itemsSource.Add(new List<double>() { 1, 3, 5 });
                 
                return itemsSource;
            }
        }
    }

    The same behaviour if you use CustomLine instead of CustomGridLine!

    Thank You!
  2. Sia
    Admin
    Sia avatar
    667 posts

    Posted 07 Feb 2012 Link to this post

    Hello,

    The same behavior can be observed with a Line element and the following style:
    <Style x:Key="Custom" TargetType="Line">
        <Setter Property="StrokeDashArray" Value="2 2" />
    </Style>

    For more information, please check this thread. As a solution I can suggest to create a new style per grid line (or recreate the same sealed style).

    Regards,
    Sia
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. alizator
    alizator avatar
    12 posts
    Member since:
    Oct 2011

    Posted 08 Feb 2012 Link to this post

    Hello,

    I create a new style per grid line and now is ok.

    Thank You!
Back to Top