Multiple line series in a subordinate (detail) Graph

3 posts, 1 answers
  1. Jeff Benson
    Jeff Benson avatar
    6 posts
    Member since:
    Apr 2010

    Posted 30 Oct 2018 Link to this post

    I was tasked with prototyping a new Telerik report using version 2018 R3 SP1 in Visual Studio 2017. I've searched the forum and the web but so far have not found a definitive answer to this question.

    The report is somewhat complicated, with several sections, but the main section was best implemented as a banded report with a Graph in the detail section. Our existing reports use ObjectDataSource objects for the DataSource and this new report will follow suit. I tried passing the banded report a C# List<PrototypeItem> instance where the classes are:

    public class PrototypeItem
    public int Id { get; set; }
    public string Location { get; set; }
    public string Name { get; set; }
    public string Type { get; set; }
    public List<NumItem> Items { get; set; }

    public class NumItem
    public DateTime X { get; set; }
    public double Y { get; set; }

    PrototypeItem.Id is used as the group property (= Fields.Id) to distinguish the report bands. I found I could create a DataSource binding for the detail Graph, which I set to = Fields.Items. I set the Graph to have a LineSeries linked to a CartesianCoordinateSystem, a SeriesGroup and a CategoryGroup. The latter group I set to have Groupings = Fields.X and Sortings = Fields.X Asc expressions. The series had X = Fields.X and Y = Fields.Y.

    When I run the report, it appears to give me the information I expect, with individual graphs having the X/Y data for the Id item in each band.

    What I would like to do now is extend this report to provide more information in the graphs. In particular, I am interested in adding a straight horizontal line (possibly several) at a value that indicates to the user when the X/Y data has exceeded a certain "alert" level. However, I can't figure out how best to do this.

    One approach I tried and found to work (albeit with limitations) was to add a another property to the NumItem class to define the "alert level". I added a second LineSeries to the Graph, linked it to the same category and series groups and defined the series X = Fields.X and Y = Fields.AlertLevel. The problem I have with this approach is that the horizontal line does not span the graph's entire X range if the main graph data does not also do so. I found that I could add two data points to the Items data list, one for the start date and another for the end date. While the alert level line spans the graph, unfortunately, this also introduces odd discontinuities in the raw data line between the end points of the graph and the first or last data points.

    Ideally, it would be best to pass two line series, one for the raw X/Y data and a second for the alert level with just two data points: start date and end date as X values and the Y values as the alert level. I cannot determine if reporting supports this sort of operation. The main problem involves the DataSource binding for the Graph. How would one define classes to and set properties to make the Graph object "aware" of two (or more) line series?

    I attempted one modification to my classes above. I changed PrototypeItem to replace List<NumItem> with a GraphData class property where:

     public class GraphData { List<NumItem> Items { get; set; } }

    and changed the Graph binding expression to be = GD.Items (instead of = Items). When I ran the report this "sort of" worked but behaved strangely: each graph displayed a data line but all the graphs were identical (rather than the individual data for each Id). This also gave no indication how to bind a second List of NumItems in GraphData to a second line series.

    I also occurred to me that I could try to create a separate report ObjectDataSource to retrieve the Graph data. However, I could not determine how to link the banded property Id to the function call so I did not attempt this.

    Any thoughts about how to extend my report graphs?


  2. Answer
    Todor avatar
    207 posts

    Posted 02 Nov 2018 Link to this post

    Hi Jeff,

    If I understood correctly, the requirement is to have one or more lines indicating threshold (alert) values, i.e. Y=const, whereas X should span a potentially wider X axis (i.e. containing also previous and next dates).
    You may achieve this by setting the Xaxis.Scale Minimum/Maximum with Bindings (see the attached screenshot). To force the alert lines to span the entire X-axis, you should change the corresponding lineSeries->LineType to Stepped. This way the lineSeries will start from the beginning of the Coordinate system and stop at its end. Note that Stepped LineType averages the data between each two points and displays a horizontal line at the computed average. This should not affect the desired behavior as the alert data is constant.

    The Graph, as each data item can have only a single DataSource.

    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Jeff Benson
    Jeff Benson avatar
    6 posts
    Member since:
    Apr 2010

    Posted 02 Nov 2018 in reply to Todor Link to this post

    Thanks, Todor.  I had already implemented the Xaxis.Scale min/max bindings you recommend, having set them to the start date and end date parameters passed to the report. It's good to know about the Stepped line type option. In my case, it does not appear to be needed since the alert Y value is, as you say, a constant. The default line type, "Straight", also produces an acceptable horizontal line.

    Thanks for confirming that Graph can only be bound to a single data source. Hopefully, that will not turn out to be a major limitation in practice.


Back to Top