mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:19:22 +02:00
TAChart: Minor axis can get marks from a chartsource now
This commit is contained in:
parent
f306bcae87
commit
fde9c86ca8
@ -165,7 +165,6 @@ type
|
|||||||
function IsDefaultPosition: Boolean;
|
function IsDefaultPosition: Boolean;
|
||||||
function IsFlipped: Boolean; override;
|
function IsFlipped: Boolean; override;
|
||||||
function IsPointInside(const APoint: TPoint): Boolean;
|
function IsPointInside(const APoint: TPoint): Boolean;
|
||||||
function IsVertical: Boolean; inline;
|
|
||||||
procedure Measure(const AExtent: TDoubleRect; const AClipRect: TRect;
|
procedure Measure(const AExtent: TDoubleRect; const AClipRect: TRect;
|
||||||
var AMeasureData: TChartAxisGroup);
|
var AMeasureData: TChartAxisGroup);
|
||||||
function MeasureLabelSize(ADrawer: IChartDrawer): Integer;
|
function MeasureLabelSize(ADrawer: IChartDrawer): Integer;
|
||||||
@ -376,12 +375,27 @@ end{%H-}; // to silence the compiler warning of impossible inherited inside inli
|
|||||||
function TChartMinorAxis.GetMarkValues(AMin, AMax: Double): TChartValueTextArray;
|
function TChartMinorAxis.GetMarkValues(AMin, AMax: Double): TChartValueTextArray;
|
||||||
var
|
var
|
||||||
vp: TValuesInRangeParams;
|
vp: TValuesInRangeParams;
|
||||||
|
i: Integer;
|
||||||
|
item: PChartDataItem;
|
||||||
begin
|
begin
|
||||||
if not Visible then exit(nil);
|
if not Visible then exit(nil);
|
||||||
with Collection as TChartMinorAxisList do
|
with Collection as TChartMinorAxisList do
|
||||||
vp := ParentAxis.MakeValuesInRangeParams(AMin, AMax);
|
vp := ParentAxis.MakeValuesInRangeParams(AMin, AMax);
|
||||||
vp.FFormat := Marks.Format;
|
vp.FFormat := Marks.Format;
|
||||||
Marks.DefaultSource.ValuesInRange(vp, Result);
|
if Marks.Source = nil then
|
||||||
|
Marks.DefaultSource.ValuesInRange(vp, Result)
|
||||||
|
else begin
|
||||||
|
SetLength(Result, Marks.Source.count);
|
||||||
|
for i := 0 to Marks.Source.Count-1 do begin
|
||||||
|
item := Marks.Source[i];
|
||||||
|
if IsVertical then
|
||||||
|
Result[i].FValue := item^.Y
|
||||||
|
else
|
||||||
|
Result[i].FValue := item^.X;
|
||||||
|
Result[i].FText := Marks.Source.FormatItemXYText(
|
||||||
|
Marks.Format, item^.X, item^.Y, item^.Text);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartMinorAxis.SetAlignment(AValue: TChartAxisAlignment);
|
procedure TChartMinorAxis.SetAlignment(AValue: TChartAxisAlignment);
|
||||||
@ -784,11 +798,6 @@ begin
|
|||||||
Result := PtInRect(FTitleRect, APoint) and not PtInRect(FAxisRect, APoint);
|
Result := PtInRect(FTitleRect, APoint) and not PtInRect(FAxisRect, APoint);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChartAxis.IsVertical: Boolean; inline;
|
|
||||||
begin
|
|
||||||
Result := Alignment in [calLeft, calRight];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TChartAxis.IsWordwrappedTitle: Boolean;
|
function TChartAxis.IsWordwrappedTitle: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Title.Wordwrap and (
|
Result := Title.Wordwrap and (
|
||||||
|
@ -87,8 +87,11 @@ type
|
|||||||
strict private
|
strict private
|
||||||
FDefaultListener: TListener;
|
FDefaultListener: TListener;
|
||||||
FDefaultSource: TIntervalChartSource;
|
FDefaultSource: TIntervalChartSource;
|
||||||
|
FListener: TListener;
|
||||||
|
FSource: TCustomChartSource;
|
||||||
FSourceExchangeXY: Boolean;
|
FSourceExchangeXY: Boolean;
|
||||||
FStripes: TChartStyles;
|
FStripes: TChartStyles;
|
||||||
|
procedure SetSource(AValue: TCustomChartSource);
|
||||||
procedure SetStripes(AValue: TChartStyles);
|
procedure SetStripes(AValue: TChartStyles);
|
||||||
strict protected
|
strict protected
|
||||||
function IsFormatStored: Boolean;
|
function IsFormatStored: Boolean;
|
||||||
@ -98,7 +101,9 @@ type
|
|||||||
function Measure(
|
function Measure(
|
||||||
ADrawer: IChartDrawer; AIsVertical: Boolean; ATickLength: Integer;
|
ADrawer: IChartDrawer; AIsVertical: Boolean; ATickLength: Integer;
|
||||||
AValues: TChartValueTextArray): Integer;
|
AValues: TChartValueTextArray): Integer;
|
||||||
|
function SourceDef: TCustomChartSource;
|
||||||
property DefaultSource: TIntervalChartSource read FDefaultSource;
|
property DefaultSource: TIntervalChartSource read FDefaultSource;
|
||||||
|
property Source: TCustomChartSource read FSource write SetSource;
|
||||||
property SourceExchangeXY: Boolean
|
property SourceExchangeXY: Boolean
|
||||||
read FSourceExchangeXY write FSourceExchangeXY default false;
|
read FSourceExchangeXY write FSourceExchangeXY default false;
|
||||||
property Stripes: TChartStyles read FStripes write SetStripes;
|
property Stripes: TChartStyles read FStripes write SetStripes;
|
||||||
@ -113,6 +118,8 @@ type
|
|||||||
property Frame;
|
property Frame;
|
||||||
property LabelBrush;
|
property LabelBrush;
|
||||||
property OverlapPolicy;
|
property OverlapPolicy;
|
||||||
|
property Source;
|
||||||
|
property SourceExchangeXY;
|
||||||
property Style default smsNone;
|
property Style default smsNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -121,18 +128,12 @@ type
|
|||||||
TChartAxisMarks = class(TCustomChartAxisMarks)
|
TChartAxisMarks = class(TCustomChartAxisMarks)
|
||||||
strict private
|
strict private
|
||||||
FAtDataOnly: Boolean;
|
FAtDataOnly: Boolean;
|
||||||
FListener: TListener;
|
|
||||||
FRange: TChartRange;
|
FRange: TChartRange;
|
||||||
FSource: TCustomChartSource;
|
|
||||||
|
|
||||||
procedure SetAtDataOnly(AValue: Boolean);
|
procedure SetAtDataOnly(AValue: Boolean);
|
||||||
procedure SetRange(AValue: TChartRange);
|
procedure SetRange(AValue: TChartRange);
|
||||||
procedure SetSource(AValue: TCustomChartSource);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TCustomChart);
|
constructor Create(AOwner: TCustomChart);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function SourceDef: TCustomChartSource;
|
|
||||||
published
|
published
|
||||||
property AtDataOnly: Boolean
|
property AtDataOnly: Boolean
|
||||||
read FAtDataOnly write SetAtDataOnly default false;
|
read FAtDataOnly write SetAtDataOnly default false;
|
||||||
@ -143,7 +144,7 @@ type
|
|||||||
property OverlapPolicy;
|
property OverlapPolicy;
|
||||||
property Range: TChartRange read FRange write SetRange;
|
property Range: TChartRange read FRange write SetRange;
|
||||||
property RotationCenter;
|
property RotationCenter;
|
||||||
property Source: TCustomChartSource read FSource write SetSource;
|
property Source;
|
||||||
property SourceExchangeXY;
|
property SourceExchangeXY;
|
||||||
property Stripes;
|
property Stripes;
|
||||||
property Style default smsValue;
|
property Style default smsValue;
|
||||||
@ -186,6 +187,7 @@ type
|
|||||||
public
|
public
|
||||||
procedure Assign(ASource: TPersistent); override;
|
procedure Assign(ASource: TPersistent); override;
|
||||||
function IsFlipped: Boolean; virtual;
|
function IsFlipped: Boolean; virtual;
|
||||||
|
function IsVertical: Boolean; inline;
|
||||||
function TryApplyStripes(
|
function TryApplyStripes(
|
||||||
ADrawer: IChartDrawer; var AIndex: Cardinal): Boolean;
|
ADrawer: IChartDrawer; var AIndex: Cardinal): Boolean;
|
||||||
|
|
||||||
@ -634,11 +636,13 @@ begin
|
|||||||
FDefaultSource := TIntervalChartSource.Create(AOwner);
|
FDefaultSource := TIntervalChartSource.Create(AOwner);
|
||||||
FDefaultSource.Broadcaster.Subscribe(FDefaultListener);
|
FDefaultSource.Broadcaster.Subscribe(FDefaultListener);
|
||||||
FDistance := 1;
|
FDistance := 1;
|
||||||
|
FListener := TListener.Create(@FSource, @StyleChanged);
|
||||||
FLabelBrush.Style := bsClear;
|
FLabelBrush.Style := bsClear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCustomChartAxisMarks.Destroy;
|
destructor TCustomChartAxisMarks.Destroy;
|
||||||
begin
|
begin
|
||||||
|
FreeAndNil(FListener);
|
||||||
FreeAndNil(FDefaultListener);
|
FreeAndNil(FDefaultListener);
|
||||||
FreeAndNil(FDefaultSource);
|
FreeAndNil(FDefaultSource);
|
||||||
inherited;
|
inherited;
|
||||||
@ -667,6 +671,18 @@ begin
|
|||||||
Result += ADrawer.Scale(ATickLength) + ADrawer.Scale(Distance);
|
Result += ADrawer.Scale(ATickLength) + ADrawer.Scale(Distance);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomChartAxisMarks.SetSource(AValue: TCustomChartSource);
|
||||||
|
begin
|
||||||
|
if FSource = AValue then exit;
|
||||||
|
if FListener.IsListening then
|
||||||
|
FSource.Broadcaster.Unsubscribe(FListener);
|
||||||
|
FSource := AValue;
|
||||||
|
if FSource <> nil then
|
||||||
|
FSource.Broadcaster.Subscribe(FListener);
|
||||||
|
StyleChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCustomChartAxisMarks.SetStripes(AValue: TChartStyles);
|
procedure TCustomChartAxisMarks.SetStripes(AValue: TChartStyles);
|
||||||
begin
|
begin
|
||||||
if FStripes = AValue then exit;
|
if FStripes = AValue then exit;
|
||||||
@ -674,12 +690,19 @@ begin
|
|||||||
StyleChanged(Self);
|
StyleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomChartAxisMarks.SourceDef: TCustomChartSource;
|
||||||
|
begin
|
||||||
|
Result := FSource;
|
||||||
|
if Result = nil then
|
||||||
|
Result := DefaultSource;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TChartAxisMarks }
|
{ TChartAxisMarks }
|
||||||
|
|
||||||
constructor TChartAxisMarks.Create(AOwner: TCustomChart);
|
constructor TChartAxisMarks.Create(AOwner: TCustomChart);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FListener := TListener.Create(@FSource, @StyleChanged);
|
|
||||||
FRange := TChartRange.Create(AOwner);
|
FRange := TChartRange.Create(AOwner);
|
||||||
FStyle := smsValue;
|
FStyle := smsValue;
|
||||||
FFormat := SERIES_MARK_FORMATS[FStyle];
|
FFormat := SERIES_MARK_FORMATS[FStyle];
|
||||||
@ -688,7 +711,6 @@ end;
|
|||||||
destructor TChartAxisMarks.Destroy;
|
destructor TChartAxisMarks.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FRange);
|
FreeAndNil(FRange);
|
||||||
FreeAndNil(FListener);
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -706,23 +728,6 @@ begin
|
|||||||
StyleChanged(Self);
|
StyleChanged(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartAxisMarks.SetSource(AValue: TCustomChartSource);
|
|
||||||
begin
|
|
||||||
if FSource = AValue then exit;
|
|
||||||
if FListener.IsListening then
|
|
||||||
FSource.Broadcaster.Unsubscribe(FListener);
|
|
||||||
FSource := AValue;
|
|
||||||
if FSource <> nil then
|
|
||||||
FSource.Broadcaster.Subscribe(FListener);
|
|
||||||
StyleChanged(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TChartAxisMarks.SourceDef: TCustomChartSource;
|
|
||||||
begin
|
|
||||||
Result := FSource;
|
|
||||||
if Result = nil then
|
|
||||||
Result := DefaultSource;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TChartBasicAxis }
|
{ TChartBasicAxis }
|
||||||
|
|
||||||
@ -772,6 +777,11 @@ begin
|
|||||||
Result := false;
|
Result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TChartBasicAxis.IsVertical: Boolean;
|
||||||
|
begin
|
||||||
|
Result := Alignment in [calLeft, calRight];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartBasicAxis.SetArrow(AValue: TChartArrow);
|
procedure TChartBasicAxis.SetArrow(AValue: TChartArrow);
|
||||||
begin
|
begin
|
||||||
FArrow.Assign(AValue);
|
FArrow.Assign(AValue);
|
||||||
|
Loading…
Reference in New Issue
Block a user