Menu
Download Free Trial
  1. Getting started
    1. Quickstart
    2. System requirements
    3. Managing license keys
    4. Updating to the latest version
    5. Typical errors
    6. Migration guide
    7. Installation troubleshooting
  2. JSON data source
    1. Data types in JSON
  3. CSV data source
    1. Data types in CSV
  4. Connecting to SQL database
    1. Connecting to database with .NET
    2. Connecting to database with Java
    3. Connecting to database with PHP
  5. Connecting to Microsoft Analysis Services
    1. Getting started with Accelerator
    2. Installing Accelerator as a Windows Service
    3. Configuring username/password protection
    4. Configuring secure HTTPS connection
    5. Troubleshooting
  6. Connecting to Pentaho Mondrian
    1. Getting started with Accelerator
    2. Configuring Mondrian roles
    3. Сonfiguring username/password protection
    4. Сonfiguring secure HTTPS connection
    5. Troubleshooting
  7. Connecting to icCube
  8. Configuring report
    1. Data source
    2. Slice
    3. Options
    4. Number formatting
    5. Conditional formatting
    6. Set report to the component
    7. Get report from the component
    8. Date and time formatting
    9. Calculated values
    10. Custom sorting
  9. Integration
    1. Integration with AngularJS
    2. Integration with Angular 2
    3. Integration with Angular 4
    4. Integration with React
    5. Integration with RequireJS
    6. Integration with TypeScript
    7. Integration with ASP.NET
    8. Integration with JSP
    9. Integration with PhoneGap
  10. Integration with charts
    1. Integration with Highcharts
    2. Integration with FusionCharts
    3. Integration with Google Charts
    4. Integration with any charting library
  11. Customizing toolbar
  12. Customizing appearance
  13. Localizing component
  14. Global Object
  15. Export and print
  16. API reference - JavaScript
  17. API reference - Flex
Table of contents

Data types in JSON

In addition, the first object in JSON array can be used to define data types, captions, group fields under one dimension, define hierarchy with 3 levels, etc. Here is the list of supported properties that can be used in the first object of input array:

  • type – data type. Can be:
    • "string" – field contains string data. You will be able to aggregate it only with Count and Distinct Count aggregations. It will be sorted as string data.
    • "number" – field contains numeric data. You will be able to aggregate it with all different aggregations. It will be sorted as numeric data.
    • "level" – field is a level of hierarchy. This type is used together with other properties such as: hierarchy, level and parent
    • "month" – field contains months.
    • "weekday" – field contains days of the week.
    • "date" – field is a date. Such field will be split into 3 different fields: Year, Month, Day.
    • "date string" – field is a date. Such field will be formatted using date pattern (default is dd/MM/yyyy).
    • "year/month/day" – field is a date. You will see such date as a hierarchy: Year > Month > Day.
    • "year/quarter/month/day" – field is a date. You will see such date as a hierarchy: Year > Quarter > Month > Day.
    • "time" – field is a time (numeric data). Such field will be formatted using HH:mm pattern. Min, Max, Count and Distinct Count aggregations can be applied to it.
    • "datetime" – field is a date (numeric data). Such field will be formatted using dd/MM/yyyy HH:mm:ss pattern. Min, Max, Count and Distinct Count aggregations can be applied to it.
    • "id" – field is an id of the fact. Such field is used for editing data. This field will not be shown in Fields List.
    • "hidden" – field is hidden. This field will not be shown in Fields List.
  • caption – hierarchy caption.
  • hierarchy – hierarchy name, if the field is a level of hierarchy ("type":"level").
  • level – caption of the level, if the field is a level of hierarchy ("type":"level").
  • parent – caption of the parent level, if the field is a level of hierarchy ("type":"level").
  • dimensionUniqueName – dimension unique name. Can be used to group several fields under one dimension.
  • dimensionCaption – dimension caption. Is used as a display name (folder name in Fields List) when several fields are grouped under one dimension.

For example, you can add the following first object in JSON array and see how it changes the report:

<div id="pivotContainer">The component will appear here</div>
<script src="flexmonster/lib/jquery.min.js"></script>
<script src="flexmonster/flexmonster.js"></script>

<script>
    var jsonData = [
        {
            "Color": {type: "string"},
			"Country":{type: "level", hierarchy: "Geography", 
					level: "Country"},
			"State": {type: "level", hierarchy: "Geography", 
					level: "State", parent: "Country"},
			"City": {type: "level", hierarchy: "Geography", 
					parent: "State"},
			"Price": {type: "number"},
			"Quantity": {type: "number"}
        },
        {
            "Color" : "green",
            "Country" : "Canada",
            "State" : "Ontario",
            "City" : "Toronto",
            "Price" : 174,
            "Quantity" : 22
        },
        {
            "Color" : "red",
            "Country" : "USA",
            "State" : "California",
            "City" : "Los Angeles",
            "Price" : 166,
            "Quantity" : 19
        }
    ];

	var pivot = $("#pivotContainer").flexmonster({
		toolbar: true,
		report: {
			dataSource: {
				data: jsonData
			},
			slice: {
				rows: [
				{ uniqueName: "Color" },
				{ uniqueName: "[Measures]" }
				],
				columns: [
				{ uniqueName: "Geography" }
				],
				measures: [
				{ uniqueName: "Price", aggregation: "sum" }
				]
			}
		},
		licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX"
	});
</script>

Try on JSFiddle.

Undefined types in JSON

It is possible to define only necessary types of fields and leave all others empty {}. Type of these fields will be selected automatically. In the following example "Color" was left undefined:

<div id="pivotContainer">The component will appear here</div>
<script src="flexmonster/lib/jquery.min.js"></script>
<script src="flexmonster/flexmonster.js"></script>

<script>
    var jsonData = [
        {
            "Color": {},
            "Price": {type: "number"}
        },
        {
            "Color" : "green",
            "Price" : 174
        },
        {
            "Color" : "red",
            "Price" : 166
        }
    ];

    var pivot = $("#pivotContainer").flexmonster({
        toolbar: true,
        report: {
            dataSource: {
                data: jsonData
            }
        },
        licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX"
    });
</script>

Please note, that in Fields List will be available only two fields: "Color" and "Price". All other fields ("Country", "City" etc.) will be omitted because they were not mentioned in the first object of JSON array.

Supported date formats

To make date fields be interpreted as date, you should define data type, for example, "type":"date", "type":"date string", "type":"year/month/day" or "type":"year/quarter/month/day". Besides, data from these fields should have special date format to be understood properly.
Pivot table component supports ISO 8601 date (other formats may be used, but results can be unexpected). For example, "2016-03-20" (just date) or "2016-03-20T14:48:00" (date and time).