You can create multilevel hierarchies from non-hierarchical data in Flexmonster Pivot. To build a hierarchy, Flexmonster will ask the server to apply hierarchical filters to the data. This guide describes which filter structure your server should support to provide the correct data for visualizing hierarchies.
By default, Flexmonster Pivot assumes that multilevel hierarchies are not supported on the server. Therefore, if you configure multilevel hierarchies, these configurations will be ignored.
To change this behavior, your server needs to inform Flexmonster Pivot that the hierarchies are supported and can be filtered. For this purpose, set the filters.advanced property to true
in the response to the /fields request.
Once Flexmonster Pivot knows that the server supports multilevel hierarchies, you can configure them in two ways:
You can group data into hierarchies using the mapping. Specify the [field_name].hierarchy and [field_name].parent properties to structure the data.
In the example below, we create the "Item"
hierarchy with the "Category"
field as the first level and the "Color"
field as the second level:
report: { dataSource: { type: "api", url: "your_url", index: "your_index", mapping: { "Category": { type: "string", hierarchy: "Item" }, "Color": { type: "string", hierarchy: "Item", parent: "Category" } } }, slice: { // Your slice } }
You can configure hierarchies right in the response to the /fields request. To do so, specify hierarchy and parent properties for the necessary fields.
Here is an example of a /fields response where the "Category"
and "Color"
fields are grouped under the "Item"
hierarchy (with "Category"
as the top level of the hierarchy):
{ "fields":[ { "uniqueName": "Category", "type": "string", "hierarchy": "Item" }, { "uniqueName": "Color", "type": "string", "hierarchy": "Item", "parent": "Category" }, // ... ], "aggregations":{ // ... }, "filters":{ // ... } }
Once the hierarchies are configured, Flexmonster Pivot will start sending requests with hierarchical filters to properly display the data.
Flexmonster sends filters in the /members request and the /select requests for the pivot table, the flat table, and the drill-through view. The filters' structure is described by the FilterGroupObject.
Your server needs to handle these requests and apply hierarchical filters correctly.
The component sends the additional /select request when the levelName property is defined in the slice. This request extracts members from the hierarchy level specified in levelName
.
If you need the levelName
property in your slice, handle the /select request for loading the required hierarchy levels.
Now if you run your project and open the webpage with Flexmonster - multilevel hierarchies will appear in the component.