mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 03:01:41 +02:00
TAChart: Allow user-drawn legend items with arbitrary text
git-svn-id: trunk@28572 -
This commit is contained in:
parent
abd5ef4928
commit
431801a4c5
@ -56,6 +56,7 @@ object Form1: TForm1
|
||||
Source = ListChartSource2
|
||||
end
|
||||
object Chart1FuncSeries1: TFuncSeries
|
||||
Legend.UserItemsCount = 2
|
||||
Extent.XMax = 5
|
||||
Extent.UseXMin = True
|
||||
Extent.UseXMax = True
|
||||
|
@ -35,7 +35,7 @@ type
|
||||
procedure cbUseSidebarChange(Sender: TObject);
|
||||
procedure Chart1FuncSeries1Calculate(const AX: Double; out AY: Double);
|
||||
procedure Chart1FuncSeries1DrawLegend(
|
||||
ACanvas: TCanvas; AIndex: Integer; const ARect: TRect);
|
||||
ACanvas: TCanvas; const ARect: TRect; AIndex: Integer; var AText: String);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure rgAlignmentClick(Sender: TObject);
|
||||
procedure seMarginXChange(Sender: TObject);
|
||||
@ -51,6 +51,9 @@ implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.cbUseSidebarChange(Sender: TObject);
|
||||
@ -64,10 +67,11 @@ begin
|
||||
end;
|
||||
|
||||
procedure TForm1.Chart1FuncSeries1DrawLegend(
|
||||
ACanvas: TCanvas; AIndex: Integer; const ARect: TRect);
|
||||
ACanvas: TCanvas; const ARect: TRect; AIndex: Integer; var AText: String);
|
||||
var
|
||||
x, y0, w: Integer;
|
||||
begin
|
||||
AText := 'Function ' + IntToStr(AIndex);
|
||||
ACanvas.Pen := Chart1FuncSeries1.Pen;
|
||||
y0 := (ARect.Top + ARect.Bottom) div 2;
|
||||
ACanvas.MoveTo(ARect.Left, y0);
|
||||
|
@ -41,8 +41,9 @@ type
|
||||
property Color: TColor read FColor write FColor;
|
||||
end;
|
||||
|
||||
TLegendItemDrawEvent =
|
||||
procedure (ACanvas: TCanvas; AIndex: Integer; const ARect: TRect) of object;
|
||||
TLegendItemDrawEvent = procedure (
|
||||
ACanvas: TCanvas; const ARect: TRect; AIndex: Integer; var AText: String
|
||||
) of object;
|
||||
|
||||
{ TLegendItemUserDrawn }
|
||||
|
||||
@ -218,9 +219,9 @@ end;
|
||||
|
||||
procedure TLegendItemUserDrawn.Draw(ACanvas: TCanvas; const ARect: TRect);
|
||||
begin
|
||||
inherited Draw(ACanvas, ARect);
|
||||
if Assigned(FOnDraw) then
|
||||
FOnDraw(ACanvas, FIndex, ARect);
|
||||
FOnDraw(ACanvas, ARect, FIndex, FText);
|
||||
inherited Draw(ACanvas, ARect);
|
||||
end;
|
||||
|
||||
{ TLegendItemLine }
|
||||
|
Loading…
Reference in New Issue
Block a user