Test Hierarchy Fields

by sergin

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

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

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 430,
  toolbar: true,
  report: {
    dataSource: {
      dataSourceType: "json",
      mapping: {
          "Year": {
          "type": "level",
          "hierarchy": "Time",
          "level": "Year"
        },
         "HalfYear": {
          "type": "level",
          "hierarchy": "Time",
          "level": "HalfYear",
          "parent": "Year"
        },
        "Month": {
            "type": "level",
          "hierarchy": "Time",
          "level": "Month",
          "parent": "HalfYear"
        },
        "Product": {
          "type": "string"
        },
        "Price": {
          "type": "number"
        }
      },
      data: [		{
          "Month": "Dec2019",
          "HalfYear": "Second",
          "Year": "2019",
          "Product": "apple",
          "Price": 1
        },
        {
          "Month": "Jan2020",
          "HalfYear": "First",
          "Year": "2020",
          "Product": "orange",
          "Price": 1
        },
        {
          "Month": "Jan2020",
          "HalfYear": "First",
          "Year": "2020",
          "Product": "pear",
          "Price": 1
        }	
      ]
    },
    options: {
      showEmptyValues: "columns"
    },
    slice: {
      rows: [{
        uniqueName: "Product",
        "filter": {
          "exclude": [
            "product.[apple]"
          ]
        }
      }],
      columns: [{
        uniqueName: "Time"
      }, {
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price"
      }],
      expands: { expandAll: true },
      drills: { drillAll: true }   
    }
  }
});