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

Set filtered items for series

1 Answer 69 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Ion
Top achievements
Rank 1
Ion asked on 12 Nov 2013, 02:36 PM
Hello,

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
                            }) 
            .ToList();
            chart.PlotArea.Series.Clear();
            foreach (var equipment in source.Select(src => src.Name).Distinct())
            {
                var equipmentLineSeries = new LineSeries
                                       {
                                           DataField = "Value",
                                           Name = equipment,
                                       };
                chart.PlotArea.Series.Add(equipmentLineSeries);
            }
            chart.DataSource = source;
            chart.DataBind();

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?

Thanks, 
Ion

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 14 Nov 2013, 02:31 PM
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.

Regards,
Danail Vasilev
Telerik
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.
Tags
Chart (HTML5)
Asked by
Ion
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or