Hi Janne,
Let me try to explain the alternatives you have with GDI+, then if you find any problem with any of them, or for any reason they don't fit your needs, please don't hesitate to let us know.
- With GDI+ you can activate/deactivate the AntiAlias
Code: Select all
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=False; 'True by default
- Then, you can activate/deactivate the AntiAlias for a single series using the BeforeDrawValues/AfterDrawValues events of the series. Ie:
Code: Select all
procedure TForm1.SeriesBeforeDrawValues(Sender: TObject);
begin
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=True;
end;
procedure TForm1.SeriesAfterDrawValues(Sender: TObject);
begin
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=False;
end;
So, your example, simplified and with GDI+ enabling the AntiAlias for the series with the trick above looks like this:
- GDI+AntiAlias.png (13.1 KiB) Viewed 20889 times
Code: Select all
uses TeCanvas, Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
with Chart1.AddSeries(TLineSeries) do
begin
AddArray([10,10,12,1,15,13,13]);
BeforeDrawValues:=SeriesBeforeDrawValues;
AfterDrawValues:=SeriesAfterDrawValues;
end;
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=False;
end;
procedure TForm1.SeriesBeforeDrawValues(Sender: TObject);
begin
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=True;
end;
procedure TForm1.SeriesAfterDrawValues(Sender: TObject);
begin
(Chart1.Canvas as TGDIPlusCanvas).AntiAlias:=False;
end;
- On the contrary direction, some series like the TFastLineSeries, include the
FastPen property that actually disables the AntiAlias when set to true (only for the series), to improve the speed.