Set filtered items for series

2 posts, 0 answers
  1. Ion
    Ion avatar
    1 posts
    Member since:
    Nov 2013

    Posted 12 Nov 2013 Link to this post


    I have a Q3 2012 HtmlRadChart, trying to bind it with List<> values. A list item object has properties CreatedDate, Name and Value. I want to display CreatedDate on XAxis, Name as legend and Value as series. Code:

    var source = (from r in readData join sen in equipments on r.EquipmentId equals sen.Id
                              select new
                                    Id = r.Id,
                                    CreatedDate = r.CreatedDate,
                                    Value = r.Value,
                                    Name = sen.Name,
                                    EquipmentId = sen.Id
                foreach (var equipment in source.Select(src => src.Name).Distinct())
                    var equipmentLineSeries = new LineSeries
                                               DataField = "Value",
                                               Name = equipment,
                chart.DataSource = source;

    The problem is that chart does not "filter" values, and displays all values for every Name in the names list, overriding the other series displayed.
    As you can see in attachment, I have 13 values for all 3 Names (PT206, PT208, PT205) and all of them are displayed for every Name, thus, lines are overriten by each other.
    How can I filter data source by names, to display the series correctly?

  2. Danail Vasilev
    Danail Vasilev avatar
    1476 posts

    Posted 14 Nov 2013 Link to this post

    Hello Ion,

    It seems that DataField property (this property is called DataFieldY now) for each LineSeries refers to the same data source "Value" column. I can suggest that you create different columns in the data source, for example "Value1", "Value2" and "Value3 "and refer them by each series.

    Note also that in older versions of RadHtmlChart date axis is not supported and therefore custom manipulations with the XAxis items are required in order to display dates there. More information on the matter is available in this help article.

    You may also find useful the HtmlChart - Date Axis and HtmlChart - List Of Custom Objects online demos that sheds more light on configuring date axis and databinding.

    Danail Vasilev
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top