mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 05:19:18 +02:00
TAChart: Add property SuppressPrevUnit to TDateTimeIntervalChartSource. Respect FormatSettings.DecimalSeparator for milliseconds display.
git-svn-id: trunk@45967 -
This commit is contained in:
parent
04d4a3fff3
commit
6ed3de7912
@ -60,8 +60,10 @@ type
|
|||||||
strict private
|
strict private
|
||||||
FDateTimeFormat: String;
|
FDateTimeFormat: String;
|
||||||
FSteps: TDateTimeSteps;
|
FSteps: TDateTimeSteps;
|
||||||
|
FSuppressPrevUnit: Boolean;
|
||||||
procedure SetDateTimeFormat(AValue: String);
|
procedure SetDateTimeFormat(AValue: String);
|
||||||
procedure SetSteps(AValue: TDateTimeSteps);
|
procedure SetSteps(AValue: TDateTimeSteps);
|
||||||
|
procedure SetSuppressPrevUnit(AValue: Boolean);
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure ValuesInRange(
|
procedure ValuesInRange(
|
||||||
@ -70,6 +72,8 @@ type
|
|||||||
property DateTimeFormat: String read FDateTimeFormat write SetDateTimeFormat;
|
property DateTimeFormat: String read FDateTimeFormat write SetDateTimeFormat;
|
||||||
property Steps: TDateTimeSteps
|
property Steps: TDateTimeSteps
|
||||||
read FSteps write SetSteps default DATE_TIME_STEPS_ALL;
|
read FSteps write SetSteps default DATE_TIME_STEPS_ALL;
|
||||||
|
property SuppressPrevUnit: Boolean
|
||||||
|
read FSuppressPrevUnit write SetSuppressPrevUnit default true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -341,6 +345,7 @@ constructor TDateTimeIntervalChartSource.Create(AOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FSteps := DATE_TIME_STEPS_ALL;
|
FSteps := DATE_TIME_STEPS_ALL;
|
||||||
|
FSuppressPrevUnit := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDateTimeIntervalChartSource.SetDateTimeFormat(AValue: String);
|
procedure TDateTimeIntervalChartSource.SetDateTimeFormat(AValue: String);
|
||||||
@ -359,6 +364,14 @@ begin
|
|||||||
Notify;
|
Notify;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDateTimeIntervalChartSource.SetSuppressPrevUnit(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FSuppressPrevUnit = AValue then exit;
|
||||||
|
FSuppressPrevUnit := AValue;
|
||||||
|
InvalidateCaches;
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDateTimeIntervalChartSource.ValuesInRange(
|
procedure TDateTimeIntervalChartSource.ValuesInRange(
|
||||||
AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
|
AParams: TValuesInRangeParams; var AValues: TChartValueTextArray);
|
||||||
var
|
var
|
||||||
@ -381,24 +394,24 @@ var
|
|||||||
FormatDateTime('/yyyy', AValue);
|
FormatDateTime('/yyyy', AValue);
|
||||||
dtsMonth:
|
dtsMonth:
|
||||||
Result := FormatDateTime(
|
Result := FormatDateTime(
|
||||||
IfThen(st.Year = prevSt.Year, 'mm', 'mm/yyyy'), AValue);
|
IfThen(FSuppressPrevUnit and (st.Year = prevSt.Year), 'mm', 'mm/yyyy'), AValue);
|
||||||
dtsWeek:
|
dtsWeek:
|
||||||
Result := FormatDateTime('dd/mm', AValue);
|
Result := FormatDateTime('dd/mm', AValue);
|
||||||
dtsDay:
|
dtsDay:
|
||||||
Result := FormatDateTime(
|
Result := FormatDateTime(
|
||||||
IfThen(st.Month = prevSt.Month, 'dd', 'dd/mm'), AValue);
|
IfThen(FSuppressPrevUnit and (st.Month = prevSt.Month), 'dd', 'dd/mm'), AValue);
|
||||||
dtsHour:
|
dtsHour:
|
||||||
Result := FormatDateTime(
|
Result := FormatDateTime(
|
||||||
IfThen(st.Day = prevSt.Day, 'hh:00', 'dd hh:00'), AValue);
|
IfThen(FSuppressPrevUnit and (st.Day = prevSt.Day), 'hh:00', 'dd hh:00'), AValue);
|
||||||
dtsMinute:
|
dtsMinute:
|
||||||
Result := FormatDateTime(
|
Result := FormatDateTime(
|
||||||
IfThen(st.Hour = prevSt.Hour, 'nn', 'hh:nn'), AValue);
|
IfThen(FSuppressPrevUnit and (st.Hour = prevSt.Hour), 'nn', 'hh:nn'), AValue);
|
||||||
dtsSecond:
|
dtsSecond:
|
||||||
Result := FormatDateTime(
|
Result := FormatDateTime(
|
||||||
IfThen(st.Minute = prevSt.Minute, 'ss', 'nn:ss'), AValue);
|
IfThen(FSuppressPrevUnit and (st.Minute = prevSt.Minute), 'ss', 'nn:ss'), AValue);
|
||||||
dtsMillisecond:
|
dtsMillisecond:
|
||||||
Result :=
|
Result :=
|
||||||
IfThen(st.Second = prevSt.Second, '', IntToStr(st.Second) + '.') +
|
IfThen(FSuppressPrevUnit and (st.Second = prevSt.Second), '', IntToStr(st.Second) + DefaultFormatSettings.DecimalSeparator) +
|
||||||
IntToStr(st.Millisecond) + 'ms';
|
IntToStr(st.Millisecond) + 'ms';
|
||||||
end;
|
end;
|
||||||
if InRange(AValue, helper.FOrigParams.FMin, helper.FOrigParams.FMax) then
|
if InRange(AValue, helper.FOrigParams.FMin, helper.FOrigParams.FMax) then
|
||||||
|
Loading…
Reference in New Issue
Block a user