Jump to content
Software FX Community

Outer regions of plot are clipped off when I export


yefchak

Recommended Posts

Hi,

I'm exporting a chart to the clipboard as follows (pseudocode):

 

Dim stream as new memorystreamoriginalChart.Export(binary, stream)stream.position = 0dim newChart as new ChartnewChart.Import(binary, stream)newChart.left, right, top, width, etc. = originalChart.left, right, top, width, etc...newChart.AxisX.Font = New Font(newChart.AxisX.Font.Fontfamily, factor * originalChart.AxisX.Font.Size)  same for AxisY, etc.newChart.UpdateSizeNow()newChart.ExportImageSize = new Size(newWidth, newHeight)newChart.Export(bitmap, netastream)dim myImage as new Bitmap(metastream)My.Computer.Clipboard.SetImage(myImage)

 

Note in particular the manipulation of the font size.  Basically this all works, EXCEPT sometimes a very large axis label (e.g., "10,000") on the right-hand edge of the chart will be cut off in the exported image.  And AnotationText objects (not shown in the code above, but treated in the same way) which fall above the top edge of the chart) are cut off as well.  These problems occur when my exported image size is large (e.g., for making a 300-dpi image).  When I keep everything at the original size (96 dpi), everything appears just as on screen.

What's up? 

Thanks!--George 

Link to comment
Share on other sites

Hi folks,

 

A bit more info about my problem.  First, I'm using log axes... haven't had time to see if this fails with regular-mode axes as well.  When I specify a large ExportImageSize (e.g., 1650x1650) and increase the axis and/or annotation font size accordingly, the axis labels are often drawn such that large numbers can fall outside the chart's boundaries.  Reducing the font size doesn't help until the font is too small to be legible. 

I'm searching for a way to fix this... anybody?

Thanks,

--George 

Link to comment
Share on other sites

Please attach a screen shot of the chart so that we can understand how things are being cutoff.

Sure, Frank.

I've attached a screen shot which shows the issues (look at the right-hand size of the horizontal axis -- the text "11" is clipped off the side of the plot area) as well as showing the slightly insane window which I've had to create in order to avoid the problem.

By allowing the user to edit the right and top margins of the plot as well as the ExportImageSize paramters, I'm able to ensure that the axis label text (and annotation text, not shown here) all fitss inside the plot area.  This seems to be a problem only when I set ExportImageSize to something fairly large (1600 x 1600 pixes) in this example, used here for a press-quality bitmap exported to the clipboard.  When a smaller size, similar the chart's actual dimensions on screen, is used eveything looks fine.

Just so I'm clear, the image of the plot shown in this window isn't actually the live ChartFX.WinForms.Chart object, but rather a bitmap generated by calling myChart.Export(bitmapFormat, myStream).  The resulting bitmap is scaled to fit in the window, but of course the clipboard gets the full, unsqueezed bitmap.

Thanks,

--George

Link to comment
Share on other sites

The rightmost label in the X-Axis (110...) is being clipped because the right margin is not big enough. This right space will not be adjusted automatically to make this label fit.

I suspect it is a similar deal with the annotation objects, in general changing the font size of the annotation objects can make them go out of the chart area.

Link to comment
Share on other sites

The rightmost label in the X-Axis (110...) is being clipped because the right margin is not big enough. This right space will not be adjusted automatically to make this label fit.

 

 

Yes, that's it exactly.  I guess my question is, why can't the margin be adjusted automatically since the axis labels should never be clipped. (I can see the question might be less valid for annotation objects.)  In the mean, time, my solution is to allow the user to adjust the margin as illustrated.

Thanks,
--George 

Link to comment
Share on other sites

The reason why it doesn't is due to implementation details.

Without going too much into it it comes down to a chicken-and-the egg situation: Resizing the right margin may change the X-Axis step effectively changing which labels are displayed, therefore, adjusting the right margin to fit 110... may actually result in 110... not shown anymore but another label shown that requires a different size for the right margin. So we are back to square one.

So the short answer is: currently the X-Axis is not considered for automatically adjusting the right margin.

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.

Guest
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...