TChart Legend

TeeChart for ActiveX, COM and ASP
Post Reply
XRS
Newbie
Newbie
Posts: 7
Joined: Mon Jul 04, 2005 4:00 am
Location: California, USA
Contact:

TChart Legend

Post by XRS » Sun Mar 21, 2010 1:45 am

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?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart Legend

Post by Yeray » Mon Mar 22, 2010 4:05 pm

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 434 times
Could you please check it?
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

XRS
Newbie
Newbie
Posts: 7
Joined: Mon Jul 04, 2005 4:00 am
Location: California, USA
Contact:

Re: TChart Legend

Post by XRS » Mon Mar 22, 2010 4:51 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart Legend

Post by Yeray » Tue Mar 23, 2010 2:39 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

XRS
Newbie
Newbie
Posts: 7
Joined: Mon Jul 04, 2005 4:00 am
Location: California, USA
Contact:

Re: TChart Legend

Post by XRS » Tue Mar 23, 2010 4:28 pm

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
Attachments
test.zip
(132.63 KiB) Downloaded 418 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart Legend

Post by Yeray » Thu Mar 25, 2010 10:46 am

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
test.jpg (100.59 KiB) Viewed 7798 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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

XRS
Newbie
Newbie
Posts: 7
Joined: Mon Jul 04, 2005 4:00 am
Location: California, USA
Contact:

Re: TChart Legend

Post by XRS » Thu Mar 25, 2010 7:42 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TChart Legend

Post by Yeray » Fri Mar 26, 2010 3:24 pm

Hi Brian,

I'm glad to see that you've found a solution that fits your wishes!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply