Page 1 of 1

Export & Resize JPEG Image of Chart

Posted: Tue Jan 13, 2009 5:29 pm
by 15047425
I am trying to export a JPEG image of a pie chart I have created. If I do not resize the image, it looks great - but if a try to resize the Chart it is unreadable - pie shape changes radically or disappears, etc.

Code I use in Visual FoxPro (VFP):

With thisform.mmTeeChart_Pie.Export.asJPEG
.CompressionQuality = 90
.GrayScale = .F.
.Height = 105
.Width = 120
.SaveToFile("c:\pie.jpg")
ENDWITH

All I want is an image that looks EXACTLY like the bigger version - only smaller (like a thumbnail). Maybe just specify width and be able to use "Keep Aspect Ratio" type command to calculate the height. Is that possible?

Posted: Wed Jan 14, 2009 8:34 am
by narcis
Hi Tom,

This is because chart's legend and pie's mark don't let the pie be visible you can do something like this:

Code: Select all

Private Sub Command1_Click()

    TChart1.Legend.Visible = False
    TChart1.Series(0).Marks.Visible = False
    
    With TChart1.Export.asJPEG
        .CompressionQuality = 90
        .GrayScale = False
        .Height = 105
        .Width = 120
        .SaveToFile ("c:\temp\pie.jpg")
    End With
    
    TChart1.Legend.Visible = True
    TChart1.Series(0).Marks.Visible = True
End Sub