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.
Great. That sounds simpler than the approach I was taking. I was able to add a space between the grid and charts, by calling AddGap() on the section after exporting the grid, and then specifying the FixedHeight of the gap.
I put space between the charts by adding two columns to the Flow, and specifying the appropriate Margins (Right for the first column, and Left for the second). Finally, before creating the second canvas, I add a ColumnBreak to the flow.
Let me know if you have any other questions.
one quick one, if I had only one chart is there an easy why to center it on the page? Something like flow.center. :)
The Flow has an Alignment property that you can set to ContentAlignment.Center.
Morning,
Me again.
I have 1 wingrid on each page being exported. But the first pages grid has different number of columns then the rest.
The PDF pages widths are not the same. How can I get the pages to be the same size and have the grids fill the width of the pages?
I have been playing around with he grids width size and the columns autoresize properties but no good result as of yet.
At the beginning I set the report objs page size as {2000,1000}. But on do the GridDocExport cmd I see the page size gets reset.
And even if I do a page resize right after that the result is not what I expected.
Hope that made sense.
There is no built in way to tell the exported grid to autosize to fill the width of the page. From reading some other posts on this subject, it seems the best solution is increase the width of each (or just the last) column to reach the desired page width.
Try something like the following:
Private Sub UltraGridDocumentExporter1_ExportStarted(sender As Object, e As Infragistics.Win.UltraWinGrid.DocumentExport.ExportStartedEventArgs) Handles UltraGridDocumentExporter1.ExportStarted ' Determine the difference between the pageSize and the size of the grid. Dim widthDifference As Integer = e.Section.PageSize.Width - e.Layout.Bands(0).GetExtent() If widthDifference > 0 Then Dim columnWidthIncrease As Integer = widthDifference / e.Layout.Bands(0).Columns.Count For Each column As UltraGridColumn In e.Layout.Bands(0).Columns column.Width = column.Width + columnWidthIncrease Next End If End Sub
' Determine the difference between the pageSize and the size of the grid. Dim widthDifference As Integer = e.Section.PageSize.Width - e.Layout.Bands(0).GetExtent()
If widthDifference > 0 Then Dim columnWidthIncrease As Integer = widthDifference / e.Layout.Bands(0).Columns.Count For Each column As UltraGridColumn In e.Layout.Bands(0).Columns column.Width = column.Width + columnWidthIncrease Next End If End Sub
Make sure to set the PageSize on the section prior to each export. Hopefully this helps.
Hi!
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!
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