Page 1 of 1

Dashboard Functionality

Posted: Thu Jun 02, 2016 4:27 pm
by 16578095
I'm looking to use the dashboard component but can't find much in the way of documentation.

Specifically I would like to:

Print the entire dashboard and all its charts.
Load and Save editor settings.
Add charts at runtime to the dashboard.

Any clues where to look please?

Re: Dashboard Functionality

Posted: Fri Jun 03, 2016 10:55 am
by yeray
Hello,
OSNick wrote:Print the entire dashboard and all its charts.
I've seen the positions and the size of the charts seems to be lost when printing. I'll be back to you asap.
OSNick wrote:Load and Save editor settings.
Note the TDashBoard is basically a TChart with a TSubChartTool. It is designed so you can easily add SubCharts to the DashBoard.
There are a couple of tickets reporting issues about the Dashboard not saving some properties into the .dfm. In case this is what you are finding problems with:
http://bugs.teechart.net/show_bug.cgi?id=1314
http://bugs.teechart.net/show_bug.cgi?id=1315
OSNick wrote:Add charts at runtime to the dashboard.
Ie:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  DashBoard1.AddChart('Chart1').AddSeries(TBarSeries).FillSampleValues;
  DashBoard1.AddChart('Chart2').AddSeries(TLineSeries).FillSampleValues;
  DashBoard1.AddChart('Chart2').AddSeries(TPieSeries).FillSampleValues;
end;

Re: Dashboard Functionality

Posted: Mon Jun 06, 2016 2:59 pm
by yeray
Hello,
Yeray wrote:I've seen the positions and the size of the charts seems to be lost when printing. I'll be back to you asap.
I've added this to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1554

We have a fix in the works.

Re: Dashboard Functionality

Posted: Tue Jun 07, 2016 1:15 pm
by yeray
Hello,
Yeray wrote:I've added this to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1554
We've just closed the ticket.

The fix consists on:

Code: Select all

--- a/TeeSubChart.pas
+++ b/TeeSubChart.pas
@@ -17,6 +17,11 @@ uses
 
   {$IFDEF FMX}
   FMX.Types, System.UITypes,
+
+  {$IFDEF D19}
+  FMX.Graphics,
+  {$ENDIF}
+
   {$IFDEF D17}
   System.UIConsts,
   {$ENDIF}
@@ -382,20 +387,57 @@ begin
 end;
 
+type
+  TCustomTeePanelAccess=class(TCustomTeePanel);
+
 procedure TSubChartTool.ChartEvent(AEvent: TChartToolEvent);
+
+  {$IFNDEF FMX}
+  procedure ApplyMetaScale(var R:TRect);
+  var tmp : TRect;
+      tmpR : TRect;
+      tmpW,
+      tmpH,
+      tmpX,
+      tmpY : Single;
+  begin
+    tmp:=ParentChart.ChartPrintRect;
+    tmpR:=ParentChart.GetRectangle;
+
+    tmpW:=(tmpR.Right-tmpR.Left);
+    tmpX:=(tmp.Right-tmp.Left)/tmpW;
+
+    R.Left:=Round(R.Left*tmpX);
+    R.Right:=Round(R.Right*tmpX);
+
+    tmpH:=(tmpR.Bottom-tmpR.Top);
+    tmpY:=(tmp.Bottom-tmp.Top)/tmpH;
+
+    R.Top:=Round(R.Top*tmpY);
+    R.Bottom:=Round(R.Bottom*tmpY);
+  end;
+  {$ENDIF}
+
 var t : Integer;
+    tmp : TCanvas;
+    tmpR : TRect;
+
+    {$IFNDEF FMX}
+    tmpScale : Boolean;
+    {$ENDIF}
 begin
   inherited;
 
   if Active and (AEvent=cteAfterDraw) and Assigned(ParentChart) then
-     for t:=0 to Charts.Count-1 do
-     with Charts[t] do
-     if Chart.Visible then
-     begin
-       // NOT A GOOD IDEA: Chart.View3D:=Self.ParentChart.View3D;
+  begin
+    tmp:=ParentChart.Canvas.ReferenceCanvas;
+
+    {$IFNDEF FMX}
+    tmpScale:=ParentChart.Printing and
+              ParentChart.Canvas.Metafiling and
+              TCustomTeePanelAccess(ParentChart).IsPrinterCanvas;
+    {$ENDIF}
+
-       Chart.BufferedDisplay:=False;
-       Chart.Draw(Self.ParentChart.Canvas.ReferenceCanvas,Bounds);
-     end;
+    for t:=0 to Charts.Count-1 do
+    with Charts[t] do
+    if Chart.Visible then
+    begin
+      Chart.BufferedDisplay:=False;
+
+      tmpR:=Bounds;
+      OffsetRect(tmpR,ParentChart.ChartBounds.Left,
+                      ParentChart.ChartBounds.Top);
+
+      {$IFNDEF FMX}
+      if tmpScale then
+         ApplyMetaScale(tmpR);
+      {$ENDIF}
+
+      Chart.Draw(tmp,tmpR);
+    end;
+  end;
 end;
 
 procedure TSubChartTool.ChartMouseEvent(AEvent: TChartMouseEvent;
@@ -1168,9 +1171,6 @@ end;
 
 { TChartCollection }
 
-type
-  TCustomTeePanelAccess=class(TCustomTeePanel);
-
 function TChartCollection.AddChart(const AName: String=''): TChart;
 var tmp : TCustomTeePanel;
 begin
-- 
-- 

Code: Select all

--- a/TeeProcs.pas
+++ b/TeeProcs.pas
@@ -439,6 +439,7 @@ type
     FCustomChartRect : Boolean;
     IsEmbedded       : Boolean;
     InternalCanvas   : TCanvas3D;
+    IsPrinterCanvas  : Boolean;
 
     Procedure ApplyMargins;
 
@@ -3591,7 +3592,9 @@ begin
   // FMX TODO: Change Scale.X and Y
 
   SetAnisotropic;
+
   FPrinting:=True;
+  IsPrinterCanvas:=True;
   try
     if CanClip then ClipCanvas(PrintCanvas,tmpR);
 
@@ -3601,6 +3604,7 @@ begin
     DrawToMetaCanvas(PrintCanvas,tmpR);
     UnClipCanvas(PrintCanvas);
   finally
+    IsPrinterCanvas:=False;
     FPrinting:=False;
   end;

Re: Dashboard Functionality

Posted: Tue Jun 21, 2016 3:49 pm
by 16578095
Thanks for the update (just got back onto this). Is it possible to have an updated .pas please? I'm always nervous about editing your source files.

Re: Dashboard Functionality

Posted: Wed Jun 22, 2016 9:50 am
by yeray
Hello,

I've just sent you a mail with the modified units.

Re: Dashboard Functionality

Posted: Thu Jun 23, 2016 9:03 am
by 16578095
Thank you for sending the units. Unfortunately I am using version 'Teechart Pro 2014 Components' (as I couldn't install the latest version). The units you send give compilation errors

Could I have the 2014 versions please?

Re: Dashboard Functionality

Posted: Thu Jun 23, 2016 10:28 am
by yeray
Hello,
OSNick wrote:Could I have the 2014 versions please?
I'm not sure if it will be possible. v2014.11 or v2014.12?

Re: Dashboard Functionality

Posted: Thu Jun 23, 2016 2:43 pm
by 16578095
v2014.12 is my version.

I tried re-installing the latest version into D2007, but I get errors loading Delphi - cannot load bpl files.

Re: Dashboard Functionality

Posted: Mon Jun 27, 2016 9:27 am
by narcis
HI OSNick,

Which exact error message(s) do you get?

BTW, this thread may help setting up your environment.