mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 11:52:37 +02:00
TAChart: Update "legend" demo to show legend grid
git-svn-id: trunk@39075 -
This commit is contained in:
parent
bef2b0f44a
commit
aec9afaf9c
@ -49,6 +49,7 @@
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
</Unit1>
|
||||
|
@ -1,18 +1,18 @@
|
||||
object Form1: TForm1
|
||||
Left = 1322
|
||||
Height = 429
|
||||
Height = 438
|
||||
Top = 181
|
||||
Width = 510
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 429
|
||||
ClientHeight = 438
|
||||
ClientWidth = 510
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.31'
|
||||
LCLVersion = '1.1'
|
||||
object Chart1: TChart
|
||||
Left = 0
|
||||
Height = 312
|
||||
Height = 304
|
||||
Top = 0
|
||||
Width = 510
|
||||
AxisList = <
|
||||
@ -30,6 +30,8 @@ object Form1: TForm1
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Legend.BackgroundBrush.Color = clMoneyGreen
|
||||
Legend.GridHorizontal.Style = psDot
|
||||
Legend.GridVertical.Style = psDot
|
||||
Legend.GroupFont.Style = [fsBold]
|
||||
Legend.GroupTitles.Strings = (
|
||||
'Pie'
|
||||
@ -80,18 +82,18 @@ object Form1: TForm1
|
||||
end
|
||||
object pnControls: TPanel
|
||||
Left = 0
|
||||
Height = 117
|
||||
Top = 312
|
||||
Height = 134
|
||||
Top = 304
|
||||
Width = 510
|
||||
Align = alBottom
|
||||
ClientHeight = 117
|
||||
ClientHeight = 134
|
||||
ClientWidth = 510
|
||||
TabOrder = 1
|
||||
object lblMarginY: TLabel
|
||||
Left = 8
|
||||
Height = 14
|
||||
Height = 13
|
||||
Top = 33
|
||||
Width = 42
|
||||
Width = 41
|
||||
Caption = 'Y margin'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -117,15 +119,15 @@ object Form1: TForm1
|
||||
end
|
||||
object lblSymbolWidth: TLabel
|
||||
Left = 128
|
||||
Height = 14
|
||||
Height = 13
|
||||
Top = 8
|
||||
Width = 64
|
||||
Width = 63
|
||||
Caption = 'Symbol width'
|
||||
ParentColor = False
|
||||
end
|
||||
object rgAlignment: TRadioGroup
|
||||
Left = 264
|
||||
Height = 115
|
||||
Height = 132
|
||||
Top = 1
|
||||
Width = 245
|
||||
Align = alRight
|
||||
@ -139,7 +141,7 @@ object Form1: TForm1
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclTopToBottomThenLeftToRight
|
||||
ChildSizing.ControlsPerLine = 3
|
||||
ClientHeight = 97
|
||||
ClientHeight = 114
|
||||
ClientWidth = 241
|
||||
Columns = 3
|
||||
ItemIndex = 6
|
||||
@ -170,9 +172,9 @@ object Form1: TForm1
|
||||
end
|
||||
object lblSpacing: TLabel
|
||||
Left = 128
|
||||
Height = 14
|
||||
Height = 13
|
||||
Top = 33
|
||||
Width = 38
|
||||
Width = 37
|
||||
Caption = 'Spacing'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -188,9 +190,9 @@ object Form1: TForm1
|
||||
end
|
||||
object lblMarginX: TLabel
|
||||
Left = 8
|
||||
Height = 14
|
||||
Height = 13
|
||||
Top = 8
|
||||
Width = 42
|
||||
Width = 41
|
||||
Caption = 'X margin'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -217,9 +219,9 @@ object Form1: TForm1
|
||||
end
|
||||
object lblColumnCount: TLabel
|
||||
Left = 128
|
||||
Height = 14
|
||||
Height = 13
|
||||
Top = 60
|
||||
Width = 41
|
||||
Width = 40
|
||||
Caption = 'Columns'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -242,6 +244,15 @@ object Form1: TForm1
|
||||
OnChange = cbByRowsChange
|
||||
TabOrder = 8
|
||||
end
|
||||
object cbGrid: TCheckBox
|
||||
Left = 8
|
||||
Height = 17
|
||||
Top = 108
|
||||
Width = 39
|
||||
Caption = 'Grid'
|
||||
OnChange = cbGridChange
|
||||
TabOrder = 9
|
||||
end
|
||||
end
|
||||
object RandomChartSource1: TRandomChartSource
|
||||
PointsNumber = 7
|
||||
|
@ -14,6 +14,7 @@ type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
cbByRows: TCheckBox;
|
||||
cbGrid: TCheckBox;
|
||||
Chart1: TChart;
|
||||
Chart1AreaSeries1: TAreaSeries;
|
||||
Chart1FuncSeries1: TFuncSeries;
|
||||
@ -37,6 +38,7 @@ type
|
||||
seSymbolWidth: TSpinEdit;
|
||||
seMarginY: TSpinEdit;
|
||||
procedure cbByRowsChange(Sender: TObject);
|
||||
procedure cbGridChange(Sender: TObject);
|
||||
procedure cbSeriesDrawItem(Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; State: TOwnerDrawState);
|
||||
procedure cbUseSidebarChange(Sender: TObject);
|
||||
@ -65,7 +67,7 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
SysUtils, TADrawerCanvas, TADrawUtils;
|
||||
SysUtils, TAChartUtils, TADrawerCanvas, TADrawUtils;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
@ -78,12 +80,19 @@ begin
|
||||
ItemFillOrder := lfoColRow;
|
||||
end;
|
||||
|
||||
procedure TForm1.cbGridChange(Sender: TObject);
|
||||
begin
|
||||
Chart1.Legend.GridHorizontal.Visible := cbGrid.Checked;
|
||||
Chart1.Legend.GridVertical.Visible := cbGrid.Checked;
|
||||
end;
|
||||
|
||||
procedure TForm1.cbSeriesDrawItem(
|
||||
Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
||||
var
|
||||
id: IChartDrawer;
|
||||
r: TRect;
|
||||
begin
|
||||
Unused(Control, State);
|
||||
id := TCanvasDrawer.Create(cbSeries.Canvas);
|
||||
r := Bounds(
|
||||
ARect.Left + 2, ARect.Top, Chart1.Legend.SymbolWidth, cbSeries.ItemHeight);
|
||||
@ -114,6 +123,7 @@ procedure TForm1.Chart1FuncSeries1DrawLegend(
|
||||
var
|
||||
x, y0, w: Integer;
|
||||
begin
|
||||
Unused(AIndex, AItem);
|
||||
ACanvas.Pen := Chart1FuncSeries1.Pen;
|
||||
y0 := (ARect.Top + ARect.Bottom) div 2;
|
||||
ACanvas.MoveTo(ARect.Left, y0);
|
||||
|
Loading…
Reference in New Issue
Block a user