From 518cb42e0e4039f6b0afc256dcc012b97c752428 Mon Sep 17 00:00:00 2001 From: ask Date: Sun, 1 Aug 2010 03:12:12 +0000 Subject: [PATCH] TAChart: Add TDateTimeIntervalChartSource component git-svn-id: trunk@26949 - --- components/tachart/tagraph.lrs | 28 ++++++ components/tachart/tasources.pas | 141 ++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 3 deletions(-) diff --git a/components/tachart/tagraph.lrs b/components/tachart/tagraph.lrs index 18b913a2d2..f9f91c9c08 100644 --- a/components/tachart/tagraph.lrs +++ b/components/tachart/tagraph.lrs @@ -53,6 +53,34 @@ LazarusResources.Add('tcharttoolset','PNG',[ +'k'#209#191#237#154#175#137'Vr'#224#208#4#170#229#230'?'#207#214#205#191#132 +#224#11'M'#1#188'+SC'#237'5'#0#0#0#0'IEND'#174'B`'#130 ]); +LazarusResources.Add('tdatetimeintervalchartsource','PNG',[ + #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175 + +#0#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0#25'tEXtSoftware'#0'Paint.NET v3' + +'.5.4>'#141#204'v'#0#0#2#8'IDAT8O'#173#148#205'K'#27'A'#24#198#211'JhO9'#22 + +#165#208#155#133#226#7#133'^"T'#15#214#180#7#15'AAi'#169#169#10#162'F'#165 + +#196#4'kl'#226'GP'#188'm'#210#216#180'$'#209#172'D'#189#148'&1'#238'jL'#168 + +#174#237'6'#179#206#236#236#244#149#149'HkLv'#163#195#195'2,'#179#191'y'#222 + +'wg'#158'{'#140'1'#203#157#12#0#221#201#176#232#20#187'}'#164'>'#149'M\'#129 + +#224#21'B'#232'P'#204#243#252#174#199#19#240#249#2#28#199#185'\'#174'*~a'#239 + +#207#161#176#190#224#10#148#203#229#230'}'#139#179#222#165#181#245'P'#146#223 + +#203#29#28#18#140#131#171'k'#177'X<'#147#249'~]'#128#168#12#154#157#251'('#22 + +#138#197#19'I'#250#245'['#150'e'#132#20'U'#211#246#5#161#199#254#218#28#232 + +#131'w'#238#172#132#148's'#172#230#243#148#223#166#209'(I'#167#21'B'#28#131 + +'oR'#169#148#9'G'#206#209#177't'#225#148'P'#138#243#199#10'B$'#153#164#28'G4' + +'mc{oh'#200'i'#2#20#253#26#243#135'y'#172'1DY'#169#132'p('#172#186#221'$'#181 + +'#)'#164#239#221#176#9#144'('#136#3#147#139'G'#152')'#132#201'T'#147'U'#149 + +#184#221#216#31#160#170':'#245'i%'#158'H'#232',6'#211#10#130#201#141#205#198 + +#24#191#29#157#158#231'%'#25'L'#197#226#212#235'QW'#131'''?'#165#31#18#243'~' + +#203#188#234'u'#24#5#193'Y'#216#136'D'#218#251#23#14#254#176'3'#229' '' then + exit(FormatDateTime(DateTimeFormat, x)); + DateTimeToSystemTime(x, st); + case s of + dtsCentury, dtsDecade, dtsYear: + Result := FormatDateTime('yyyy', x); + dtsQuarter: + Result := FormatDateTime('yyyy/', x) + IntToStr(Floor(x / si) mod 4 + 1); + dtsMonth: + Result := FormatDateTime( + IfThen(st.Year = prevSt.Year, 'mm', 'mm/yyyy'), x); + dtsWeek: + Result := FormatDateTime('dd/mm', x); + dtsDay: + Result := FormatDateTime( + IfThen(st.Month = prevSt.Month, 'dd', 'dd/mm'), x); + dtsHour: + Result := FormatDateTime( + IfThen(st.Day = prevSt.Day, 'hh:00', 'dd hh:00'), x); + dtsTenMinutes, dtsMinute: + Result := FormatDateTime( + IfThen(st.Hour = prevSt.Hour, 'nn', 'hh:nn'), x); + dtsTenSeconds, dtsSecond: + Result := FormatDateTime( + IfThen(st.Minute = prevSt.Minute, 'ss', 'nn:ss'), x); + dtsMillisecond: + Result := IntToStr(st.Millisecond) + 'ms'; + end; + prevSt := st; + end; + +var + i, cnt: Integer; +begin + if (AMax - AMin) / STEP_INTERVALS[dtsCentury] > MAX_STEPS then begin + inherited ValuesInRange( + AMin / STEP_INTERVALS[dtsYear], AMax / STEP_INTERVALS[dtsYear], + AFormat, AUseY, AValues, ATexts); + exit; + end; + s := Low(s); + while s < High(s) do begin + si := STEP_INTERVALS[s]; + if (s in Steps) and ((AMax - AMin) / si > MIN_STEPS) then + break; + Inc(s); + end; + start := Int(AMin / si - 1) * si; + x := start; + cnt := 0; + while x <= AMax do begin + if x >= AMin then + cnt += 1; + x += si; + end; + i := Length(AValues); + SetLength(AValues, i + cnt); + SetLength(ATexts, i + cnt); + + FillChar(prevSt, SizeOf(prevSt), $FF); + x := start; + while x <= AMax do begin + if x >= AMin then begin + AValues[i] := x; + ATexts[i] := Format(AFormat, [x, 0.0, FormatLabel, 0.0, 0.0]); + i += 1; + end; + case s of + dtsCentury: x := IncYear(x, 100); + dtsDecade: x := IncYear(x, 10); + dtsYear: x := IncYear(x); + dtsMonth: x := IncMonth(x); + otherwise x += si; + end; + end; +end; + { TUserDefinedChartSource } function TUserDefinedChartSource.GetCount: Integer;