Hello all,
I have 2 charts on a pdf page. They appear one after the other.
I would like them to appear side by side on the page?
Not seeing a way to do this. Any help would be appreciated.
Thanks
Deasun
{vb.net :) }
Hello Deasun,
You can place charts side by side within a PDF document by positioning canvases within the PDF page, then rendering each chart to a canvas. This technique is explained in this walkthrough. I have attached a sample of the final product of the walkthrough if you'd like to see the code in action. Let me know if you have any questions.
Thanks,
Chris
thanks very much for the reply.
Question can this be used with sections?
Currently I have; Dim section1 As ISection = report.AddSection()
then I add a Header and Footer section and set the page number section
I export a wingrid to Section 1 using the griddocexporter.
Then for the charts I do;
Dim canvas As ICanvas = section1.AddCanvascanvas.Width = New FixedWidth(2000)canvas.Height = New FixedHeight(500)Dim g As Drawing.Graphics = canvas.CreateGraphics()uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
and the 2nd chart gets:
Dim canvas2 As ICanvas = section1.AddCanvascanvas2.Width = New FixedWidth(2000)canvas2.Height = New FixedHeight(500)Dim g2 As Drawing.Graphics = canvas2.CreateGraphics()uwCht_HidChartView.RenderPdfFriendlyGraphics(g2)
Guess how does that page object work with the sections?
I may have come at this from wrong direction and missed something.
Here is a modified version of your sample that should achieve what I believe to be your desired behaviors.
The main thing to keep in mind is that the UltraGridDocumentExporter will changed the section's PageSize when it performs the export. As such, you'll see that I reset the PageSize after each export. This helped to make sure that pages were all the same size.
The next issue to resolve was getting the exported grids to extend across the entire width of the section. To achieve this, I determined the default export size of the grid, and then added the necessary pixels to the width of each UltraGridColumn based on the Point difference between the default export size and the desired size.
Finally, I had to tweak the calculated ChartWidth and the Paddings of each chart canvas so the charts are nicely aligned/spaced. Note that I assigned a BackColor to the chart in the sample to make it easier to see the bounds of each rendered chart.
Hopefully these modifications help resolve your issues.
Hello me again.
Mgt wanted me to change to Lanscape from Protrait and after doing so things went haywire again.
1] All 3 pages should be same size.
2] Grids on all pages should fit from margin to margrin.
We are all getting a bit frustrated with this.
Attached is the test project.
Is there a Overview documentation somewhere of the Infragistics.Documents.Reports
Like how its made up.
Example. Real basic stuff!
Report
Page
Sections
It looks like the new sample you provided removed some of the lines of code (from previous posts) that are necessary to stretch the grids to fit the width of the page. The multiple lines that set the PageSize of each specific section are necessary due to the grid exporting changing the section's PageSize. Additionally, the previously provided code to stretch the grid relies on setting the grid's width based on the temporary exported grid's size (see GetExportSize()). Once I put this code back in the place the grids were properly stretching the width of the page.
Another thing that had to change in the sample was were you were changing the PageOrientation and PageSize. The code was changing the PageSize so it was wider than it was talk (i.e. looks landscape) but also changing the orientation to Landscape. I believe internally this was causing the page to be rotated, and thus become taller than it is wide. I don't think setting the PageOrientation is necessary here, and seems to work without it. You could probably adjust the code so the PageOrientation is Landscape, and the PageSize is taller than it is wide, but you would have to adjust all the other code that relies on the Page size (such as the chart size code).
I've attached my updated sample.
The documentation for the Infragistics Document Engine can be found here. There is no real simple overview due to the complex nature of the engine. There is just so much you can do in terms of nesting report objects.
I hope this helps.
Morning,
I rewrote the example project.Too many edits wanted a clean version.In this version I am supplying 4 pages.2 with 2 charts and 2 with 3 charts on it.Each having 1 grid.
I have also changed the DB table values to show what happens with different values in the last two pages grids.
I am also including 2 PDFs. 1 with the outcome using just your code. InfragisticsCode_exampleresults_RunBy_THRUD.pdfAnd the other with code changes I made. MyCode_exampleresults_RunBy_THRUD.pdf
Maybe I missed something in all the edits but the grid on the pages of the PDFusing the, .Width = Basic_GetExportSize(uwGrid_HiddenObj), doesn't seem to have expanded to the page margins.
In my code example I am finding the Max cell width and then adding a figure I calculated by hitnmiss reviewing the reports. Not something I want to do!You will also see on the last 2 pages that this value has to change because of the data in the cells/grid.
I need a much better way to keep the grids margin to margin on each page no matter the values in the girds.
Also Have a question on the Chart, Is it possible to center or left/right justify the actualchart part between the chart controls borders?Mgt would like it in the center.
ThanksDeasun
Try this version of the sample. I've marked all my changes with //TODO: CDS so you can quickly find the changes in the Task window. There are quite a few changes, but the main one regarding the stretching of the grid was due to the exported size of the grid being smaller than the default TargetPageSize of the exporter. As such, the method that attempts to figure out the grid's Size was returning the wrong value.
Figuring out the size of the charts was a bit of a task. The easy part was to make sure the width was being calculated based on the proper extent (ie. the Height when using landscape mode). The harder part dealt with determining the proper height for the chart. There is no way to know the exported grid height, so the sample had to estimate it based on the number of rows and their height.
Finally, the positioning of the chart area within each chart can be controlled using the Extent property on each Axis.
Hope this helps.
Another quick ?
On the Chart control, there appears to be a lot of space between the barchart and the legend at the bottom.
Anyway to decrease that spacing? Would like to increase the size of the barchart itself and leave the legend at the size its at.
Heres the PDF results docs!