The data source is a required part of the report object. Flexmonster supports data from OLAP data sources, SQL databases, CSV and JSON static files, and inline JSON data. Each data source requires specific properties to be set inside the dataSource
section of the report object. To see examples of connecting to different data sources, visit the Examples page.
Read more in the following sections:
JSON data source can be:
Here is a list of dataSource
properties used to connect to JSON data sources:
browseForFile
– Boolean. Defines whether you want to load the file from the local file system (true
) or not (false
). Default value: false
.
data
(from v2.2) – JSON. The inline JSON data.type
– String. The type of data source. In this case, it is "json"
. You do not need to explicitly define this property when reading static JSON files with a “.json” extension.filename
– String. The URL to the file or to the server-side script which generates data. mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, and multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. requestHeaders
(optional) – Object. This object allows you to add custom request headers. The object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls. useStreamLoader
(optional) – Boolean. Optimizes the large file processing using the stream loader. When set to true
, the stream loader is enabled. Available only when loading files via URL. See an example on JSFiddle. Default value: false
.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
. Here is an example of JSON dataset using a file from the local file system:
{ dataSource: { /* Path to the local JSON file */ filename: "data.json" } }
If the data is generated by a server-side script, type
must be defined explicitly:
{ dataSource: { type: "json", filename: "script_which_returns_json_data" } }
Inline JSON:
{ dataSource: { /* jsonData variable contains JSON data */ data: jsonData } }
CSV data source can be:
Here is a list of dataSource
properties used to connect to CSV data sources:
browseForFile
– Boolean. Defines whether you want to load a file from the local file system (true
) or not (false
). Default value: false
.type
– String. The type of data source. In this case, it is "csv"
. You do not need to explicitly define this property when reading static CSV files with a .csv
extension.fieldSeparator
– String. Defines the specific fields separator to split each CSV row. There is no need to define it if the CSV fields are separated by ,
or ;
. This property is required only if another character separates fields. For example, if you use TSV, where a tab character is used to separate fields, then the fieldSeparator
parameter should be set to "\t"
. thousandSeparator
(optional) – String. Allows importing CSV data with commas used to separate groups of digits in numbers (e.g., 1,000
for one thousand). To load such data, set thousandSeparator
to ","
. filename
– String. The URL to the file or to the server-side script which generates data.ignoreQuotedLineBreaks
(from v2.1) – Boolean. Indicates whether line breaks in quotes should be ignored (true
) or not (false
). When set to true
, CSV parsing is faster. Set it to false
only if your data source has important line breaks in quotes. Note that this might slow down CSV parsing a little bit. Default value: true
.mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, and multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
. In the following example data is taken from a CSV file where the colon character (:
) is used to separate fields within the row. Line breaks in quotes are not ignored:
{ dataSource: { /* URL or local path to a CSV file */ filename: 'colon-data.csv', fieldSeparator: ':', ignoreQuotedLineBreaks: false } }
If the data is generated by a server-side script, type
must be defined explicitly:
{ dataSource: { type: "csv", filename: "script_which_returns_csv_data" } }
Here is a list of dataSource
properties used to connect to SQL databases using the custom data source API:
type
– String. The type of data source. In this case, it is "api"
.url
– String. The path to the API endpoints.index
– String. The dataset identifier.mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, and multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls. withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
.
Here is an example of how a connection to a relational database is represented in a dataSource
object:
{
dataSource: {
type: "api",
url: "http://olap.flexmonster.com:9202/api/cube",
index: "fm-product-sales"
}
}
Read more about connecting to SQL databases with the custom data source API here.
Here is a list of dataSource
properties used to connect to a MongoDB database:
type
– String. The type of data source. In this case, it is "api"
.url
– String. The path to the API endpoints.index
– String. The dataset identifier.mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, and multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
.
Here is an example of how a connection to a MongoDB database is represented in a dataSource
object:
{
dataSource: {
type: "api",
url: "http://olap.flexmonster.com:9204/mongo",
index: "fm-product-sales"
}
}
Check out a live example on JSFiddle.
Here is a list of dataSource
properties used to connect to the custom data source API:
type
– String. The type of data source. In this case, it is "api"
.url
– String. The path to the API endpoints.index
– String. The dataset identifier.mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, and multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls.singleEndpoint
– Boolean. When set to true
, all custom data source API requests are sent to a single endpoint specified in the url
property. Default value: false
.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
.
Here is an example of how a connection to the custom data source API is represented in a dataSource
object:
{
dataSource: {
type: "api",
url: "http://olap.flexmonster.com:9202/api/cube",
index: "fm-product-sales"
}
}
Check it out on JSFiddle.
OLAP data sources include Microsoft Analysis Services and Mondrian. There are two ways to connect to an OLAP cube using Flexmonster Pivot:
Here is a list of dataSource
properties used to connect to Microsoft Analysis Services:
catalog
– String. The data source catalog name.cube
– String. The given catalog’s cube’s name.dataSourceInfo
(optional) – String. The service info.type
– String. The type of data source. In this case, it is "microsoft analysis services"
.proxyUrl
– String. The path to the proxy URL. Both tabular and multidimensional model types are supported. binary
(optional) – Boolean. A flag to use Flexmonster Accelerator instead of the XMLA protocol.effectiveUserName
(optional) – String. Use when an end-user identity must be impersonated on the server. Specify the account in a domain\user format.localeIdentifier
(optional) – Number. The Microsoft locale ID value for your language.mapping
(optional) – Mapping Object | String. Allows defining field data types, captions, multilevel hierarchies, grouping fields under separate dimensions, and setting other view configurations of hierarchies. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle.roles
(optional) – String. A comma-delimited list of predefined roles to connect to a server or a database using the permissions defined by that role. If this property is omitted, all roles are used and the effective permissions are the combination of all roles. For example, to combine "admin"
and "manager"
roles, set the roles
property like so: roles: "admin,manager"
.subquery
(optional) – String. The parameter to set a server-side filter to decrease the size of the response from the OLAP cube. For example, to show reports for only one specific year set the subquery like so: "subquery": "select {[Delivery Date].[Calendar].[Calendar Year].&[2008]} on columns from [Adventure Works]"
.requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. This property is available for both XMLA protocol and Flexmonster Accelerator. Default value: false
.
Here is an example of how the connection to SSAS via XMLA is represented in dataSource
:
{ dataSource: { type: "microsoft analysis services", proxyUrl: "http://olap.flexmonster.com/olap/msmdpump.dll", // URL to msmdpump.dll catalog: "Adventure Works DW Standard Edition", cube: "Adventure Works", localeIdentifier: 1036, // Microsoft Locale ID Value for French roles: "admin,manager", // roles from SSAS subquery: "select {[Delivery Date].[Calendar].[Calendar Year].&[2008]} on columns from [Adventure Works]" } }
Check it out on JSFiddle.
Here is an example of how the connection to SSAS via Flexmonster Accelerator is represented in dataSource
:
{ dataSource: { type: "microsoft analysis services", proxyUrl: "http://localhost:50005", catalog: "Adventure Works DW Standard Edition", cube: "Adventure Works", binary: true, localeIdentifier: 1036, // Microsoft Locale ID Value for French subquery: "select {[Delivery Date].[Calendar].[Calendar Year].&[2008]} on columns from [Adventure Works]" } }
You can read all the details about the Accelerator here.
Here is a list of dataSource
properties used to connect to Mondrian:
catalog
– String. The data source catalog name.cube
– String. The given catalog’s cube’s name.dataSourceInfo
– String. The service info.mapping
(optional) – Mapping Object | String. Allows setting captions of dimensions and measures. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle.type
– String. The type of data source. In this case it is "mondrian"
.proxyUrl
– String. The path to the proxy URL. binary
(optional) – Boolean. A flag to use Flexmonster Accelerator instead of the XMLA protocol.roles
(optional) – String. A comma-delimited list of predefined roles to connect to a server or a database using the permissions defined by that role. If this property is omitted, all roles are used and the effective permissions are the combination of all roles. For example, to combine "admin"
and "manager"
roles, set the roles
property like so: roles: "admin,manager"
.requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via save()
and getReport()
API calls.Here is an example of how the connection to Mondrian via XMLA is represented in dataSource
:
{
dataSource: {
type: "mondrian", // URL to the XMLA provider
proxyUrl: "http://localhost:8080/mondrian/xmla",
dataSourceInfo: "MondrianFoodMart",
catalog: "FoodMart",
cube: "Sales"
}
}
Here is an example of how the connection to Mondrian via Flexmonster Accelerator is represented in dataSource
:
{ dataSource: { type: "mondrian", proxyUrl: "localhost:50006", dataSourceInfo: "MondrianFoodMart", catalog: "FoodMart", cube: "Sales", binary: true, roles: "California manager" // Mondrian roles } }
You can read all the details about the Accelerator here.
Here is a list of dataSource
properties used to connect to Elasticsearch:
type
– String. The type of the data source. In this case it is "elasticsearch"
.subquery
(optional) – Bool Query Object. The parameter to set a server-side filter to decrease the size of the response from the server.mapping
(optional) – Mapping Object | String. Allows customizing hierarchies’ captions, formats, time zones, control fields’ visibility, and more. It can be either the inline Mapping Object or the URL to a JSON file with mapping. See an example on JSFiddle. node
– String. The URL string for the connection.index
– String. The name of the Elasticsearch index to connect to. requestHeaders
(optional) – Object. This object allows you to add custom request headers. This object consists of "key": "value"
pairs, where "key"
is a header name and "value"
is its value. Check out a live sample on JSFiddle. Important note: requestHeaders
is not saved when obtaining the report via the save()
and getReport()
API calls.withCredentials
(optional) – Boolean. It indicates whether cross-site Access-Control
requests should be made using credentials such as authorization headers (true
) or not (false
). For more details refer to MDN web docs.withCredentials
flag to true
is recommended when using Windows authentication and other types of server authentications. When set to false
, the browser does not request credentials, as well as does not include them into outgoing requests. Default value: false
. Here is an example of how a connection to Elasticsearch is represented in a dataSource
object:
{ dataSource: { type: "elasticsearch", node: "https://olap.flexmonster.com:9200", index: "fm-product-sales" } }
Try the example on JSFiddle.
Use the Connect option to choose another data source or Open to load another report at runtime. Use Save to save the report with the current data source.
Data in the pivot table will be updated and saved within the report.
The API calls connectTo(), load(), and open() are used to change the data source at runtime. The API call save() is used to save the report.