Need a special offer?Find out if your project fits.
+
All documentation
  • Introduction
  • Connecting to data source
  • Browser compatibility
  • Documentation for older versions
  • Data source

    The data source is a required part of the ReportObject. 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 ReportObject. To see examples of connecting to different data sources, visit the Examples page.

    JSON data sources

    JSON data source can be:

    • Files from the local file system.
    • A remote static file.
    • Data generated by a server-side script.
    • Inline JSON.

    Here is a list of dataSource properties used to connect to JSON data sources:

    Property/TypeDescription
    browseForFile
    Boolean
    optional Defines whether you want to load the file from the local file system (true) or not (false).
    Default value: false.
    data
    JSON
    optional The inline JSON data.
    dataRootPath
    String
    optional Specifies a path to a nested JSON property that contains data for Flexmonster. See an example on JSFiddle.
    This property works only for JSON data that is loaded via the filename property and is up to 30 MB in size. Also, ensure your data is specified in a supported JSON data format.
    The dataRootPath is not compatible with useStreamLoader.
    filename
    String
    optional The URL to a JSON file or to a server-side script that generates JSON data.
    If your JSON data is located in a nested property, specify a path to that property in the dataRootPath.
    mapping
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    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.
    useStreamLoader
    Boolean
    optional Optimizes processing of large .json files using the stream loader. When set to true, the stream loader is enabled. See an example on JSFiddle.
    useStreamLoader works only when loading files via URL. Not compatible with the dataRootPath property.
    Default value: false.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in outgoing requests.
    Default value: false.

    Here is an example of JSON dataset using a file from the local file system:

    report: {
        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:

    report: {
        dataSource: {
            type: "json",
            filename: "script_which_returns_json_data"
        }
    }

    Inline JSON:

    report: {
        dataSource: {
            /* jsonData variable contains JSON data */
            data: jsonData
        }
    }

    CSV data sources

    CSV data source can be:

    • A file from the local file system.
    • A remote static file.
    • Data generated by a server-side script.

    Here is a list of dataSource properties used to connect to CSV data sources:

    Property/TypeDescription
    browseForFile
    Boolean
    optional Defines whether you want to load the 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
    optional 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".
    Alternatively, you can specify the field separator in the CSV file's first row using the sep prefix. Supported prefix formats are the following: sep=fieldSep and "sep=fieldSep". For example:
    sep=|
    Country|Color|Price
    Canada|blue|1000
    thousandsSeparator
    String
    optional Defines the specific character used to separate groups of digits in numbers. For example, if commas separate groups of digits in numbers (e.g., 1,000 for one thousand), set thousandsSeparator to ",".
    filename
    String
    The URL to a CSV file or to a server-side script that generates CSV data.
    ignoreQuotedLineBreaks
    Boolean
    optional 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
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in 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:

    report: {
        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:

    report: {
        dataSource: {
            type: "csv",
            filename: "script_which_returns_csv_data"
        }
    }

    SQL databases

    Here is a list of dataSource properties used to connect to SQL databases using the custom data source API:

    Property/TypeDescription
    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
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in outgoing requests.
    Default value: false.
    concurrentRequests
    Boolean
    optional When set to false, Flexmonster sends a request for each expand/drill-down separately and waits for the server’s response before sending a new request. This can result in slow performance when there are a lot of expands/drill-downs in the report.
    When the concurrentRequests is true, Flexmonster sends requests for expands/drill-downs of a particular level simultaneously. To get the best performance, enable the HTTP/2 protocol on your server.
    Default value: false.

    Here is an example of how a connection to a relational database is represented in a dataSource object:

    report: {
        dataSource: {
            type: "api",
            url: "https://olap.flexmonster.com:9202/api/cube",
            index: "fm-product-sales"
        }
    } 

    Read more about connecting to SQL databases with the custom data source API here.

    MongoDB databases

    Here is a list of dataSource properties used to connect to a MongoDB database:

    Property/TypeDescription
    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
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in outgoing requests.
    Default value: false.
    concurrentRequests
    Boolean
    optional When set to false, Flexmonster sends a request for each expand/drill-down separately and waits for the server’s response before sending a new request. This can result in slow performance when there are a lot of expands/drill-downs in the report.
    When the concurrentRequests is true, Flexmonster sends requests for expands/drill-downs of a particular level simultaneously. To get the best performance, enable the HTTP/2 protocol on your server.
    Default value: false.

    Here is an example of how a connection to a MongoDB database is represented in a dataSource object:

    report: {
        dataSource: {
            type: "api",
            url: "http://localhost:9204/mongo",
            index: "fm-product-sales"
        }
    }

    The custom data source API

    Here is a list of dataSource properties used to connect to the custom data source API:

    Property/TypeDescription
    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
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    singleEndpoint
    Boolean
    optional 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
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in outgoing requests.
    Default value: false.
    concurrentRequests
    Boolean
    optional When set to false, Flexmonster sends a request for each expand/drill-down separately and waits for the server’s response before sending a new request. This can result in slow performance when there are a lot of expands/drill-downs in the report.
    When the concurrentRequests is true, Flexmonster sends requests for expands/drill-downs of a particular level simultaneously. To get the best performance, enable the HTTP/2 protocol on your server.
    Default value: false.

    Here is an example of how a connection to the custom data source API is represented in a dataSource object:

    report: {
        dataSource: {
            type: "api",
            url: "https://olap.flexmonster.com:9202/api/cube",
            index: "fm-product-sales"
        }
    }

    Check it out on JSFiddle.

    Microsoft Analysis Services

    There are two ways to connect to Microsoft Analysis Services using Flexmonster Pivot:

    1. Via the XMLA protocol – an industry standard for data access in analytical systems. Works for multidimensional models only.
    2. Via Flexmonster Accelerator – a special server-side utility developed by Flexmonster. Works for both multidimensional and tabular models.

    Here is a list of dataSource properties used to connect to Microsoft Analysis Services:

    Property/TypeDescription
    catalog
    String
    The data source catalog name.
    cube
    String
    The catalog's cube's name.
    dataSourceInfo
    String
    optional 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
    Boolean
    optional A flag to use Flexmonster Accelerator instead of the XMLA protocol.
    effectiveUserName
    String
    optional Use when an end-user identity must be impersonated on the server. Specify the account in a domain\user format.
    localeIdentifier
    Number
    optional The Microsoft locale ID value for your language.
    mapping
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    roles
    String
    optional 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
    String
    optional This parameter allows setting 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]". See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    useGranularityNamesForDateFilters
    Boolean
    optional Allows adjusting date filters to the cube structure.
    If set to true, date filters use granularityNames. If set to false, date filters use the unique name of the hierarchy being filtered.
    Default value: true.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in 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:

    report: {
    dataSource: {
    type: "microsoft analysis services",
    // URL to msmdpump.dll
    proxyUrl: "https://olap.flexmonster.com/olap/msmdpump.dll",
    catalog: "Adventure Works DW Standard Edition",
    cube: "Adventure Works",
    // Microsoft Locale ID Value for French
    localeIdentifier: 1036,
    // roles from SSAS
    roles: "admin,manager",
    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:

    report: {
    dataSource: {
    type: "microsoft analysis services",
    proxyUrl: "http://localhost:50005",
    catalog: "Adventure Works DW Standard Edition",
    cube: "Adventure Works",
    binary: true,
    // Microsoft Locale ID Value for French
    localeIdentifier: 1036,
    subquery: "select { [Delivery Date].[Calendar].[Calendar Year].&[2008] } on columns from [Adventure Works]"
    }
    }

    You can read all the details about the Accelerator here.

    Elasticsearch

    Here is a list of dataSource properties used to connect to Elasticsearch:

    Property/TypeDescription
    type
    String
    The type of data source. In this case, it is "elasticsearch".
    node
    String
    The URL string for the connection.
    index
    Boolean
    The name of the Elasticsearch index to connect to.
    mapping
    MappingObject | String
    optional 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 an inline MappingObject or a URL to a JSON file with mapping. See an example on JSFiddle.
    subquery
    BoolQueryObject
    optional This parameter allows setting a server-side filter to decrease the size of the response from the server. See an example on JSFiddle.
    requestHeaders
    Object
    optional 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.
    Note requestHeaders are not saved when obtaining the report via save() and getReport() API calls.
    withCredentials
    Boolean
    optional 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.
    Setting the withCredentials flag to true is recommended when using Windows authentication and other types of server authentications. When set to false, the browser does not ask for credentials, as well as does not include them in outgoing requests.
    Default value: false.

    Here is an example of how a connection to Elasticsearch is represented in a dataSource object:

    report: {
        dataSource: {
            type: "elasticsearch",
            node: "https://olap.flexmonster.com:9200",
            index: "fm-product-sales"
        }
    }

    Try the example on JSFiddle.

    Change the data source using the Toolbar

    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.

    dataSource

    Data in the pivot table will be updated and saved within the report.

    Data source via API

    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.