From 6ed3de7912c671ee40a4e49564d82f4bf73ee0cf Mon Sep 17 00:00:00 2001 From: wp Date: Thu, 24 Jul 2014 16:48:40 +0000 Subject: [PATCH] TAChart: Add property SuppressPrevUnit to TDateTimeIntervalChartSource. Respect FormatSettings.DecimalSeparator for milliseconds display. git-svn-id: trunk@45967 - --- components/tachart/taintervalsources.pas | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/components/tachart/taintervalsources.pas b/components/tachart/taintervalsources.pas index 41ae70d006..955217f984 100644 --- a/components/tachart/taintervalsources.pas +++ b/components/tachart/taintervalsources.pas @@ -60,8 +60,10 @@ type strict private FDateTimeFormat: String; FSteps: TDateTimeSteps; + FSuppressPrevUnit: Boolean; procedure SetDateTimeFormat(AValue: String); procedure SetSteps(AValue: TDateTimeSteps); + procedure SetSuppressPrevUnit(AValue: Boolean); public constructor Create(AOwner: TComponent); override; procedure ValuesInRange( @@ -70,6 +72,8 @@ type property DateTimeFormat: String read FDateTimeFormat write SetDateTimeFormat; property Steps: TDateTimeSteps read FSteps write SetSteps default DATE_TIME_STEPS_ALL; + property SuppressPrevUnit: Boolean + read FSuppressPrevUnit write SetSuppressPrevUnit default true; end; @@ -341,6 +345,7 @@ constructor TDateTimeIntervalChartSource.Create(AOwner: TComponent); begin inherited Create(AOwner); FSteps := DATE_TIME_STEPS_ALL; + FSuppressPrevUnit := true; end; procedure TDateTimeIntervalChartSource.SetDateTimeFormat(AValue: String); @@ -359,6 +364,14 @@ begin Notify; end; +procedure TDateTimeIntervalChartSource.SetSuppressPrevUnit(AValue: Boolean); +begin + if FSuppressPrevUnit = AValue then exit; + FSuppressPrevUnit := AValue; + InvalidateCaches; + Notify; +end; + procedure TDateTimeIntervalChartSource.ValuesInRange( AParams: TValuesInRangeParams; var AValues: TChartValueTextArray); var @@ -381,24 +394,24 @@ var FormatDateTime('/yyyy', AValue); dtsMonth: Result := FormatDateTime( - IfThen(st.Year = prevSt.Year, 'mm', 'mm/yyyy'), AValue); + IfThen(FSuppressPrevUnit and (st.Year = prevSt.Year), 'mm', 'mm/yyyy'), AValue); dtsWeek: Result := FormatDateTime('dd/mm', AValue); dtsDay: Result := FormatDateTime( - IfThen(st.Month = prevSt.Month, 'dd', 'dd/mm'), AValue); + IfThen(FSuppressPrevUnit and (st.Month = prevSt.Month), 'dd', 'dd/mm'), AValue); dtsHour: 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: Result := FormatDateTime( - IfThen(st.Hour = prevSt.Hour, 'nn', 'hh:nn'), AValue); + IfThen(FSuppressPrevUnit and (st.Hour = prevSt.Hour), 'nn', 'hh:nn'), AValue); dtsSecond: Result := FormatDateTime( - IfThen(st.Minute = prevSt.Minute, 'ss', 'nn:ss'), AValue); + IfThen(FSuppressPrevUnit and (st.Minute = prevSt.Minute), 'ss', 'nn:ss'), AValue); dtsMillisecond: 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'; end; if InRange(AValue, helper.FOrigParams.FMin, helper.FOrigParams.FMax) then