Jump to content
Software FX Community

Making a copy of a chart for printing


Recommended Posts


 I was looking at the following code excerpt in another posting on this forum.  I'm trying something nearly identical in my code.  I seem to create a duplicate chart in memory, but it doesn't seem to print.  First, here's the code excerpt I found:


private void PrintMosaic (Chart chart) {  // Calculate Rows/Cols  m_firstPage = true;
  // Make a coppy of the chart to avoid flickering
  MemoryStream stream = new MemoryStream();  chart.Export(FileFormat.Binary,stream);  stream.Position = 0;  m_chart = new Chart();  m_chart.Import(FileFormat.Binary,stream);  // Print    ...   }

 I'm doing the same thing in VB.net, and the new chart seems OK as far as I can tell. I print using the following approach:

m_chart.Paint(g, chartRect, ChartFX.WinForms.PaintStyles.Print)

 This works fine if I use my original chart, but using the copy produces no output. Is there something else I need to do?


Link to comment
Share on other sites

I believe the problem is that you are failing to provide the second chart with a size. The size is not serialized into the binary file.

Try adding the following right after the call to Import:

chart.Width = chartRect.Width;

chart.Height = chartRect.Height;

chart.UpdateSizeNow(); // Very important. This call commits the changed to the chart layout.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...