Dataset Tag in QPR UI

From QPR ProcessAnalyzer Wiki
Jump to: navigation, search

Dataset tag is used to get a dataset into a JSON format to be used for example in a Chart or Data Grid JSON settings. Data is presented in their original datatypes in the JSON (more information: Following datatypes can be shown in the JSON: string, integer, double, boolean and datetime. Datetime is presented as integer in milliseconds from 01 January 1970 00:00:00 UTC as JSON doesn't support dates directly. Dataset tag parameters:

Tag parameter Description
identifier Used dataset identifier. The dataset may exist in the same or upper level in the UI elements hierarchy. An error message is shown if the referenced dataset doesn't exist.
grouping When grouping is defined, JSON is structured in a two level hierarchy (see the example 3 below). The grouping is defined using format [Group column in dataset];[Group property in JSON];[Inner array property in JSON]. In the hierarchy the outer level contains an object array where the objects have two properties: the defined Group property in JSON and Inner array property in JSON. Group property in JSON contains the group name, and Group property in JSON contains an object array where there is data belonging to that single group.
additionalJson JSON structure that is added (merged) to the JSON that is generated by the dataset tag. The additional JSON must be an object array. When defined in the tag, the JSON definition needs to be escaped. Example:
(other parameters) All other parameters define column mappings from the dataset to the JSON presentation. Parameter name is the column name in the formatted JSON and parameter value is the dataset column name. All unmapped columns in the dataset are mapped with same names in JSON. Empty value means that if the dataset contains the defined column, it is not mapped. If referenced column is not found, an error is returned.

Example 1

<#dataset identifier="scorecards" name="scorecardName" x="" y="revenue" color="statusColor">

Examples 2

If there is a dataset with columns A, B and C, and there is a tag

<#dataset identifier="datasetname" D="A" B="">

the resulting JSON contains columns D and C. Column A as mapped with the name D, column B is not mapped at all and C as mapped with the same name.

Example 3: grouping

There is the following dataset with identifier MetricsQuery (shown here in the CSV format):


With tag

<#dataset identifier="MetricsQuery" grouping="Country;name;data" x="Year" y="Efficiency">

the result is as follows:

    "name": "India",
    "data": [{"x": 2015, "y": 28}, {"x": 2016, "y": 25}, {"x": 2017, "y": 26}]						 
    "name": "Germany",
    "data": [{"x": 2015, "y": 31}, {"x": 2016, "y": 28}, {"x": 2017, "y": 30}]					 
    "name": "England",
    "data": [{"x": 2015, "y": 36}, {"x": 2016, "y": 32}, {"x": 2017, "y": 34}]