pie series
Series := TPieSeries.Create (Chart);
Series.ParentChart := Chart;
Series.DataSource := Table1;
Series.XLabelsSource := ''Name'';
Series.OtherSlice.Style := poBelowPercent;
Series.OtherSlice.Text := ''Others'';
Series.OtherSlice.Value := 2;
Chart.AddSeries (Series);
// create the memory bitmap
Image := TImage.Create (nil);
Image.Width := Chart.Width;
Image.Height := Chart.Height;
end;
procedure TWebModule1.WebModule1Destroy(
Sender: TObject);
begin
Chart.Free;
Series.Free;
Image.Free;
end;
procedure TWebModule1.WebModule1AfterDispatch(
Sender: TObject;
Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
Jpeg: TJpegImage;
MemStr: TMemoryStream;
begin
// paint the chart on the memory bitmap
Chart.Draw (Image.Canvas, Image.BoundsRect);
// create the jpeg and copy the iamge to it
Jpeg := TJpegImage.Create;
try
Jpeg.Assign (Image.Picture.Bitmap);
MemStr := TMemoryStream.Create;
try
// save to a stream and return it
Jpeg.SaveToStream (MemStr);
MemStr.Position := 0;
Response.ContentType := ''image/jpeg'';
Response.ContentStream := MemStr;
Response.SendResponse;
finally
MemStr.Free;
end;
finally
Jpeg.Free;
end;
end;
end.