LineSeries Stroke color is ignored

2 posts, 0 answers
  1. Alex
    Alex avatar
    13 posts
    Member since:
    Jun 2011

    Posted 01 Feb 2013 Link to this post

    LineSeries Stroke color is ignored if RadCartesianChart is used in the DataTemplate.
    In the example below both charts should look identical.
    Telerik.Windows.Controls.Chart.dll version 2012.3.1129.40

    public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                Charts = new ObservableCollection<ChartItemsHolder>();
                Chart = new ChartItemsHolder();
                Chart.Items = new ObservableCollection<ChartItem>();
                for (int j = 0; j < 10; j++)
                {
                    Chart.Items.Add(new ChartItem() { Value1 = 20 * j, Value2 = DateTime.Now.Ticks * j });
                }
                Charts.Add(Chart);
                DataContext = this;
     
            }
     
            public ObservableCollection<ChartItemsHolder> Charts { get; set; }
            public ChartItemsHolder Chart { get; set; }
        }
     
        public class ChartItemsHolder
        {
            public ObservableCollection<ChartItem> Items { get; set; }
        }
     
        public class ChartItem
        {
            public DateTime TimeStamp { get; set; }
            public double Value1 { get; set; }
            public double Value2 { get; set; }
        }

    <Grid>
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition />
        </Grid.RowDefinitions>
        <TabControl Grid.Row="0" ItemsSource="{Binding Charts, Mode=OneWay}">
          <TabControl.ContentTemplate>
            <DataTemplate>
              <chart:RadCartesianChart Grid.Column="3" EmptyContent="">
                <chartView:LineSeries Stroke="Red" ValueBinding="Value1" ItemsSource="{Binding Items}">
                  <chartView:LineSeries.VerticalAxis>
                    <chartView:LinearAxis Title="Value1" LabelFormat="F2"
                                          ElementBrush="Red"
                                          HorizontalLocation="Right" />
                  </chartView:LineSeries.VerticalAxis>
                </chartView:LineSeries>
                <chartView:LineSeries Stroke="Gold" ValueBinding="Value2" ItemsSource="{Binding Items}">
                  <chartView:LineSeries.VerticalAxis>
                    <chartView:LinearAxis Title="Value2" LabelFormat="F0"
                                          ElementBrush="Gold"
                                          HorizontalLocation="Left" />
                  </chartView:LineSeries.VerticalAxis>
                </chartView:LineSeries>
                <chart:RadCartesianChart.HorizontalAxis>
                  <chartView:CategoricalAxis Visibility="Collapsed" />
                </chart:RadCartesianChart.HorizontalAxis>
              </chart:RadCartesianChart>
            </DataTemplate>
          </TabControl.ContentTemplate>
        </TabControl>
         
        <chart:RadCartesianChart Grid.Row="1" EmptyContent="d" DataContext="{Binding Chart}">
          <chartView:LineSeries  Stroke="Red" ValueBinding="Value1" ItemsSource="{Binding Items}">
            <chartView:LineSeries.VerticalAxis>
              <chartView:LinearAxis Title="Value1" LabelFormat="F2"
                                    ElementBrush="Red"
                                    HorizontalLocation="Right" />
            </chartView:LineSeries.VerticalAxis>
          </chartView:LineSeries>
          <chartView:LineSeries  Stroke="Gold"  ValueBinding="Value2" ItemsSource="{Binding Items}">
            <chartView:LineSeries.VerticalAxis>
              <chartView:LinearAxis Title="Value2" LabelFormat="F0"
                                    ElementBrush="Gold"
                                    HorizontalLocation="Left" />
            </chartView:LineSeries.VerticalAxis>
          </chartView:LineSeries>
          <chart:RadCartesianChart.HorizontalAxis>
            <chartView:CategoricalAxis Visibility="Collapsed" />
          </chart:RadCartesianChart.HorizontalAxis>
        </chart:RadCartesianChart>
      </Grid>

  2. Missing user
    Missing user avatar

    Posted 05 Feb 2013 Link to this post

    Hi Alex,

    The issue you've encountered is a known one and it is expected to be fixed in time for the next major release (later this month).

    In the meantime, as a workaround, you can try wrapping the chart inside a user control:
    <UserControl x:Class="WpfApplication1.Chart"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <telerik:RadCartesianChart/>
    </UserControl>


    Regards,
    Ivan N.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top