What is the fast way to show TChart in Intraweb

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Soluzioni PMI
Newbie
Newbie
Posts: 7
Joined: Mon Jan 19, 2015 12:00 am

What is the fast way to show TChart in Intraweb

Post by Soluzioni PMI » Sun Feb 01, 2015 4:57 pm

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

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

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

Post by Yeray » Tue Feb 03, 2015 9:40 am

Hello,

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

Soluzioni PMI
Newbie
Newbie
Posts: 7
Joined: Mon Jan 19, 2015 12:00 am

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

Post by Soluzioni PMI » Tue Feb 03, 2015 5:24 pm

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

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

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

Post by Yeray » Wed Feb 04, 2015 3:38 pm

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?
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

Soluzioni PMI
Newbie
Newbie
Posts: 7
Joined: Mon Jan 19, 2015 12:00 am

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

Post by Soluzioni PMI » Sat Feb 14, 2015 11:22 am

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

Soluzioni PMI
Newbie
Newbie
Posts: 7
Joined: Mon Jan 19, 2015 12:00 am

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

Post by Soluzioni PMI » Sat Feb 14, 2015 11:23 am

Hi Yeray,

I'm working on Intraweb 14.0.37 version.

Best regards,
Davide

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

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

Post by Yeray » Mon Feb 16, 2015 11:58 am

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.
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

Soluzioni PMI
Newbie
Newbie
Posts: 7
Joined: Mon Jan 19, 2015 12:00 am

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

Post by Soluzioni PMI » Fri Jun 26, 2015 8:33 am

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
Attachments
IW_TChart.zip
Sample code
(58.86 KiB) Downloaded 765 times

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

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

Post by Yeray » Fri Jun 26, 2015 2:14 pm

Hello,

If you don't want GDIPlus, you can go back to GDI following any of the ways described 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

Post Reply