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 :) }
thanks very much.
Pointed me in the right direction.
Will play around with that code now.
Here are a few things that you'll probably want to do different.
I'll paste my updated code at the end of the reply. Let me know if you have any issues with it. Thanks,
Chris
Dim UltraChart1 As New UltraChart() Dim report As New Infragistics.Documents.Reports.Report.Report()Dim section As ISection = report.AddSection()Me.UltraGridDocumentExporter1.Export(Me.UltraGrid1, section)'section.PageSize = New PageSize(800, 1000) Dim chartWidth As Integer = section.PageSize.Width / 2 _ - (section.PageMargins.Left + section.PageMargins.Right)Dim chartHeight As Integer = chartWidth * 0.75 UltraChart1.Size = New Size(chartWidth, chartHeight)UltraChart1.ChartType = ChartType.ColumnChartUltraChart1.Data.DataSource = New Integer() {1, 2, 3, 4, 5, 6}UltraChart1.Data.DataBind() Dim flow As IFlow = section.AddFlow()Dim canvas As ICanvas = flow.AddCanvas()canvas.Width = New FixedWidth(chartWidth)canvas.Height = New FixedHeight(chartHeight)Dim g As Graphics = canvas.CreateGraphics()UltraChart1.RenderPdfFriendlyGraphics(g) UltraChart1.ChartType = ChartType.GanttChartUltraChart1.Data.SwapRowsAndColumns = FalseUltraChart1.Data.DataSource = tableUltraChart1.Data.DataBind() canvas = flow.AddCanvas()canvas.Width = New FixedWidth(chartWidth)canvas.Height = New FixedHeight(chartHeight)g = canvas.CreateGraphics()UltraChart1.RenderPdfFriendlyGraphics(g) Dim reportPath As String = _ System.Environment.GetFolderPath( _ System.Environment.SpecialFolder.MyDocuments)report.Publish(reportPath + "\Report.pdf", FileFormat.PDF)
Dim UltraChart1 As New UltraChart()
Dim report As New Infragistics.Documents.Reports.Report.Report()Dim section As ISection = report.AddSection()Me.UltraGridDocumentExporter1.Export(Me.UltraGrid1, section)'section.PageSize = New PageSize(800, 1000)
Dim chartWidth As Integer = section.PageSize.Width / 2 _ - (section.PageMargins.Left + section.PageMargins.Right)Dim chartHeight As Integer = chartWidth * 0.75
UltraChart1.Size = New Size(chartWidth, chartHeight)UltraChart1.ChartType = ChartType.ColumnChartUltraChart1.Data.DataSource = New Integer() {1, 2, 3, 4, 5, 6}UltraChart1.Data.DataBind()
Dim flow As IFlow = section.AddFlow()Dim canvas As ICanvas = flow.AddCanvas()canvas.Width = New FixedWidth(chartWidth)canvas.Height = New FixedHeight(chartHeight)Dim g As Graphics = canvas.CreateGraphics()UltraChart1.RenderPdfFriendlyGraphics(g)
UltraChart1.ChartType = ChartType.GanttChartUltraChart1.Data.SwapRowsAndColumns = FalseUltraChart1.Data.DataSource = tableUltraChart1.Data.DataBind()
canvas = flow.AddCanvas()canvas.Width = New FixedWidth(chartWidth)canvas.Height = New FixedHeight(chartHeight)g = canvas.CreateGraphics()UltraChart1.RenderPdfFriendlyGraphics(g)
Dim reportPath As String = _ System.Environment.GetFolderPath( _ System.Environment.SpecialFolder.MyDocuments)report.Publish(reportPath + "\Report.pdf", FileFormat.PDF)
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.
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,