unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, TAGraph, TAIntervalSources, TASources, Forms,
Controls, Graphics, Dialogs, StdCtrls, ComCtrls, TATools,
dateutils, tatypes, TASeries, Types, TACustomSeries;
type
{ TForm1 }
TForm1 = class(TForm)
Chart1: TChart;
ChartToolset1: TChartToolset;
ChartToolset1DataPointClickTool1: TDataPointClickTool;
DateTimeIntervalChartSource1: TDateTimeIntervalChartSource;
Label1: TLabel;
Label2: TLabel;
ListChartSource1: TListChartSource;
StatusBar1: TStatusBar;
procedure ChartToolset1DataPointClickTool1AfterMouseDown(ATool: TChartTool;
APoint: TPoint);
procedure FormCreate(Sender: TObject);
private
public
end;
type
hit = record
time: int64;
lat, long, user_n, user_name: string;
end;
var
Form1: TForm1;
Series_ar: array[1..15000] of TLineSeries;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
Detection: array[1..15000] of hit;
f: textfile;
i, j: integer;
cc: int64;
Read_Line: string;
dt: tdatetime;
begin
AssignFile(f, '01.01.2019.txt');
reset(f);
i := 1;
while not EOF(f) do
begin
readln(f, cc);
Detection[i].time := cc;
readln(f, Read_Line);
Detection[i].lat := Read_Line;
readln(f, Read_Line);
Detection[i].long := Read_Line;
readln(f, Read_Line);
Detection[i].user_n := Read_Line;
readln(f, Read_Line);
readln(f, Read_Line);
Detection[i].user_name := Read_Line;
readln(f, Read_Line);
Inc(i);
end;
closefile(f);
for j := Low(Series_ar) to High(Series_ar) do
begin
Series_ar[j] := TLineSeries.Create(Chart1);
Series_ar[j].ShowPoints := True;
Series_ar[j].Pointer.Brush.Color := clRed;
Series_ar[j].Pointer.Pen.Color := clBlack;
Series_ar[j].Pointer.Style := psCircle;
end;
for j := 1 to High(Series_ar) do
begin
if Detection[j].user_n <> '' then
begin
DT := unixToDateTime((Detection[j].time) div 1000);
Series_ar[StrToInt(Detection[j].user_n)].AddXy(dt,
StrToInt(Detection[j].user_n), 'a');
Series_ar[StrToInt(Detection[j].user_n)].Title :=
(Detection[j].user_name) + ' (' + (Detection[j].user_n) + ')';
Chart1.AddSeries(Series_ar[StrToInt(Detection[j].user_n)]);
end;
end;
end;
procedure TForm1.ChartToolset1DataPointClickTool1AfterMouseDown(ATool: TChartTool;
APoint: TPoint);
var
x, y: double;
begin
with ATool as TDatapointClickTool do
if (Series is TLineSeries) then
with TLineSeries(Series) do
begin
x := GetXValue(PointIndex);
y := GetYValue(PointIndex);
Statusbar1.SimpleText := Format('%s: x = %f, y = %f', [Title, x, y]);
end
else
Statusbar1.SimpleText := '';
end;
end.