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

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

2 Answers 46 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
alizator
Top achievements
Rank 1
alizator asked on 03 Feb 2012, 05:22 PM
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 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 07 Feb 2012, 02:39 PM
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 >>
0
alizator
Top achievements
Rank 1
answered on 08 Feb 2012, 10:31 AM
Hello,

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

Thank You!
Tags
Chart
Asked by
alizator
Top achievements
Rank 1
Answers by
Sia
Telerik team
alizator
Top achievements
Rank 1
Share this question
or