Page 1 of 1

What is the fast way to show TChart in Intraweb

Posted: Sun Feb 01, 2015 4:57 pm
by 16871264
Hello,

I'm using the following code (thanks to Alexandre Machado) to show some charts in my Intraweb application :

Code: Select all

procedure CopyChartToImage(const aChart: TChart; const aImage: TIWCGJQImage);
var
	xMetaFile: TMetafile;
	xBitmap: TBitmap;
	xRect: TRect;
begin
	xBitmap := aImage.Picture.Picture.Bitmap;
	xBitmap.Width := aChart.Width;
	xBitmap.Height := aChart.Height;

	xRect := Rect(0, 0, aChart.Width, aChart.Height);
	aChart.BufferedDisplay := False;
	xMetaFile := aChart.TeeCreateMetafile(False, xRect);
	try
		xBitmap.Canvas.Draw(0, 0, xMetaFile);
	finally
		FreeAndNil(xMetaFile);
	end;
end;
Cause I need to deploy my application as an ISAPI dll I use the following code in my main form to initialize the GDI+ that seems to be necessary to TChart component :

Code: Select all

procedure GDIPlus_Initialize;
begin
	StartupInput.DebugEventCallback := nil;
	StartupInput.SuppressBackgroundThread := False;
	StartupInput.SuppressExternalCodecs := False;
	StartupInput.GdiplusVersion := 1;

	GdiplusStartup(gdiplusToken, @StartupInput, nil);
end;

procedure GDIPlus_Finalize;
begin
	if Assigned(GenericSansSerifFontFamily) then
		GenericSansSerifFontFamily.Free;
	if Assigned(GenericSerifFontFamily) then
		GenericSerifFontFamily.Free;
	if Assigned(GenericMonospaceFontFamily) then
		GenericMonospaceFontFamily.Free;
	if Assigned(GenericTypographicStringFormatBuffer) then
		GenericTypographicStringFormatBuffer.free;
	if Assigned(GenericDefaultStringFormatBuffer) then
		GenericDefaultStringFormatBuffer.Free;

	GdiplusShutdown(gdiplusToken);
end;

initialization
	GDIPlus_Initialize;

finalization
	GDIPlus_Finalize;
I noticed that it takes some seconds to show the form.
Is the above code the fastest way to show TChart in Intraweb application ?
Is the GDI+ initialization that took some time to initialize ?
If yes, is it possible to avoid the GDI+ initialization ?
If no, how can I speed up the showing of the form in my Intarweb ISAPI application ?

Thank you,
Davide

Re: What is the fast way to show TChart in Intraweb

Posted: Tue Feb 03, 2015 9:40 am
by yeray
Hello,

Have you seen the this blog post (read the comments too)?
http://steema.com/wp/blog/2014/03/12/te ... ide-a-dll/

Re: What is the fast way to show TChart in Intraweb

Posted: Tue Feb 03, 2015 5:24 pm
by 16871264
Hello,

Thank you for your response.
I saw the post you indicate me and in fact the initialization code I'm using is derived from that post.
In the post is written that in the subsequent release TChart can automatically swith to GDI if GDI+ is not initialize.
I try to omit the GDI+ initialization code but i get an "Access violation error".
Is it true that TChart doesn't need the GDI+ initialization in its actual last release ?

In any case my question is not strictly realted to GDI/GDI+ but rather to know if is there a faster (respect to my code) way to show charts produced by TChart in my Intraweb ISAPI dll application.

Best regards,
Davide

Re: What is the fast way to show TChart in Intraweb

Posted: Wed Feb 04, 2015 3:38 pm
by yeray
Hi Davide,

In order to do the according tests here in an environment as similar as possible to yours, could you please tell us what exact Intraweb and Embarcadero IDE are you using? Are you using TeeChart v2015.14?

Re: What is the fast way to show TChart in Intraweb

Posted: Sat Feb 14, 2015 11:22 am
by 16871264
Hi Yeray,

sorry for the delay of my reply but I was ill...
I'm using Delphi XE7 and now (after reading your post) Teechart 2015 on Windows 7 64bit.

PS.
Is there a way to be informed on new TeeChart release ? (something like a newsletter...)

Thank you,
Davide

Re: What is the fast way to show TChart in Intraweb

Posted: Sat Feb 14, 2015 11:23 am
by 16871264
Hi Yeray,

I'm working on Intraweb 14.0.37 version.

Best regards,
Davide

Re: What is the fast way to show TChart in Intraweb

Posted: Mon Feb 16, 2015 11:58 am
by yeray
Hi Davide,

It would be also helpful if you could arrange a simple example project we can run as-is to reproduce the problem here.

Thanks in advance.

Re: What is the fast way to show TChart in Intraweb

Posted: Fri Jun 26, 2015 8:33 am
by 16871264
Hello,

sorry for the late of my response but I was involved in a FMX project that has taken more time than expected.
The FMX TChart component works like a charm!

Following your request attached you can find a sample of the code I'm using to show a chart on Intraweb pages.
Now I'm working with XE8 and IW 14.0.42 and TChart Std v2015.15.150420.

I would like to know if I'm using the right code in terms of performance a system resources usage.
Considering that on the web I don't need to use the GDI+ features is there a why to avoid to initialize it ?
I should be result in a faster chart creation.

Please let me know if you have any suggestion to achieve better performace in showing chart on the web.

Thank you,
Davide

Re: What is the fast way to show TChart in Intraweb

Posted: Fri Jun 26, 2015 2:14 pm
by yeray
Hello,

If you don't want GDIPlus, you can go back to GDI following any of the ways described here.