Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


TChart in a webapplication?

Posted on 2002-07-15
Medium Priority
Last Modified: 2010-04-04
I want to create a TChart inside a webapplication, but the chart needs a Parent Handle wich is usualy a Form.
Since there is no Form in my webapp the chart wont work.
Once the chart is set up I want to save it to a bitmap
-> Chart.SaveToBitmapFile('test.bmp');
so I can set up a link in the Response to the just saved bitmap.
What should be the Parent Handle for the Chart?

Question by:corpa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1

Expert Comment

ID: 7155916
Why not just use 0 (or nil) instead of the handle?

Author Comment

ID: 7156487

I assigned the NULL but that didn't help.
If I leave the ParentWindow line out it also does not work.
Here's what I got so far:

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var val : Integer;
    Gr: TChart;
    Ser: THorizBarSeries;

  Response.Content := '';

  if (Gr <> nil) then Gr.Free;
  Gr := TChart.Create(self);
  Gr.ParentWindow := null;         //this does not work
  if (Ser <> nil) then Ser.Free;
  Ser := THorizBarSeries.Create(self);
  Ser.parentchart := Gr;

  for val := 10 to 50 step 10 do
   Ser.AddBar(val,'anytext', clRed);

  with Gr do
     width := 420;
     Height :=210;
     Visible := false;
     BevelOuter := bvNone;
     Color := clWhite;

  Response.Content := Response.Content + 'Hello world';

Any ideas?
LVL 17

Expert Comment

ID: 7156538
I'm afraid that you may not use any visual components in CGI/ISAPI applications.

Regards, Geo
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 7157179
I think the component is one of those which you can't.  I think the Pro Essentials graph I use can be instantiated with no parent.

Author Comment

ID: 7157516
Ok, bad programming from my side.
Now what should I do to reach my target?
I want to be able to create a chart (bitmap) that
changes from content as people submit a html form.
So the bitmap needs to be created inside my webapp.
I already know what to do to get the bitmap displayed in the result page, but creating it and storing seems to be a problem.
Mikepj,you mentioned Pro Essentials graph, what is it and where can I find it?

Thanks, corpa

Expert Comment

ID: 7172153
I use TChart, as well as many other visual components in Web Applications. Remember to remove the ChartF from the autocreate.

This example uses the RX Tools rxGif component, and ODBCExpress connectivity for the example.

I can literally copy and paste a TChart object onto the ChartF form from a test program, and it works fine.

If you cannot gain what you need from this example, it may be easier to send you a small example project

Here is my Chart Action:

procedure TWebModule1.WebModule1chartAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var MemStream: TMemoryStream;
    Gif: TGifImage;
    Bit: TBitmap;
    Text: String;
 With ChartF.OEQuery1 do begin

Here is the code on the chart form:

function TChartF.BuildChart(cKind: String):TBitmap;
 if cKind='traffic1' then

Expert Comment

ID: 7172164
Oh.. and don`t save out a bmp like that from a web app: what happens when multiple hits occur? Also, you have to grant write access to where you save the bmp...

oh.. and bmp are not supported by browsers or are too big...

Use my streaming example to send images.
Good luck!

Author Comment

ID: 7175902
Hi, RayNorrish

you have good points there.
I can see what you are doing in the routine, but don't get it all.
Is ChartF a form you declared earlier?
Maybe you should send the example project; do you need my e-mail adress?


Expert Comment

ID: 7176568
Sort of. ChartF is a non autocreate form - created just like any other form!
This is where I drop the TChart object.

What I`ll do is put a small project together for a TChart using random points, avoiding DB issues.

I`ll post a URL where you can download it from, shortly.

Accepted Solution

RayNorrish earned 400 total points
ID: 7176611
OK, I`ve posted an example for you at borland.public.attachments

Once compiled: test it like this:


Note that you could also replace an image tag with this method:

<img src="http://yourserver/cgi-bin/chart.exe?model=traffic1">

Oh.. the news server is forums.borland.com


Author Comment

ID: 7177313
Excellent, this is exact what I needed and it works just perfect. Thanks alot, all credits go to you.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question