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

Adding Graphs Dynamically

4 Answers 256 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 14 Oct 2015, 09:23 PM

Hello,

I am trying to create a set of graphs. I don't know how many graphs I will need to present at designtime (could be anywhere from 1 to 5). I first attempted to do this by adding all of the charts to the designer with their different criterias set and then hiding the ones that I didn't need at runtime, however this left me with seemingly random blank pages at the end of my report. I tried to change the report's detail height both at runtime and designtime to no avail.

Next, I took the programmatic approach. I attempted to follow the instructions here but couldn't figure out how to make this work with a pie chart - the graph would show up but the slices of data would not. I gave up on this because I figured it would be more effective to do this at designtime.

Now I'm at the designtime approach. I put the graph in a table, and I am able to repeat the graph for every row of the table, but I don't seem to be able to change any properties of the graph based on the row that it's on (I need to change the title, filter criteria, etc). There also seems to be some overlapping issues.

What is the correct way to go about this? I have read this thread (and the corresponding help articles), but the thread just isn't detailed enough for me follow, and the help articles don't give much of an explanation either.

4 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 19 Oct 2015, 03:29 PM
Hello Ryan,

You can use both approaches you tested:
  1. Add all Graph items and hide them conditionally. To shrink the container, you can use the approach from the Collapse the container when hiding child report items KB article. It will work if there is no other content beside the Graph item - Design Considerations for Report Item Layout.
  2. Add a single Graph item in a List item. The number of Graph items will be determined by the number of records in the List.DataSource.
    The Graph >Titles > Text property can be set to an expression.
    Filter expressions can be set via expression as well. For example, define the filter as follows:
    Expression: =Fields(ReportItem.DataObject.FieldX)
    Operator: <>
    Value:='test'
    The above will use the container's data FieldX value (ReportItem.DataObject) to determine which field of the Graph's DataSource to get, and will compare that field to the set Value.


About overlapping labels, please check the newly introduced labels connectors feature - How to: Setup a Pie Chart With No Overlapping Labels.


If you need further help, please elaborate on the scenario with screenshots and images of the desired layout. Feel free to open a support ticket and send us a demo project that illustrates the current settings and the data structure.

Regards,
Stef
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
0
Ryan
Top achievements
Rank 1
answered on 21 Oct 2015, 09:22 PM

Thanks for the detailed response, Stef!

1. I attempted to bind the detail section's height to 1px but failed at this (there is still a blank page at the end). I'm assuming this is because I have two tables above my graphs.

2. I actually need some grouping in the list (I have hundreds of rows but need the sums from various ones to make up a certain number of graphs). From what it looks like, it appears that grouping is not possible within a list - is this true? To work around this, I created a datatable with all of the groups that I need and assigned the list control's datasource to this datatable. Now, I'm attempting to filter the graph's data according to which row it is on in the list. My filter expression is: '= Fields.DataType = =Fields(ReportItem.DataObject.DataType)'. I'm getting this error when I load the graph: 'An error has occurred while processing Graph 'Graph1': The expression contains object '25' that is not defined in the current context.'. This error obviously repeats for each row in the list's datasource. Any idea how I can fix this?

 

And as far as the overlapping goes, I meant the graphs as a whole were overlapping when I placed my graph control inside a table. Half the graph would be covered by another graph.

Thanks!

0
Accepted
Stef
Telerik team
answered on 26 Oct 2015, 03:38 PM
Hello Ryan,

The blank page may be caused by horizontal paging which occurs when a Table/Crosstab item grows in width and cannot be gathered on a single page. The tests suggested in the Problem: Telerik Reporting renders blank pages KB article can pinpoint the item causing the issue - changing the report's PageSettings to provide more space can resolve the issue.


On your second question, The Table and List items have the same base and structure respectively. the difference is that a List item comes with nested Panel items instead of a TextBox items in cells. You can use any of both, where you will need to manually drag and drop Panel items in a Table item's cells.

On positioning the Graph item in a Panel item, verify it is fitting correctly in the boundaries of the Panel item. Then on applying the filter, create a valid expression based on the data.
  • Fields(<string>) is equivalent to an expression like Fields.<string>, where <string> stands for the name of the field.
  • ReportItem.DataObject.<field_name> gets the <field_name> value from the parent element's data.


Regards,
Stef
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
0
Ryan
Top achievements
Rank 1
answered on 27 Oct 2015, 04:59 PM

Stef, I was finally able to fix it using your suggestions!

Rather than using '= Fields.DataType = =Fields(ReportItem.DataObject.DataType)' for the graph's filter expression, I used '= Fields.DataType = =ReportItem.DataObject.DataType'.

Thanks!

Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Stef
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or