Menu
Download Free Trial
  1. API reference
  2. Welcome
    1. Getting started
    2. Quickstart
    3. System requirements
    4. Typical errors
    5. Installation troubleshooting
  3. Connecting to Data Source
    1. JSON
      1. JSON data source
      2. Data types in JSON
    2. CSV
      1. CSV data source
      2. Data types in CSV
    3. SQL database
      1. Connecting to SQL database
      2. Connecting to database with .NET
      3. Connecting to database with .NET Core
      4. Connecting to database with Java
      5. Connecting to database with PHP
    4. Microsoft Analysis Services
      1. Connecting to Microsoft Analysis Services
      2. Getting started with Accelerator
      3. Installing Accelerator as a Windows Service
      4. Configuring username/password protection
      5. Configuring secure HTTPS connection
      6. Troubleshooting
    5. Pentaho Mondrian
      1. Connecting to Pentaho Mondrian
      2. Getting started with Accelerator
      3. Configuring Mondrian roles
      4. Сonfiguring username/password protection
      5. Сonfiguring secure HTTPS connection
      6. Troubleshooting
    6. icCube
  4. Configuring report
    1. Configuring report
    2. Data source
    3. Slice
    4. Options
    5. Number formatting
    6. Conditional formatting
    7. Set report to the component
    8. Get report from the component
    9. Calculated values
    10. Custom sorting
    11. Date and time formatting
    12. Configuring global options
  5. Integration with frameworks
    1. Integration with frameworks
    2. Integration with AngularJS
    3. Integration with Angular 2
    4. Integration with Angular 4
    5. Integration with React
    6. Integration with RequireJS
    7. Integration with TypeScript
    8. Integration with ASP.NET
    9. Integration with JSP
    10. Integration with PhoneGap
  6. Integration with charts
    1. Integration with charts
    2. Integration with Highcharts
    3. Integration with FusionCharts
    4. Integration with Google Charts
    5. Integration with any charting library
  7. Customizing
    1. Customizing toolbar
    2. Customizing appearance
    3. Localizing component
  8. Export and print
  9. Updating to the latest version
    1. Updating to the latest version
    2. Release notes
    3. Migration guide from 2.3 to 2.4
    4. Migration guide from 2.2 to 2.3
  10. Managing license keys
  11. Older Versions
    1. Documentation 2.3
    2. Documentation 2.2
    3. 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/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 = new Flexmonster({
		container: "pivotContainer",
		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/flexmonster.js"></script>

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

    var pivot = new Flexmonster({
		container: "pivotContainer",
        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).