Dastardly Dynamic Data Dilemma
By Tim Dexter on Apr 30, 2007
Another great cartoon from the past ... so to something a little more useful. A nice real world problem from a custmer today. Say you needed an output that showed a chart and a table beneath it ... you had no idea how much data was going to hit your report at runtime but you wanted an output looking something like this.
Notice the chart has no column labels or legend, you would add this to the table rows, the idea is that the table columns line up with the chart columns and data points. Pretty nifty eh? It can be done with publisher relatively easily using its support for dynamic data. It requires a little 'alignment' to get table columns lined up with chart columns but thats just a little jiggery pokery.
Whats going on in the template then?
Well the chart is pretty standard we have covered multiple y-axis entries in previous entries. So the only tough bit we have is the table. In the first column we have fixed row headers, we could handle dynamic data here if we wanted. To get the second column to handle the dynamic data we set its width to that required, in this case the width of the plot are of the chart, just use your mouse to drag the table border. Notice the red arrows in the following image marking the table column alignment.
It might take a little adjustment to get things aligned exactly but its only a few iterations with the template builder.
In the fields we are using, for Time
The split-column-header just tells the rendering engine to split the available space qually between the number of ocuurences of the G_MEASUREMENT group, then the FINISH_DATE is inserted.
The next rows handle the specific data elements:
They work just the same way. The whole split column functions can be a little more sophisticated if needed. In this case we wanted equal columns across a given width, we could also specify widths for each column either as a percentage of the total width. Just note the limiting factor to the number of columns shown in the table is going to be how small you can make that font and still make it readable for your users and I guess how messy that chart is going ot get.
The other case we did not need to handle here but publisher is up to it, is something along the lines of the 'Z' printing format in Excel. Let's assume we had a report with 50 columns in it, ordinarily publisher would reach the edge of the page and truncate the report. With the dynamic column support we can generate reports to say PDF that behave like Excel when it prints i.e. print columns across the page until we can not fit anymore, drop to the next page and continue, repeating the row header if we wish, we continue like that until the columns are exhausted. If we had too many rows on a page then we would start at column 1 and go through again until all the rows had been rendered to the page.
This technique is pretty well covered in the user guide and the Template Builder install provides another example showing how to specify the width. You can get the sample RTF, XML and output here.