Configure multilevel hierarchies in the custom data source API

Data source

by bradhuang9999

HTML

<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div id="pivot-container"></div>

JavaScript

let pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 550,
  toolbar: true,
  report: {
    "dataSource": {
      "type": "api",
      "url": "https://olap.flexmonster.com:9500",
      "index": "fm-product-sales",
      "mapping": {
        "Category": {
          "type": "string",
          "hierarchy": "Tree1"
        },
        "Color": {
          "type": "string",
          "hierarchy": "Tree1",
          "parent": "Category"
        },
        "Country": {
          "type": "string",
          "hierarchy": "Tree2"
        },
        "Destination": {
          "type": "string",
          "hierarchy": "Tree2",
          "parent": "Country"
        },
      }
    },
    "slice": {
      "rows": [{
        "uniqueName": "Tree1"
      },{
        "uniqueName": "Tree2"
      }],
      "columns": [{
        "uniqueName": "[Measures]"
      }],
      "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
      }],
      "drills": {
        "rows": [{
          "tuple": [
            "Tree1.[accessories]"
          ]
        }]
      }
    }
  }
});