Page 1 of 1

Export Chart Question

Posted: Mon Dec 29, 2003 4:14 am
by 9078641
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

Posted: Mon Dec 29, 2003 8:24 am
by Pep
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

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

Posted: Mon Dec 29, 2003 4:14 pm
by 9078641
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);
}

Posted: Mon Dec 29, 2003 4:35 pm
by Chris
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?

Almost works... still has problems

Posted: Tue Dec 30, 2003 5:18 am
by 9078641
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++

Posted: Tue Dec 30, 2003 7:20 am
by Chris
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();

Thanks

Posted: Tue Dec 30, 2003 10:56 am
by 9078641
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... :-)