Reputation: 15
I have the following elements:
1. MigraDoc.DocumentObjectModel.Shapes.Charts.Chart
2. MigraDoc.DocumentObjectModel.Tables.Table
I want to show the data table (2) on the right side of the chart (1). Something like a legend, but with more information. This custom table will give more information than the standard legend.
For some reason, I can add them one above the other by using:
PdfDoc.LastSection.Add(Chart);
PdfDoc.LastSection.Add(Table);
But this is vertical addition. Can I place them horizontally?
Upvotes: 0
Views: 1560
Reputation: 21689
There are several ways to position the items horizontally.
Chart is derived from Shape and can be placed at any position (absolute or relative). A table can be placed inside a TextFrame which is also derived from Shape. Shape placement is a bit tricky though.
Most likely I would use a table and place the chart inside one cell of the table. Using MergeDown and maybe MergeRight you can create almost anything.
Example: Your legend needs two columns and six rows. Create a table with three columns and six (or seven) rows, set MergeDown=5 (or 6) for the first cell in the first column. You can set borders only for the cells in columns 2 and 3 and the first six rows. You should use 7 rows if the legend might be shorter than the chart. If you know the legend is longer than the chart then 6 rows will be enough.
Note: MergeDown=5 will create one cell that spans 6 rows.
The Invoice sample shows MergeDown and MergeRight at work:
http://www.pdfsharp.net/wiki/Invoice-sample.ashx
Upvotes: 1