Page 1 of 1
TChart Legend
Posted: Sun Mar 21, 2010 1:45 am
by 9527612
Is there any way to include the Legend when Exporting a Chart, e.g., as a Bitmap. Text boxes are included, but not Legends. It is included in the Printing methods but not the Copy/Export methods.
Any ideas?
Re: TChart Legend
Posted: Mon Mar 22, 2010 4:05 pm
by yeray
Hi XRS,
The following code in VB6:
Code: Select all
Private Sub Form_Load()
'TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 25
TChart1.Environment.InternalRepaint
TChart1.Export.SaveToBitmapFile "C:\tmp\test.bmp"
End Sub
Gives the following picture here:
- test.zip
- (28.1 KiB) Downloaded 435 times
Could you please check it?
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Re: TChart Legend
Posted: Mon Mar 22, 2010 4:51 pm
by 9527612
Yeray,
Thanks for the reply. I investigated further and find that the Legend IS saved and copied/pasted with the BMP format, but NOT with the JPEG format (neither Save nor Copy works).
Brian
Re: TChart Legend
Posted: Tue Mar 23, 2010 2:39 pm
by yeray
Hi Brian,
Again, the following code seems to work fine for me here with TeeChart AX 8.0.0.8 under Visual Basic 6. Could you please check if you are using the latest maintenance release available?
Code: Select all
Private Sub Form_Load()
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 25
TChart1.Environment.InternalRepaint
TChart1.Export.asJPEG.SaveToFile "C:\tmp\test.jpg"
End Sub
Re: TChart Legend
Posted: Tue Mar 23, 2010 4:28 pm
by 9527612
Yeray,
I am using the menu, not doing this programmatically, and I've created two files, one as a BMP, and one as a JPEG file (see attachment). You can see the difference,
Regards, Brian
Re: TChart Legend
Posted: Thu Mar 25, 2010 10:46 am
by yeray
Hi Brian,
The following code tries to do a chart as similar as possible to yours:
Code: Select all
Private Sub Form_Load()
TeeCommander1.Chart = TChart1
TChart1.Aspect.View3D = False
TChart1.AddSeries scArea
TChart1.Series(0).FillSampleValues 250
TChart1.Series(0).asArea.AreaPen.Visible = False
TChart1.Series(0).Pen.Visible = False
TChart1.AddSeries scVolume
TChart1.Series(1).Color = vbYellow
With TChart1.Series(0)
TChart1.Series(1).AddXY .XValues.Value(50), .YValues.Value(50), "", clTeeColor
TChart1.Series(1).AddXY .XValues.Value(100), .YValues.Value(100), "", clTeeColor
TChart1.Series(1).AddXY .XValues.Value(150), .YValues.Value(150), "", clTeeColor
TChart1.Series(1).AddXY .XValues.Value(200), .YValues.Value(200), "", clTeeColor
End With
With TChart1.Legend
.CustomPosition = True
.Left = 900
.Top = 50
.Transparency = 50
End With
With TChart1.Walls.Back
.Color = RGB(128, 255, 255)
.Transparent = False
.Transparency = 50
End With
TChart1.Environment.InternalRepaint
TChart1.Export.asJPEG.SaveToFile "C:\tmp\test.jpg"
End Sub
Both the generated test.jpg and saving it through the commander gives the same result for me here:
- test.jpg (100.59 KiB) Viewed 7807 times
Could you please modify the code above or send us a simple example project we can run as-is to reproduce the problem here?
Re: TChart Legend
Posted: Thu Mar 25, 2010 7:42 pm
by 9527612
Yeray,
I was not able to duplicate the problem with your project. In the end I was able to fix it on my side by using the custom positioning setup for the Legend, programmatically similar to what you had done, rather than using the Designer to set it up with Percent Margins. The strange thing is that it worked with v.6 and 7 of TChart, but not v.8. It was only a problem with saving to JPEG, not with BMP.
Anyway, thanks for your help,
Brian
Re: TChart Legend
Posted: Fri Mar 26, 2010 3:24 pm
by yeray
Hi Brian,
I'm glad to see that you've found a solution that fits your wishes!