All documentation
  • Introduction
  • Connecting to data source
    1. Supported data sources
    2. Connecting to other data sources
  • Browser compatibility
  • Documentation for older versions
  • Supporting multilevel hierarchies

    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.

    Step 1. Notify Flexmonster Pivot about implementing advanced filters

    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.

    Step 2. Configure the multilevel hierarchies

    Once Flexmonster Pivot knows that the server supports multilevel hierarchies, you can configure them in two ways:

    On the client side

    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
      }
    }

    Live example

    On the server side

    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":{
        // ...
      } 
    }

    Step 3. Implement advanced hierarchical 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.

    Step 4. (optional) Handle the additional /select request

    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.

    Step 5. See the result

    Now if you run your project and open the webpage with Flexmonster - multilevel hierarchies will appear in the component.

    See also