Export Chart Question

TeeChart for ActiveX, COM and ASP
Post Reply
hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Export Chart Question

Post by hansw » Mon Dec 29, 2003 4:14 am

Export to jpg or GIF works fine.

In the OnAfterDraw() I do several line drawings, and these are never exported with the chart.

How can I make it export my drawings with the chart ?

Thanks
Hans W

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Dec 29, 2003 8:24 am

Hi Hans,

there's no problem getting Canvas drawing methods and properties to write to a JPEG file (in the OnAfterDraw() event recommended in Tutorial 13 - Custom Drawing on the Chart Panel) using the following example:

Code: Select all

Private Sub Command1_Click()
With TChart1
    .Export.SaveToJPEGFile "C:\TestFiles\file.jpg", False, jpegBestQuality,
95, 400, 400
End With
End Sub

Private Sub Form_Load()
TeeCommander1.Chart = TChart1
With TChart1
    .AddSeries scLine
    .AddSeries scLine
    For i = 0 To 1
        .Series(i).FillSampleValues 10
    Next i
End With
End Sub

Private Sub TChart1_OnAfterDraw()
With TChart1
    .Canvas.Font.Name = "Verdana"
    .Canvas.Font.Size = 16
    .Canvas.Font.Color = vbCyan
    .Canvas.TextOut 200, 200, "HELLO"
End With
End Sub
Could you test if it works for you ?

Josep Lluis Jorge
http://support.steema.com

hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Well I think it should work, but it does not !

Post by hansw » Mon Dec 29, 2003 4:14 pm

OK I'm drawing in the OnAfterDraw() like this
m_Chart1.GetCanvas().GetPen().SetColor(pt.crColor);
m_Chart1.GetCanvas().MoveTo( X, m_Chart1.GetAxis().GetTop().GetPosition());
m_Chart1.GetCanvas().LineTo( X, m_Chart1.GetAxis().GetBottom().GetPosition());

Then when the user clicks send chart by email I use this code
The chart is fine, but the lines do not show on the jpeg image.

What now ?
Thanks
Hans W


void C_TeeChartView::OnEmailChart()
{
char lpBuffer[MAX_PATH];
DWORD error = GetTempPath(MAX_PATH, lpBuffer );
strcat (lpBuffer,"Chart1.jpg");

m_Chart1.GetExport().GetAsJPEG().SetCompressionQuality(90);
m_Chart1.GetExport().GetAsJPEG().SetGrayScale(false);
m_Chart1.GetExport().GetAsJPEG().SetHeight(400);
m_Chart1.GetExport().GetAsJPEG().SetWidth(600);
m_Chart1.GetExport().GetAsJPEG().SaveToFile(lpBuffer);
m_Chart1.GetExport().EmailFile(lpBuffer);
}

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Dec 29, 2003 4:35 pm

Hi -
Then when the user clicks send chart by email I use this code
The chart is fine, but the lines do not show on the jpeg image.
I imagine that this is because the C_TeeChartView::OnEmailChart() event, which is not a TeeChart event, is being called before the Chart has fired the OnAfterDraw() event. Have you tried calling ITChart.Repaint() or IEnvironment.InternalRepaint() before you export the Chart to JPEG?
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Almost works... still has problems

Post by hansw » Tue Dec 30, 2003 5:18 am

I used m_Chart1..Repaint() which did make the extra lines appear, however the annotations are no in the correct place.

By correct place I mean X,Y the are way off form where they appear in the chart before it is exported.

So I looked for IEnvironment.InternalRepaint()

And as usual I could not find it.

C++ users only have the few (sometimes not working) examples and a small tutorial for help, and the hints in the VC IDE which can take hours use and are of very little help for learning TeeChart.

VB help for VC+= users is not good enough. I have zero use for VB and can't spend time learning it. It's a craby language about as bad as delphi.

begin
end

who has time to type all those begin and ends when a simple

{
}

does the same thing... long live VC++

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Dec 30, 2003 7:20 am

Hi --
So I looked for IEnvironment.InternalRepaint()

And as usual I could not find it.
Have you had a look for "IEnvironment" in the Index of TeeChart's Help file?

Under "InternalRepaint" you will find a VB example that looks a bit like this:

Code: Select all

With TChart1
    .Environment.InternalRepaint
End With
In VC++, the "translation" looks like this:

Code: Select all

m_Chart1.GetEnvironment().InternalRepaint();
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

hansw
Newbie
Newbie
Posts: 59
Joined: Fri Nov 15, 2002 12:00 am

Thanks

Post by hansw » Tue Dec 30, 2003 10:56 am

thanks..
I still hate VB :-) crap language...:-)

With
End With...

That requires 10 more characters than sthe same statement in C, I've already had carpal tunnel surgery... crap language... :-)

Post Reply