CategoricalSeriesDescriptor causes Chartview failure

5 posts, 1 answers
  1. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 07 Dec 2013 Link to this post




    I cannot get a simple RadCartesianChart to display when setting the style for a CategoricalSeriesDescriptor.  I have a simple one window WPF app (I can send the project if you wish). The project has a folder called "Blah" in which the Telerik.Windows.Controls.xaml and Telerik.Windows.Controls.Chart.xaml Windows8 resource dictionaries are located (both with build action of Page). The Telerik binaries that are referenced by the project are the latest noxaml versions.



    If I remove the style for the CategoricalSeriesDescriptor.Style, the chart shows as expected. If I add the style, the project will build and run, but, the chart will not draw, and the message "No data to plot" is displayed. The output shows no exceptions. 



    Also, when I edit the XAML, no errors are displayed in the XAML editor in VS. However, as soon as I build, the XAML editor underlines (in blue) the entire CategoricalSeriesDescriptor element. The tooltip error message for that element is 'The value "Telerik.Windows.Controls.ChartView.CategoricalSeriesDescriptor" is not of type "Telerik.WIndows.Controls.ChartView.ChartSeriesDescriptor" and cannot be used in this generic collection. Parameter name: value'



    Further, if I remove the style completely, the XAML editor complains about the properties like ItemsSourcePath and TypePath. But without the style, the project runs and the chart is displayed. 



    Please help me figure out what I'm doing wrong.  Is it something to do with the resource dictionaries & usage of the noxaml assemblies?  The rest of the code is basically straight out of the examples & it's driving me crazy :(.



    Thanks - Mitch



    The XAML for the windows is:

    <Window x:Class="Chart3.MainWindow"
            Title="MainWindow" Height="350" Width="525">
     
        <Window.Resources>
     
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/Chart3;component/Blah/Telerik.Windows.Controls.xaml"/>
                    <ResourceDictionary Source="pack://application:,,,/Chart3;component/Blah/Telerik.Windows.Controls.Chart.xaml"/>
                </ResourceDictionary.MergedDictionaries>
     
            </ResourceDictionary>
        </Window.Resources>
     
        <Grid>
            <telerik:RadCartesianChart x:Name="chart">
                <telerik:RadCartesianChart.HorizontalAxis>
                    <telerik:DateTimeCategoricalAxis/>
                </telerik:RadCartesianChart.HorizontalAxis>
     
                <telerik:RadCartesianChart.VerticalAxis>
                    <telerik:LinearAxis/>
                </telerik:RadCartesianChart.VerticalAxis>
     
                <telerik:RadCartesianChart.SeriesProvider>
                    <telerik:ChartSeriesProvider
                        Source="{Binding Series}">
     
                        <telerik:ChartSeriesProvider.SeriesDescriptors>
     
                            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="MyData"
                                CategoryPath="Category"
                                ValuePath="Value"
                                TypePath = "SeriesType">
     
                                
                                <telerik:CategoricalSeriesDescriptor.Style>
                                    <Style TargetType="{x:Type telerik:LineSeries}">
                                        <Setter Property="StrokeThickness" Value="8"/>
                                    </Style>
                                </telerik:CategoricalSeriesDescriptor.Style>
                                 
                            </telerik:CategoricalSeriesDescriptor>
                        </telerik:ChartSeriesProvider.SeriesDescriptors>
     
                    </telerik:ChartSeriesProvider>
                </telerik:RadCartesianChart.SeriesProvider>
     
     
            </telerik:RadCartesianChart>
        </Grid>
    </Window>


    and the code behind that populates the data, etc. is:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Collections.ObjectModel;
    using Telerik.Charting;
    using Telerik.Windows.Controls.ChartView;
     
    namespace Chart3
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                this.DataContext = this;
     
                this.Series = new ObservableCollection<ChartSeries>();
                 
                //add some data.
                ChartSeries series = new ChartSeries();
     
                MyPoint dp = new MyPoint();
                dp.Value = 10;
                dp.Category = DateTime.Now;
                series.MyData.Add(dp);
     
                dp = new MyPoint();
                dp.Value = 40;
                dp.Category = DateTime.Now.AddMonths(2);
                series.MyData.Add(dp);
     
                dp = new MyPoint();
                dp.Value = 20;
                dp.Category = DateTime.Now.AddMonths(3);
                series.MyData.Add(dp);
     
                this.Series.Add(series);
            }
     
            public ObservableCollection<ChartSeries> Series
            {
                get;
                set;
            }
        }
     
        public class ChartSeries
        {
            public ChartSeries()
            {
                this.MyData = new ObservableCollection<MyPoint>();
                this.SeriesType = typeof(LineSeries);
            }
     
            public Type SeriesType { get; set; }
     
            public ObservableCollection<MyPoint> MyData
            { get; set; }
        }
     
        public class MyPoint
        {
            public object Category { get; set; }
            public double? Value { get; set; }
        }
    }


  2. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 07 Dec 2013 Link to this post

    I removed the resource dictionaries, removed the references to the noxaml Telerik assemblies & add refrences to the Telerik assemblies installed in the GAC. I did not encounter any problems with that arrangement.  Is there a problem with the noxaml assemblies, or am I not doing something appropriately regarding those assemblies?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Stephen
    Stephen avatar
    1 posts
    Member since:
    Dec 2013

    Posted 09 Dec 2013 Link to this post

    I have the same problem. I've followed the examples very closely and I get the same message in the chart area. If I stop specifying the style then I get the default bar chart with my data shown correctly so the rest of the configuration must be OK.

    I am also using the NoXaml libraries so I wonder whether I am missing a reference to a xaml style somewhere. I do not want to use the GAC versions since we have customised one of the other telerik styles and may do so more in future.

    We are still evaluating the Telerik library before purchase so an answer to this would be helpful!
  5. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 11 Dec 2013 Link to this post

    Hello Mitchell,

    I noticed the reason that the series are not displayed. You need to have in mind that when using our NoXaml binaries you need to base your custom Styles on our ones. In your case you need to define your custom Style like this:

    ...
    <telerik:CategoricalSeriesDescriptor.Style>
                                    <Style TargetType="telerik:LineSeries" BasedOn="{StaticResource LineSeriesStyle}">
    ...
    Please give this approach a try and let us know if you need any further assistance.


    @Stephen,

    Please note that by using our NoXaml binaries you need to make sure that the full Template of the control is properly defined (not only some of the properties). In your case it is most likely that your custom Style is not based on our default, also.

    For more information regarding our theming mechanism you can refer to this article. I hope this is information is helpful.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Mitchell
    Mitchell avatar
    45 posts
    Member since:
    Mar 2013

    Posted 12 Dec 2013 Link to this post

    That makes sense.  I'll give it a try & respond to this thread if that solves my issues.  Thanks!
Back to Top
UI for WPF is Visual Studio 2017 Ready