Code: Select all
Chart1:=TChart.Create(Self);
with Chart1 do
begin
Parent:=Self;
AllowPanning:=TPanningMode.pmNone;
BackWall.Brush.Color:=TAlphaColors.White;
BackWall.Color:=TAlphaColors.White;
BackWall.Visible:=False;
BottomWall.Visible:=False;
LeftWall.Visible:=False;
Legend.Visible:=False;
// Title.Text.Strings[1]:='EKM-Mobile Weekly Report';
Title.Visible:=False;
AxisVisible:=False;
BottomAxis.Automatic:=False;
BottomAxis.AutomaticMaximum:=False;
BottomAxis.AutomaticMinimum:=False;
BottomAxis.Axis.Visible:=False;
BottomAxis.Grid.Visible:=False;
BottomAxis.Labels:=False;
BottomAxis.LabelsFormat.Visible:=False;
BottomAxis.Title.Visible:=False;
BottomAxis.Visible:=False;
Panning.MouseWheel:=pmwNone;
Shadow.Visible:=False;
View3DOptions.Orthogonal:=False;
View3DWalls:=False;
Zoom.Allow:=False;
Zoom.Brush.Kind:=TBrushKind.None;
Zoom.Pen.Visible:=False;
BevelOuter:=bvNone;
Color:=TAlphaColors.White;
Enabled:=False;
TabOrder:=0;
EnableDragHighlight:=False;
Size.PlatformDefault:=False;
Size.Width:=842;
Size.Height:=597;
OnAfterDraw:=Chart1AfterDraw;
end;
procedure TEditMonitoringForm.Chart1AfterDraw(Sender: TObject);
const
ThickPen=1.0;
ThinPen=0.5;
RepTitle='WEEKLY MONITORING';
var
I,J:Integer;
Query:TFDQuery;
WeekCommencingDate:TDate;
Tots,Vals:array[1..11] of Single;
FName,Comments:String;
FontList:TStringList;
begin
Inc(DrawCount);
// Chart1.Canvas.Draw(700,15,Image1.Bitmap);
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoHorizLine(42,800,100); // 1st horizontal line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoHorizLine(142,582,125); // 2nd horizontal line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoHorizLine(42,800,150); // 3rd horizontal line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoVertLine(42,100,400); // 1st vertical line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoVertLine(102,100,360); // 2nd vertical ine
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoVertLine(142,100,400); // 3rd vertical line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoVertLine(182,125,400); // 4th vertical line
Chart1.Canvas.DoVertLine(222,125,400); // 5th vertical line
Chart1.Canvas.DoVertLine(262,125,400); // 6th vertical line
Chart1.Canvas.DoVertLine(302,125,400); // 7th vertical line
Chart1.Canvas.DoVertLine(342,125,400); // 8th vertical line
Chart1.Canvas.DoVertLine(382,125,400); // 9th vertical line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoVertLine(422,100,400); // 10th vertical line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoVertLine(462,125,360); // 11th vertical line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoVertLine(502,100,360); // 12th vertical line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoVertLine(542,125,360); // 13th vertical line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoVertLine(582,100,360); // 14th vertical line
Chart1.Canvas.DoVertLine(800,100,360); // 15th vertical line
Chart1.Canvas.Pen.Width:=ThinPen;
Chart1.Canvas.DoHorizLine(42,800,180); // 4th horizontal line
Chart1.Canvas.DoHorizLine(42,800,210); // 5th horizontal line
Chart1.Canvas.DoHorizLine(42,800,240); // 6th horizontal line
Chart1.Canvas.DoHorizLine(42,800,270); // 7th horizontal line
Chart1.Canvas.DoHorizLine(42,800,300); // 8th horizontal line
Chart1.Canvas.DoHorizLine(42,800,330); // 9th horizontal line
Chart1.Canvas.Pen.Width:=ThickPen;
Chart1.Canvas.DoHorizLine(42,800,360); // 10th horizontal line
Chart1.Canvas.DoHorizLine(42,422,400); // 11th horizontal line
Chart1.Canvas.Font.Family:='Helvetica';
Chart1.Canvas.Font.Size:=14;
Chart1.Canvas.Font.Color:=TAlphaColors.Black;
Chart1.Canvas.TextAlign:=TA_LEFT;
Chart1.Canvas.Font.Style:=[TFontStyle.fsBold,TFontStyle.fsUnderline];
Chart1.Canvas.TextOut(350,20,RepTitle);
Chart1.Canvas.Pen.Width:=ThickPen;
// Chart1.Canvas.DoHorizLine(((800-PDF.TextWidth(RepTitle)) div 2)+2,((800-PDF.TextWidth(RepTitle)) div 2)+
// Chart1.Canvas.TextWidth(RepTitle)+2,17+PDF.TextHeight(RepTitle)); // Underline Title
Chart1.Canvas.Font.Size:=11;
Chart1.Canvas.Font.Style:=[TFontStyle.fsBold];
Chart1.Canvas.TextOut(42,60,'Name:');
Chart1.Canvas.TextOut(200,60,'Week commencing:');
Chart1.Canvas.TextOut(500,60,'Weight at end of week:');
Chart1.Canvas.TextOut(58,118,'Date');
Chart1.Canvas.TextOut(111,118,'Day');
Chart1.Canvas.TextOut(200,105,'Number of seizures of each type');
Chart1.Canvas.TextOut(160,124,'1');
Chart1.Canvas.TextOut(200,124,'2');
Chart1.Canvas.TextOut(240,124,'3');
Chart1.Canvas.TextOut(280,124,'4');
Chart1.Canvas.TextOut(320,124,'5');
Chart1.Canvas.TextOut(360,124,'6');
Chart1.Canvas.TextOut(400,124,'7');
Chart1.Canvas.TextOut(153,136,'Abs');
Chart1.Canvas.TextOut(193,136,'Myo');
Chart1.Canvas.TextOut(230,136,'Drop');
Chart1.Canvas.TextOut(269,136,'Tonic');
Chart1.Canvas.TextOut(313,136,'T/C');
Chart1.Canvas.TextOut(348,136,'Focal');
Chart1.Canvas.TextOut(388,136,'Other');
Chart1.Canvas.TextOut(440,100,'Blood or');
Chart1.Canvas.TextOut(429,111,'urine ketones');
Chart1.Canvas.TextOut(526,100,'Blood');
Chart1.Canvas.TextOut(520,111,'glucose');
Chart1.Canvas.TextOut(434,130,'AM');
Chart1.Canvas.TextOut(474,130,'PM');
Chart1.Canvas.TextOut(514,130,'AM');
Chart1.Canvas.TextOut(554,130,'PM');
Chart1.Canvas.TextOut(620,104,'Comments on any illness or');
Chart1.Canvas.TextOut(625,118,'changes to diet, activity or');
Chart1.Canvas.TextOut(670,132,'<strong>medication</strong>',true);
Chart1.Canvas.TextOut(90,373,'Total');
Chart1.Canvas.Font.Style:=[];
Chart1.Canvas.TextOut(111,157,'Sun');
Chart1.Canvas.TextOut(111,187,'Mon');
Chart1.Canvas.TextOut(111,217,'Tue');
Chart1.Canvas.TextOut(111,247,'Wed');
Chart1.Canvas.TextOut(111,277,'Thu');
Chart1.Canvas.TextOut(111,307,'Fri');
Chart1.Canvas.TextOut(111,337,'Sat');
WeekCommencingDate:=IncDay(StartOfTheWeek(lblDate.TagFloat),-1);
Query:=TFDQuery.Create(Nil);
Query.Connection:=MainForm.FDConnection;
for I:=1 to 11 do
Tots[I]:=0;
for I:=1 to 7 do
begin
Chart1.Canvas.TextOut(44,157+((I-1)*30),FormatDateTime('dd/mm/yyyy',IncDay(WeekCommencingDate,I-1)));
Query.SQL.Text:='select * from MonitorDay where PatientID='+qPatients.FieldByName('ID').AsString+' and DayDate='+
QuotedStr(FormatDateTime('YYYY-MM-DD',IncDay(WeekCommencingDate,I-1)));
Query.Open;
if Query.IsEmpty then
begin
Comments:='';
for J:=1 to 11 do
Vals[J]:=0;
end else
begin
Comments:=Query.FieldByName('Comments').AsString;
for J:=1 to 7 do
Vals[J]:=Query.FieldByName('Seize'+IntToStr(J)).AsInteger;
Vals[8]:=Query.FieldByName('KetonesAM').AsFloat;
Vals[9]:=Query.FieldByName('KetonesPM').AsFloat;
Vals[10]:=Query.FieldByName('GlucoseAM').AsFloat;
Vals[11]:=Query.FieldByName('GlucosePM').AsFloat;
end;
for J:=1 to 7 do
begin
Tots[J]:=Tots[J]+Vals[J];
Chart1.Canvas.TextOut(153+((J-1)*40),157+((I-1)*30),Format('%4d',[Round(Vals[J])]));
end;
for J:=8 to 11 do
begin
Chart1.Canvas.TextOut(155+((J-1)*40),157+((I-1)*30),Format('%3.1f',[Vals[J]]));
end;
if Comments<>'' then
Chart1.Canvas.TextOut(584,157+((I-1)*30),Comments);
Query.Close;
end;
for J:=1 to 7 do
Chart1.Canvas.TextOut(153+((J-1)*40),373,Format('%4d',[Round(Tots[J])]));
Query.DisposeOf;
if DrawCount=1 then
begin
FName:=GetFullPathName('Weekly.pdf');
if FileExists(FName) then
DeleteFile(FName);
TeeSaveToPDFFile(Chart1,FName,Round(Chart1.Width),Round(Chart1.Height));
// DisplayPDFFile(FName);
Chart1.Visible:=False;
end;
end;