I need the same data point images that are shown in a TChart from a TPointSeries (triangle, circle etc. with a particular color), to display them outside of the TChart, e.g. to show them in a TSpeedButton.Glyph, or to print them in a table header. When I wrote that part of my program some years ago, I could not find any TeeChart procedure that would directly yield these images. So I wrote the workaround shown below - but now it doesn't work anymore. If there should be any procedure like this available today, then that workaround would be obsolete, and I would be just happy to learn what that procedure is.
My workaround worked fine with Delphi 2010 (Win 7 32 bit) and several previous TeeChart versions. But now I had to update to Rad Studio Delphi XE6 (on the same PC) and the latest TeeChart Binary installer from September 2014. Now suddenly the workaround produces empty TBitmap and TMetafile results. There has been no change in the source code at all, just recompiled with the new Delphi and TeeChart.
In the workaround, I create a small temporary TChart (not even shown on the screen) with a TPointSeries in it that just contains one point in the center, no axes, legend etc. Then I capture the image of this point into a TBitmap using TeeCreateBitmap, and into a TMetafile using TeeCreateMetafile. But these now remain empty. Have there possibly been any internal modifications in the TChart component that produce this bug under these particular circumstances?.
To make it easier to understand, the code shows only a simplified version of my workaround to produce a single TBitmap and TMetafile. In my real program I produce a full set of all possible combinations from a list of colors and a list of TSeriesPointerStyle.
Thanks in advance for your help. Regards, Uwe
Code: Select all
const
PointColor = clRed;
PointEdgeColor = clBlack;
PointImageSize = 14;
PointStyle = psRectangle;
PointBitmapBackgroundColor = clWhite;
var
TempChart: TChart;
TempPointSeries: TPointSeries;
PointBitmap: TBitmap;
PointMetafile: TMetafile;
begin
TempChart:= TChart.Create(Self);
TempPointSeries:= TPointSeries.Create(TempChart);
try
with TempChart do
begin
Width:= PointImageSize;
Height:= PointImageSize;
BevelOuter:= bvNone;
Color:= clNone;
BackColor:= clNone;
MarginLeft:= 0;
MarginRight:= 0;
MarginTop:= 0;
MarginBottom:= 0;
AxisVisible:= false;
Title.Visible:= false;
Legend.Visible:= false;
Frame.Visible:= false;
View3DWalls:= false;
RecalcWidthHeight;
AddSeries(TempPointSeries);
end; {with TempChart}
with TempPointSeries.Pointer do
begin
Style:= PointStyle;
Pen.Color:= PointEdgeColor;
Brush.Color:= PointColor;
end; {with TempPointSeries.Pointer}
TempPointSeries.AddXY(0, 0);
with TempChart do
begin
PointBitmap:= TeeCreateBitmap(PointBitmapBackgroundColor, ChartRect);
PointMetafile:= TeeCreateMetafile(true, ChartRect);
end; {with TempChart}
TempPointSeries.Clear;
finally
TempPointSeries.Free;
TempChart.Free;
end; {finally}