Search code examples
delphiteechartintraweb

Delphi - how i can use TChart with IntraWeb


I'm using Delphi XE8 with IntraWeb XIV v14.0.49 i create a TIWForm and i drooped a TChart component on it.

On the design time the TChart displayed and i can set it up.

But on the run time there is no TChart on the web page.

Is there any setting should i configure to use it ?


Solution

  • It seems you must use the TChart with TIWImage to display it in the webpage.

    I found the following method in IntraWeb demos

    // this method copies a TChart to an TIWImage
    procedure CopyChartToImage(const aChart: TChart; const aImage: TIWImage);
    var
      xMetaFile: TMetafile;
      xBitmap: TBitmap;
      xRect: TRect;
    begin
      xBitmap := aImage.Picture.Bitmap;
      xBitmap.Width := aChart.Width;
      xBitmap.Height := aChart.Height;
      aImage.Width := aChart.Width;
      aImage.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;
    

    For more information