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

Suggestion how to make Model for Reporter Graphs

1 Answer 42 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 23 Jun 2016, 05:51 AM

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;
            }
        }
    }
    

 

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 27 Jun 2016, 01:04 PM
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
Tags
Report Designer (standalone)
Asked by
Richard
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or