Menu
Download Free Trial
  1. API reference
  2. Welcome
    1. Component overview
    2. Quickstart
    3. System requirements
    4. Troubleshooting
    5. Installation troubleshooting
    6. Managing license keys
  3. Connecting to Data Source
    1. JSON
      1. Connecting to JSON
      2. Data types in JSON
    2. CSV
      1. Connecting to CSV
      2. Connecting to CSV using Compressor
      3. Data types in CSV
    3. Database
      1. Connecting to SQL databases
      2. Connecting to other databases
      3. Connecting to database with .NET
      4. Connecting to database with .NET Core
      5. Connecting to database with Java
      6. 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. Referring Accelerator as a DLL
      5. Configuring username/password protection
      6. Configuring secure HTTPS connection
      7. 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. What is a 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. Date and time formatting
    10. Configuring global options
    11. Export and print
    12. Calculated values
    13. Custom sorting
  5. Integration with frameworks
    1. Available tutorials
    2. Integration with jQuery
    3. Integration with AngularJS
    4. Integration with Angular 2
    5. Integration with Angular 4
    6. Integration with React
    7. Integration with RequireJS
    8. Integration with TypeScript
    9. Integration with ASP.NET
    10. Integration with JSP
    11. Integration with PhoneGap
  6. Integration with charts
    1. Integration with Highcharts
    2. Integration with FusionCharts
    3. Integration with Google Charts
    4. Integration with any charting library
  7. Customizing
    1. Customizing toolbar
    2. Customizing appearance
    3. Localizing component
  8. 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
  9. 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.

Please note, if you use JSON array of arrays you can also add the first object. In this case you do not need to specify hierarchies in the first sub-array. Check out live example.

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).