Creating multilevel hierarchies
Using the mapping object for JSON, you can create multilevel hierarchies from fields of any type.
In this guide, we’ll create a Food
hierarchy with Category
, Item
, and Serving Size
levels based on the data below:
[ { "Category": "Breakfast", "Item": "Frittata", "Serving Size": "4.8 oz (136 g)", "Calories": 300 }, { "Category": "Breakfast", "Item": "Boiled eggs", "Serving Size": "4.8 oz (135 g)", "Calories": 250 } ]
Step 1. In the mapping object, set the type of Category
, Item
, and Serving Size
fields as "level"
:
[
{
"Category": {
type: "level"
},
"Item": {
type: "level"
},
"Serving Size": {
type: "level"
},
"Calories": {
type: "number"
}
},
{
"Category": "Breakfast",
"Item": "Frittata",
"Serving Size": "4.8 oz (136 g)",
"Calories": 300
},
{
"Category": "Breakfast",
"Item": "Boiled eggs",
"Serving Size": "4.8 oz (135 g)",
"Calories": 250
}
]
Step 2. Use the hierarchy, parent, and level properties of the mapping object to create the Food
hierarchy:
[
{
"Category": {
type: "level",
hierarchy: "Food"
},
"Item": {
type: "level",
hierarchy: "Food",
level: "Dish",
parent: "Category"
},
"Serving Size": {
type: "level",
hierarchy: "Food",
level: "Size",
parent: "Dish"
},
"Calories": {
type: "number"
}
},
{
"Category": "Breakfast",
"Item": "Frittata",
"Serving Size": "4.8 oz (136 g)",
"Calories": 300
},
{
"Category": "Breakfast",
"Item": "Boiled eggs",
"Serving Size": "4.8 oz (135 g)",
"Calories": 250
}
]
See how this dataset will be visualized in WebDataRocks:
Check out a live demo on CodePen.
See also
The mapping object for JSON is specified as the first element of the JSON array. This object is used for setting data types, creating multilevel hierarchies, and changing captions.
Properties
Name | Type | Description |
---|---|---|
type | String | optional The field’s data type. Possible values:
|
caption | String | optional The field’s caption. |
hierarchy | String | optional The name of the hierarchy. Used for multilevel hierarchies. Set this property to make the field a level of the specified hierarchy. In this case, the type must be set to "level" . |
parent | String | optional The caption of the parent hierarchy level. Used for multilevel hierarchies. In this case, the type must be set to "level" . |
level | String | optional The caption of the hierarchy level. Used for multilevel hierarchies. In this case, the type must be set to "level" . |
Examples
1) Setting the mapping object in a JSON array of objects:
[
{
"Product": {
"type": "string"
},
"Price": {
"type": "number"
}
},
{
"Product": "Apple",
"Price": 2.50
},
{
"Product": "Cherry",
"Price": 5.25
}
]
See the full example on CodePen.
2) Setting the mapping object in a JSON array of arrays:
[
{
"Product": {
"type": "string"
},
"Price": {
"type": "number"
},
},
["Apple", 2.50],
["Cherry", 5.25]
]
Try a live demo on CodePen.
See also
- Supported JSON formats
- Setting data types in JSON
- Connecting to JSON
- Creating multilevel hierarchies
Using the mapping object for JSON, you can set data types for fields in your data source.
Available data types
The following data types are available in JSON:
Some of these types can be auto-resolved by the component.
Automatic type resolution
If you omit the field’s type, the component automatically assigns the data type based on the field’s first value. The following data types can be auto-resolved:
The results of the automatic resolution may be unexpected when:
- The first field value is
null
. In this case, the field type cannot be resolved automatically. - The field values are not formatted correctly. For example, a number was specified in the hexadecimal form instead of decimal.
- The field type cannot be resolved automatically. For example, time values are processed as numbers if the
"time"
type is not explicitly specified. - The first field value is formatted differently from other values. For example, the first value is a number while others are strings.
Learn more about each field data type in the sections below.
Number
This field type is used to store numbers.
Field values can contain digits, -
, and +
characters. Point .
must be used as a decimal separator. Numbers in exponential notation are also supported. Examples of valid values: -20
, 2.50
, 1.0E+2
.
To mark the field as a number, set the type property of the mapping object to "number"
.
Can be auto-resolved: yes (learn more).
Available aggregations: all.
String
This field type is used to store strings.
Field values must be enclosed in double quotes "
. Special characters, such as line breaks or double quotes "
, must be escaped using the backslash \
. Examples of valid values: "Apple"
, "\"A-Z\" section"
.
To mark the field as a string, set the type property of the mapping object to "string"
.
Can be auto-resolved: yes (learn more).
Available aggregations: Count
, Distinct Count
.
Date
This field type is used to store dates.
Field values must be specified in one of the following formats:
- ISO 8601. Examples:
"2018-01-10"
(date),"2018-01-10T08:14:00"
(date and time),"2018-01-10T06:14:00Z"
(date and time in UTC).
If the values are specified in this format, the field type can be auto-resolved as the"date"
type. - Unix timestamps in milliseconds. Example:
1515535200000
(timestamp of the"2018-01-10"
date).
If the values are specified in this format, the field type must be set explicitly as a date. - JavaScript Date objects. Can be used only with inline JSON data. Example:
new Date(2018, 1, 10)
(creates the"2018-01-10"
date).
If the values are specified in this format, the field type can be auto-resolved as the"date"
type.
To mark the field as a date, set the type property of the mapping object to one of the following:
"date"
– dates are divided into 3 subfields:Year
,Month
,Day
.
Can be auto-resolved: yes, if values are specified in ISO 8601 or as JavaScript Date objects (learn more).
Available aggregations:Count
,Distinct Count
.
See the example."date string"
– dates are displayed as strings in the"dd/MM/yyyy"
format. The format can be changed using the datePattern option.
Can be auto-resolved: no (learn more).
Available aggregations:Min
,Max
,Count
,Distinct Count
."year/month/day"
– dates are represented as the multilevel hierarchy:Year
>Month
>Day
.
Can be auto-resolved: no (learn more).
Available aggregations:Count
,Distinct Count
.
See the example."year/quarter/month/day"
– dates are represented as the multilevel hierarchy:Year
>Quarter
>Month
>Day
.
Can be auto-resolved: no (learn more).
Available aggregations:Count
,Distinct Count
."datetime"
– dates are displayed as strings in the"dd/MM/yyyy HH:mm:ss"
format. The format can be changed using the dateTimePattern option.
Can be auto-resolved: no (learn more).
Available aggregations:Min
,Max
,Count
,Distinct Count
.
See the example.
Time
This field type is used to store time intervals, such as duration.
Field values must be specified as a number of seconds. In the component, values are displayed in the "HH:mm:ss"
format. Examples of valid values: 5400
(displayed as "01:30:00"
in the component).
To mark the field as time, set the type property of the mapping object to "time"
.
Can be auto-resolved: no (learn more).
Available aggregations: Min
, Max
, Count
, Distinct Count
.
Month
This field type is used to store months. Natural sorting is applied to the field members: from January to December.
Field values must start with a capital letter. Full names and three-letter abbreviations of months are supported. Examples of valid values: "October"
, "Dec"
, "May"
.
To mark the field as months, set the type property of the mapping object to "month"
.
Can be auto-resolved: no (learn more).
Available aggregations: Count
, Distinct Count
.
Weekday
This field type is used to store the days of the week. Natural sorting is applied to the field members: from Sunday to Monday.
Field values must start with a capital letter. Full names and three-letter abbreviations of the days of the week are supported. Examples of valid values: "Monday"
, "Sun"
, "Friday"
.
To mark the field as a day of the week, set the type property of the mapping object to "weekday"
.
Can be auto-resolved: no (learn more).
Available aggregations: Count
, Distinct Count
.
Level
This field type means that a field is a level of a multilevel hierarchy.
To mark the field as a hierarchy level, set the type property of the mapping object to "level"
.
Can be auto-resolved: no (learn more).
Available aggregations: none.
Hidden
This field type is used to hide fields from the report.
To mark the field as hidden, set the type property of the mapping object to "hidden"
.
Can be auto-resolved: no (learn more).
Available aggregations: none.
Note. Another way to hide fields from the report is to omit them in the mapping object.
After formatting your JSON data and setting field data types, learn how to connect to the JSON data.
See also
Use the drill-down feature to drill into the different levels of a hierarchy. This operation helps to reveal more details of your data and get a more specific view of the hierarchies. Drill back up when you need to get a general view of the data.
Example
Starting from a country level, drill down to a city level that can be further drilled down to an address level. Drill up the levels to return to the previous view of the hierarchy.

Note that this feature can be used only with the multi-level hierarchies. Refer to the Data types in JSON and Data types in CSV articles for details on how to define levels in the data types.
Use the drag-and-drop feature to organize and restructure your report in real time.
Example
Drag and drop the hierarchies between the rows, columns and report filters right on the grid.

Use the expand and collapse operations to analyze the data on different levels of detail.
Example
Expand the Category hierarchy to display the members of the next (Business Type) hierarchy.
In a classic form:

In a compact form:

The main idea of the calculated values lies in giving a more complete picture of your data by measuring your data in a custom way.
To create a calculated value, define an expression on which the values are calculated and apply it to your data. It serves as a new aggregation function that you can change or delete at any moment.
Moreover, multiple calculated values can be created within one report.
To add a calculated value
- Go to the Fields tab () on the Toolbar.
- Click the Add calculated value button.
- Type in the name of a formula in the input field.
- Choose the fields to include in the formula, the aggregation functions to apply to these fields, and add the necessary operators.
- Apply the changes.
NOTE
: the Count
and Unique Count
functions can be applied only to the string fields.
Example
Let’s define a new Revenue measure. It is composed of Price and Quantity fields (Price * Quantity).
- Type in a name of a new calculated value.
- Drag the fields to the Formula area and add a multiplication operator to compose a product of two values.
- Apply the changes. Now the new calculated value is placed at the bottom of the list. Drop it to the Values area to add it to the report.

All calculated values are saved in the measures of the report’s slice.
To edit a calculated value
- Go to the Fields tab () on the Toolbar.
- Find the calculated value in the All fields box.
- Click the Sigma editing button (
) next to the value’s name.
- Edit the calculated value.
- Apply the changes.
To remove a calculated value
- Go to the Fields tab () on the Toolbar.
- Find the calculated value in the All fields box.
- Click the Sigma editing button (
) next to the value’s name.
- Click the Remove button (✕).
- Confirm the action.
Individual values
Note that there is the Calculate individual values checkbox. If it is checked, the formula is calculated based on the raw values. Otherwise, it is calculated using the aggregated values.
Find out the difference between the calculated and calculated individual values in the demo.
We hope your time using WebDataRocks Pivot Table has been productive and satisfying. WebDataRocks provides all the basic features for data visualization and analysis, such as connecting to JSON or CSV data sources and essential data aggregation functions.
In case you want to have more features, be it advanced customization or more data source options, we recommend looking at Flexmonster Pivot Table & Charts — a commercial advanced component developed by the same team.
Flexmonster has all of the WebDataRocks features and more, so you have nothing to lose by migrating to it. In addition, the number of changes required to move from WebDataRocks is minimal.
Continue with this page to discover all the Flexmonster features your project can benefit from👇
No data size limit
WebDataRocks works with JSON and CSV datasets no larger than 1 MB, which should satisfy the majority of use cases.
Flexmonster doesn’t set limits on the dataset’s size, so the maximum size depends only on the browser’s capabilities. Moreover, Flexmonster can connect to server-side data storage and load only the necessary data subsets into the browser, allowing you to work with much larger datasets.
More data source options
In addition to having no strict limit on the data size, Flexmonster offers a wider selection of data sources.
The following data sources are supported out of the box:
- JSON
- CSV
- Microsoft Analyses Services
- SQL databases
- Elasticsearch
- MongoDB
You can also connect Flexmonster Pivot to any data source using the custom data source API — Flexmonster’s communication protocol that helps you build a custom data source using your server.
See the full list of the data sources supported by Flexmonster.
Built-in pivot charts
Flexmonster offers one more exclusive feature — built-in pivot charts. This allows you to visualize data using the charts out of the box without integrating with third-party charting libraries.
Check out the video that shows how to work with Flexmonster Pivot Charts:
Advanced customer support
Another important aspect of Flexmonster is Rockstar Support — a team of technical specialists who are always ready to answer your questions or help you resolve issues. You can also check out the collection of resolved support tickets to find a solution for your case.
Other benefits
In addition to everything listed, Flexmonster provides other benefits:
Where do I start with Flexmonster?
Flexmonster offers a 30-day free trial requiring no payment details, so you can test Flexmonster’s functionality and decide whether it fits your project. Moreover, you can get a special discount as a WebDataRocks user if you decide to buy the product license.
To smoothly move from WebDataRocks to Flexmonster, check out our migration guide.
If you want to see Flexmonster in action, watch this video for a detailed overview of Flexmonster Pivot and then try out the live demo:
In this guide, you can learn how to format your JSON data so WebDataRocks can process it.
WebDataRocks supports two JSON formats:
1) Array of objects. Each object in the array is an unordered collection of key-value pairs, where the key is a field name and the value is a field member. Example:
[ { "Product": "Apple", "Price": 2.50 }, { "Product": "Cherry", "Price": 5.25 } ]
2) Array of arrays. The first subarray contains field names, while other subarrays contain the respective field members. The field’s name and members must have the same position in the subarrays. Example:
[ ["Product", "Price"], ["Apple", 2.50], ["Cherry", 5.25] ]
Regardless of what JSON format you choose, the first element of each array can be the mapping object for JSON. This object is used to set data types and create multilevel hierarchies.
See also
- Setting data types in JSON
- Connecting to JSON
- Creating multilevel hierarchies
- Mapping object for JSON
What is WebDataRocks
WebDataRocks is a free web reporting tool for data analysis and visualization.
It is written in JavaScript and is not constrained by any external framework. This simple but enterprise-featured web-based pivot grid can be added to your website, application, or project web page within minutes.
What does it offer
WebDataRocks easily displays your CSV or JSON data in an interactive pivot table, offers a number of data analysis features, and provides a reporting experience. You get real-time reporting of your data on any device you prefer (PC, tablet, mobile, etc.)
Who can use WebDataRocks
Our reporting tool would be a perfect fit if you:
- Want to analyze data quickly.
- Are looking for an online reporting tool.
- Need a lightweight web pivot table.
- Don’t know how to code or don’t want to.
Why is it cool
- WebDataRocks easily embeds in your web page not requiring much programming skills.
- You can save your time and expenses on integration as it’s already configured and ready to use.
- Our tool has enterprise features for a real business, despite being costless.
- It’s a powerful analytic tool with a well-designed ready-to-use modern UI.
The main benefit is that WebDataRocks is an absolutely free tool created by passionate data lovers from Flexmonster.
How can I get WebDataRocks and add it to my project
To make it simple for you we’ve prepared an integration tutorial that provides you with easy instructions on how to download WebDataRocks and add it to your website or application.
How can I use more advanced options
For those of our users who want to further explore WebDataRocks functionality, we prepared guides on the following topics:
- Custom report themes
- Localization
- Integration with frameworks
- Integration with charting libraries (amCharts, Highcharts, Google Charts, and FusionCharts)
- List of API methods and objects
Some thoughts from creators
We truly hope that you will enjoy all this experience with WebDataRocks. It’s created to help solve data analysis needs for different kinds of projects: start-ups, nonprofit, or commercial. So, if it will work for you, please share your success with others. Let data rock this world!
License
By downloading, installing, and/or using WebDataRocks, you agree with the terms of WebDataRocks End User License Agreement.