A walktrough of how to configure a line Graph in report designer with data provided at runtime

2 posts, 0 answers
  1. Bartosz
    Bartosz avatar
    3 posts
    Member since:
    Jul 2015

    Posted 24 May 2018 Link to this post

    Hi,

    I have a hard time trying to configure a Graph with line series in the stand alone Report Designer.
    I need a simple chart with one or more line series. The line series are Numerical on both axes (it's a temperature (X) vs value (Y) plot).

    The data for the Graph will be provided at runtime.

    My data source format is thus:

    ```
    class Data

    {
       List<double> Temperature {g;s;}
       List<double> Value {g;s}
    }

    ```

    I was able to 'import' the dll to the designer and the data source was set up correctly (I know this because I'm able to use other data sources to successfully populate other elements of the report).

    ----------------------------------

    What I did so far?

    * I inserted a new line graph into the report
    * I tried setting the Category to Temperature and Value to Value in the Wizard
    * I named the graph to be able to find it at runtime and set it's DataSource
    * In various attempts to configure the graph I tried setting the X and Y axes of the Graph to Numerical type or X to Category and Y to Numerical (I get the legend and axes preview in the designer)
    * At runtime I set the DataSource of the Graph the same way as DataSource of a Table (which works ok for the table): `((Graph)(report.Items.Find("nameOfGraph", true)[0])).DataSource = dataSourceObject;`

     

    The problem I have is that there are no series in the generated report in the Graph while other parts of the report are populated correctly.

     

    Could you please provide me with a walktrough of how to configure a line Graph in Report Designer with the assumption that the data will be provided at runtime?

     

    Thanks!

  2. Todor
    Admin
    Todor avatar
    297 posts

    Posted 29 May 2018 Link to this post

    Hi Bartosz,

    The issue might be related to the structure of the Data class. Currently it has two fields each of which is a collection.
    Each of those fields can be a data source itself. However, they cannot be used together as X and Y value for a single graph series.

    I have attached a sample project based on the approach you have described. Note that the Data class is a List of DataModel and DataModel exposes the two properties that are used as Fields for the Graph.
    In the sample the DataSource of the Table and the Graph can be set runtime choosing between two approaches - with and without an ObjectDataSource component. The first approach allows for setting the count of displayed items through a Report Parameter.

    Regards,
    Todor
    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
Back to Top