mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-19 19:09:28 +01:00
TAChart: Add TUserDefinedChartSource.
git-svn-id: trunk@20171 -
This commit is contained in:
parent
104cd2a598
commit
ea1dd89ad9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1581,6 +1581,7 @@ components/tachart/tatypes.pas svneol=native#text/plain
|
||||
components/tachart/tchart.png -text svneol=unset#images/png
|
||||
components/tachart/tlistchartsource.png -text
|
||||
components/tachart/trandomchartsource.png -text
|
||||
components/tachart/tuserdefinedchartsource.png -text
|
||||
components/tdbf/Makefile svneol=native#text/plain
|
||||
components/tdbf/Makefile.fpc svneol=native#text/plain
|
||||
components/tdbf/dbflaz.lpk svneol=native#text/pascal
|
||||
|
||||
@ -47,3 +47,19 @@ LazarusResources.Add('trandomchartsource','PNG',[
|
||||
+'R7Z'#240#194#193#245#179'$s'#29#187#154''#9#243#2#216#181'Oxpg'#233#138#0#0
|
||||
+#0#0'IEND'#174'B`'#130
|
||||
]);
|
||||
LazarusResources.Add('tuserdefinedchartsource','PNG',[
|
||||
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
|
||||
+#0#0#4'gAMA'#0#0#177#143#11#252'a'#5#0#0#0#24'tEXtSoftware'#0'Paint.NET v3.3'
|
||||
+'17'#131'w'#134#0#0#0#242'IDATHK'#221#150#189#13#194'0'#16#133#179#134#23#161
|
||||
+#14'm'#134#160#164'`'#1#139#13#168'3'#0';'#176'AB'#205#6#20#25#229#224#157'8'
|
||||
+'t'#186#152'p'#198#166'I'#164''''#197'v'#252'>'#159#207'?i'#154#213'<1'#246
|
||||
+'TK'#201'I'#129'y'#141#7'>'#215'a'#164#25'D'#0#207#6'4~'#213'4'#221#201#10
|
||||
+#198'.'#128'D'#178#239'o$'#218#30#199'w'#128'!'#132#153'9`Y'#0#24'kS]'#174#2
|
||||
+#176#249#248'+'#192'FS5'#2'k'#142#200'4'#128#206';'#130#178's'#176#180'd'#177
|
||||
+#202'd'#5#21#3'l'#4'0'#167#182'e'#1'R'#12#208#145#240#254'8'#29'X'#26#128'r'
|
||||
+#214#20'}'#218'h]Gl$'#16#251#238#218#7#220#233'5'#199#241#178'!'#8'u0'#23#0
|
||||
+'F/'#16#142'&'''#201'^'#128'@'#178's'#144#3#248')'#201#2#240#28'x'#250#27'w'
|
||||
+#146'S'#167#164#183#206#149'd|T'#162#197#227#186#214#141#150#188'pp'#3#149
|
||||
+#140#220#246']'#205#191'D'#243#0#193'1'#145#19#186#2'@'#31#0#0#0#0'IEND'#174
|
||||
+'B`'#130
|
||||
]);
|
||||
|
||||
@ -144,6 +144,33 @@ type
|
||||
property YMin: Double read FYMin write SetYMin;
|
||||
end;
|
||||
|
||||
TUserDefinedChartSource = class;
|
||||
|
||||
TGetChartDataItemEvent = procedure (
|
||||
ASource: TUserDefinedChartSource; AIndex: Integer;
|
||||
var AItem: TChartDataItem) of object;
|
||||
|
||||
{ TUserDefinedChartSource }
|
||||
|
||||
TUserDefinedChartSource = class(TCustomChartSource)
|
||||
private
|
||||
FItem: TChartDataItem;
|
||||
FOnGetChartDataItem: TGetChartDataItemEvent;
|
||||
FPointsNumber: Integer;
|
||||
procedure SetOnGetChartDataItem(const AValue: TGetChartDataItemEvent);
|
||||
procedure SetPointsNumber(const AValue: Integer);
|
||||
protected
|
||||
function GetCount: Integer; override;
|
||||
function GetItem(AIndex: Integer): PChartDataItem; override;
|
||||
public
|
||||
procedure Reset; inline;
|
||||
published
|
||||
property OnGetChartDataItem: TGetChartDataItemEvent
|
||||
read FOnGetChartDataItem write SetOnGetChartDataItem;
|
||||
property PointsNumber: Integer
|
||||
read FPointsNumber write SetPointsNumber default 0;
|
||||
end;
|
||||
|
||||
function DoublePoint(const ACoord: TChartDataItem): TDoublePoint; inline; overload;
|
||||
procedure Register;
|
||||
|
||||
@ -179,7 +206,8 @@ end;
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents(
|
||||
CHART_COMPONENT_IDE_PAGE, [TListChartSource, TRandomChartSource]);
|
||||
CHART_COMPONENT_IDE_PAGE,
|
||||
[TListChartSource, TRandomChartSource, TUserDefinedChartSource]);
|
||||
end;
|
||||
|
||||
{ TCustomChartSource }
|
||||
@ -684,5 +712,43 @@ begin
|
||||
FIsListening := false;
|
||||
end;
|
||||
|
||||
{ TUserDefinedChartSource }
|
||||
|
||||
function TUserDefinedChartSource.GetCount: Integer;
|
||||
begin
|
||||
Result := FPointsNumber;
|
||||
end;
|
||||
|
||||
function TUserDefinedChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
||||
begin
|
||||
FItem.X := 0;
|
||||
FItem.Y := 0;
|
||||
FItem.Color := clTAColor;
|
||||
if Assigned(FOnGetChartDataItem) then
|
||||
FOnGetChartDataItem(Self, AIndex, FItem);
|
||||
Result := @FItem;
|
||||
end;
|
||||
|
||||
procedure TUserDefinedChartSource.Reset;
|
||||
begin
|
||||
InvalidateCaches;
|
||||
Notify;
|
||||
end;
|
||||
|
||||
procedure TUserDefinedChartSource.SetOnGetChartDataItem(
|
||||
const AValue: TGetChartDataItemEvent);
|
||||
begin
|
||||
if FOnGetChartDataItem = AValue then exit;
|
||||
FOnGetChartDataItem := AValue;
|
||||
Reset;
|
||||
end;
|
||||
|
||||
procedure TUserDefinedChartSource.SetPointsNumber(const AValue: Integer);
|
||||
begin
|
||||
if FPointsNumber = AValue then exit;
|
||||
FPointsNumber := AValue;
|
||||
Reset;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
BIN
components/tachart/tuserdefinedchartsource.png
Normal file
BIN
components/tachart/tuserdefinedchartsource.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 351 B |
Loading…
Reference in New Issue
Block a user