Suggestion how to make Model for Reporter Graphs

2 posts, 0 answers
  1. Richard
    Richard  avatar
    1 posts
    Member since:
    Dec 2015

    Posted 23 Jun Link to this post

    Any help or suggestion highly appreciated as I am stuck on something that should be simple to fix.

     

    My application in summary has a person with properties (Name, Age, height, etc...). Also arrays of ushort or double that represent pressure waveforms. I wish to put this data onto a report for printing to PDFs.

     

    I can successfully create a custom assembly and load it in the standalone ReportDesiger and it successfully fetches the data for the report for a single person. I can put the properties for the Name, Age, Height etc. on the report.

     

    What I have not been able to do is present the array data in a form that can be consumed successfully by the report Graph.

     

    Can someone please point me to an existing sample or suggestions on what classes I should copy the graph data into for it to then be usable in the Report Graph. I was expecting to use a scatter line graph as the Y axis doubles representing values in the range 0 to 300. The x axis is time. Some graphs are short duration (0.3 seconds), some are longer at around 10 seconds (2048 sample points).

     

    A simplified model for testing purposes though might be as follows. You can see I have tried two different ways to represent the X & Y coordinates on the graph. In the final solution would only need one way, whatever that may be that makes report Graph work. 

     

    public class ReportModel
        {
            public string Fullname { get; set; }

            public double[] X { get; set; }
            public double[] Y { get; set; }

            public List<Point> GraphPoints { get; set; }

            public ReportModel()
            {
                Fullname = "John Doe";
                X = new double[] { 1, 2, 3, 4, 5, 6, 7 };
                Y = new double[] { 2, 4, 6, 8, 10, 12, 14 };

                GraphPoints = new List<Point>();
                for(int i = 0; i<X.Length; i++)
                {
                    Point p = new Point();
                    p.X = X[i];
                    p.Y = Y[i];            }
            }
        }

        public class Point
        {
            double x;
            double y;

            public double X
            {
                get
                {
                    return x;
                }

                set
                {
                    x = value;
                }
            }

            public double Y
            {
                get
                {
                    return y;
                }

                set
                {
                    y = value;
                }
            }
        }
        

     

  2. Katia
    Admin
    Katia avatar
    309 posts

    Posted 27 Jun Link to this post

    Hi Richard,

    Note, that if Graph's DataSource is set to ReportModel object inner properties of Point instances will not be accessible as we do not drill down into the hierarchy.

    To access inner properties (X and Y) of GraphPoints collection you need to set report's DataSource to ReportModel object and Graph's DataSource directly to GraphPoints collection using bindings, for example:
    Property path: DataSource
    Expression: = Fields.GraphPoints

    You can check How to Databind to Collection Properties kb article that provides more detailed information about this approach.


    Regards,
    Katia
    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. DevCraft banner
Back to Top