vcl-dxdashboard-dot-tdxdashboard.md
Provides access to the dashboard layout definition (in the XML format).
property Layout: TStringList read;
| Type | Description |
|---|---|
| TStringList |
Stores the current dashboard layout (as individual strings in the XML format).
|
A dashboard layout definition contains data visualization items, properties, data bindings, and general layout information. You can use the Layout property to load, save, and access the dashboard layout.
Call Layout.LoadFromFile/Layout.LoadFromStream and Layout.SaveToFile/Layout.SaveToStream procedures to import and export configured dashboard layouts in the XML format.
In addition, you can use Layout.Strings and Layout.Text properties to access and modify dashboard layout content directly (if required).
Refer to the TStringList class description for detailed information on all available options.
The State property allows you to load and apply a previously saved dashboard user interaction state that includes filter criteria, drill-down values, the active tab page, dashboard parameter values, individual data visualization item states, and other configuration options set by users.
The following code example configures a memory-based data source (TdxBackendInMemoryJSONConnection), loads an XML dashboard layout, and exports dashboard content to a PDF file without user interaction:
uses
dxBackend.ConnectionString.JSON, // Declares the TdxBackendInMemoryJSONConnection component
dxDashboard; // Declares the TdxDashboard class
// ...
procedure TMyForm.cxExportButtonClick(Sender: TObject);
var
ADashboard: TdxDashboard;
AJSONDataConnection: TdxBackendInMemoryJSONConnection;
AMemoryStream: TMemoryStream;
AFileName, AJSONData: string;
begin
// Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows:
AJSONData :=
'[{"id": 1, "Region": "Asia", "Sales": 4.7685},' + // Row #1
'{"id": 2, "Region": "Australia", "Sales": 1.9576},' + // Row #2
'{"id": 3, "Region": "Europe", "Sales": 3.3579},' + // Row #3
'{"id": 4, "Region": "North America", "Sales": 3.7477},' + // Row #4
'{"id": 5, "Region": "South America", "Sales": 1.8237}]'; // Row #5
AJSONDataConnection := TdxBackendInMemoryJSONConnection.Create(Self); // Creates a data connection
try
AJSONDataConnection.Name := 'JSONData'; // Assigns a name to the created data connection
AJSONDataConnection.SetJSONValue(AJSONData); // Assigns the defined JSON data string
ADashboard := TdxDashboard.Create(Self); // Creates a TdxDashboard container
try
ADashboard.Layout.LoadFromFile('MyDashboardLayout.xml'); // Loads an XML dashboard layout
ADashboard.Name := 'MyDashboard'; // Defines a dashboard name
AMemoryStream := TMemoryStream.Create; // Creates a memory stream
try
// Export dashboard content to the created memory stream in the PDF format
ADashboard.ExportTo(TdxDashboardExportFormat.PDF, AMemoryStream, AFileName);
AMemoryStream.SaveToFile(AFileName); // Saves the resulting PDF file
finally
AMemoryStream.Free; // Releases the memory stream
end;
finally
ADashboard.Free; // Releases the TdxDashboard container
end;
finally
AJSONDataConnection.Free; // Releases the data connection
end;
end;
#include "dxBackend.ConnectionString.JSON.hpp" // Declares the TdxBackendInMemoryJSONConnection component
#include "dxDashboard.hpp" // Declares the TdxDashboard class
// Add the following linker directives to the corresponding CPP source file:
#pragma link "dxDashboard" // Required to use dxDashboard.hpp declarations
#if defined(_WIN64) // Required to use dxBackend.ConnectionString.JSON.hpp declarations
#pragma link "dxBackend.ConnectionString.JSON.o"
#else
#pragma link "dxBackend.ConnectionString.JSON.obj"
#endif
// ...
void __fastcall TMyForm::cxExportButtonClick(TObject *Sender)
{
TdxDashboard *ADashboard;
TdxBackendInMemoryJSONConnection *AJSONDataConnection;
TMemoryStream *AMemoryStream;
UnicodeString AFileName;
// Define a table that consists of three columns ("id", "Region", and "Sales") and five data rows:
UnicodeString AJSONData =
"[{\"id\": 1, \"Region\": \"Asia\", \"Sales\": 1.9576}," // Row #1
"{\"id\": 2, \"Region\": \"Australia\", \"Sales\": 1.9576}," // Row #2
"{\"id\": 3, \"Region\": \"Europe\", \"Sales\": 3.3579}," // Row #3
"{\"id\": 4, \"Region\": \"North America\", \"Sales\": 3.7477}," // Row #4
"{\"id\": 5, \"Region\": \"South America\", \"Sales\": 1.8237}]" // Row #5
AJSONDataConnection = new TdxBackendInMemoryJSONConnection(this); // Creates a data connection
try
{
AJSONDataConnection->Name = "JSONData"; // Assigns a name to the created data connection
AJSONDataConnection->SetJSONValue(AJSONData); // Assigns the defined JSON data string
ADashboard = new TdxDashboard(this); // Creates a TdxDashboard container
try
{
ADashboard->Layout->LoadFromFile("MyDashboardLayout.xml"); // Loads an XML dashboard layout
ADashboard->Name = "MyDashboard"; // Defines a dashboard name
AMemoryStream = new TMemoryStream(); // Creates a memory stream
try
{
// Export dashboard content to the created memory stream in the PDF format
ADashboard->ExportTo(TdxDashboardExportFormat::PDF, AMemoryStream, AFileName);
AMemoryStream->SaveToFile(AFileName); // Saves the resulting PDF file
}
__finally
{
delete AMemoryStream; // Releases the memory stream
}
}
__finally
{
delete ADashboard; // Releases the TdxDashboard container
}
}
__finally
{
delete AJSONDataConnection; // Releases the data connection
}
}
See Also