Flexmonster Software License Agreement (“Agreement”) has been revised and is effective as of January 8, 2025.
The following modifications were made:
The modified version of Agreement is available here.
Downloading, installing, and/or continuing to use Flexmonster Software after January 8, 2025, constitutes Licensee’s acceptance of the terms and conditions of the modified version of Agreement. If Licensee does not agree to any of these terms and conditions, they must cease using Flexmonster Software and must not download, install, use, access, or continue to access Flexmonster Software. By continuing to use Flexmonster Software or renewing the license or maintenance after the effective date of these modifications to Agreement, Licensee accepts and agrees to be bound by the terms and conditions of the modified Agreement.
For a quick start in using the custom data source API, we have prepared a sample .NET Core server that implements it. The sample .NET Core server allows loading data from CSV, JSON, as well as from several databases.
Additionally, you can check out our sample Node.js server, which also implements the custom data source API.
To get our sample project, download it as ZIP or clone it with the following commands:
git clone https://github.com/flexmonster/api-data-source
cd api-data-source/server-dotnetcore
In the server's appsettings.json
file, there are several preconfigured data indexes. The data will be loaded from JSON and CSV files stored in the data/
folder. To connect to your data, read the following section: Connect to the data source.
Additionally, the data refresh time is specified in appsettings.json
. You may adjust it if needed.
Learn more about available server configurations.
To start the server, run the following commands in a console:
dotnet restore
dotnet run
As soon as you start the sample .NET Core server, it automatically preloads the data specified in the Indexes property. Thus, when Flexmonster Pivot requests the data, the server responds with the already preloaded data. Note that the preloaded data is kept in the server’s RAM, so the number of indexes you can specify is limited by the amount of RAM available to the server.
All requests from Flexmonster Pivot will be handled by the http://localhost:3400/api/cube
endpoint. This is the default configuration that you can modify.
Open the api-data-source/client/index.html
file in the browser to see the pivot table with data loaded from the sample .NET Core server.
The report in Flexmonster is configured as follows:
new Flexmonster({
container: "pivotContainer",
report: {
dataSource: {
type: "api",
// A url of our sample server
url: "http://localhost:3400/api/cube",
// Index defined in the server's appsettings.json
index: "fm-product-sales"
}
}
});
Note The index
must match the name of the index defined when configuring the data source on the server. In our case, it is "fm-product-sales"
.
The sample .NET Core server can be configured in the appsettings.json
file, which contains the following properties:
{
DataSources: DataSourceConfigObject[],
DataStorageOptions: DataStorageOptionsObject
}
Property/Type | Description |
---|---|
DataSources DataSourceConfigObject[] | Configures the data sources. |
DataStorageOptions DataStorageOptionsObject | optional Configures the options for data storage. |
This object allows configuring a data source. It has the following properties:
{
Type: string,
DatabaseType: string,
ConnectionString: string,
Indexes: object
}
Property/Type | Description |
---|---|
Type String | The type of the data source: "json" , "csv" , or "database" . |
DatabaseType String | optional The type of the database: "mysql" , "mssql" , "postgresql" , or "oracle" . Only for the "database" data source type. |
ConnectionString String | optional A connection string for the database. Only for the "database" data source type. |
Indexes Object | Contains a list of datasets. Each dataset is represented by a "key": "value" pair, where "key" is the dataset name, and "value" is an IndexObject. |
This object describes a specific dataset. It has the following properties:
{
Path: string,
Delimiter: string,
Query: string
}
This object allows configuring options for data storage. It has the following properties:
{
DataRefreshTime: number
}
The sample .NET Core server configurations vary depending on the data source type: JSON, CSV, or database.
The sample .NET Core server supports only a specific JSON format – an array of objects, where each object is an unordered set of "key": "value"
pairs. Note that you can create your own parser for other JSON formats.
To connect to a JSON data source with the sample .NET Core server, specify the Type and Indexes properties in the To connect to a CSV data source with the sample .NET Core server, specify the Type and Indexes properties in the If CSV fields are not separated by The sample .NET Core server supports MySQL, Microsoft SQL Server, PostgreSQL, Oracle, and Microsoft Azure SQL databases. To connect to a database with the sample .NET Core server, specify the Type, DatabaseType, ConnectionString, and Indexes properties in the When Flexmonster Pivot requests data, the sample .NET Core server caches a response and then sends it. If the component sends the same request again, the server responds with the data from its cache. The server’s cache has a limit. When the cache does not have enough space for a new response, the .NET Core server deletes one of the previously cached responses. The server clears the cache when restarted.[
{
"Color": "green",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22
},
// ...
]appsettings.json
file. For example:"DataSources": [
{
"Type": "json",
"Indexes": {
"index_json": {
"Path": "./data/data.json"
}
}
}
], "index_json"
is a dataset identifier. It will be used to configure the data source in Flexmonster. Additional indexes can be specified like this:{
"Type": "json",
"Indexes": {
"index_json": {
"Path": "./data/data.json"
},
"another_index_json": {
"Path": "./data/another_data.json"
}
}
}Connecting to CSV
appsettings.json
file. For example:"DataSources": [
{
"Type": "csv",
"Indexes": {
"index_csv": {
"Path": "./data/data.csv"
}
}
}
], "index_csv"
is a dataset identifier. It will be used to configure the data source in Flexmonster. Additional indexes can be specified like this:{
"Type": "csv",
"Indexes": {
"index_csv": {
"Path": "./data/data.csv"
},
"another_index_csv": {
"Path": "./data/another_data.csv"
}
}
}","
but by another character, the Delimiter parameter should be specified:"index_csv": {
"Path": "./data/data.csv",
"Delimiter": ";"
} Connecting to databases
appsettings.json
file. For example:{
"DataSources": [
{
"Type": "database",
"DatabaseType": "mysql"
"ConnectionString":
"Server=localhost;Port=3306;Uid=root;Pwd=password;Database=database_name",
"Indexes": {
"index_database": {
"Query": "SELECT * FROM tablename"
}
}
}
]
} "index_database"
is a dataset identifier. It will be used to configure the data source in Flexmonster.ConnectionString
is a connection string for the database. Here are some example connection strings for each supported database type:"Server=localhost;Port=3306;Uid=;Pwd=;Database= "
"Server=(localdb)\\MSSQLLocalDB;Uid=;Pwd=;Database= "
"Server=localhost;Port=5432;Uid=;Pwd=;Database= "
"Data Source=ORCL;User Id=;Password=;"
Server=tcp:myserver.database.windows.net,1433;Database= ;User ID=;Password=;Trusted_Connection=False;Encrypt=True;
(to connect to Microsoft Azure SQL, set the "DatabaseType"
to "mssql"
)About response caching
See also