Custom Description

by bacsacosta

HTML

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

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

JavaScript

new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: "400",
  toolbar: true,
  customizeCell: function(cell, data) {
      if (data.member != null && data.member.properties != null && data.member.properties["Item Desc"] != null) {
          cell.text = data.member.properties["Item Desc"];
      }
  },
  report: {
    dataSource: {
      dataSourceType: "json",
      data: getData()
    },
    slice: {
      "rows": [{
          "uniqueName": "Item Id"
        }
      ],
      "columns": [{
        "uniqueName": "[Measures]"
      }],
      "measures": [{
          "uniqueName": "Price",
          "aggregation": "sum"
        },
        {
          "uniqueName": "Quantity",
          "aggregation": "sum"
        },
        {
          "uniqueName": "Discount",
          "aggregation": "sum"
        }
      ]
    },
    conditions: [],
    formats: []
  }
});

function getData() {
  return [
  	{
      "Item Id": {
         type: "string"
      },
      "Item Desc": {
         type: "property",
         hierarchy: "Item Id"
      },
      "Store Id": {
         type: "string"
      },
      "Store Desc": {
         type: "property",
         hierarchy: "Store Id"
      },
      "Price": {
         type: "number"
      },
      "Quantity": {
         type: "number"
      },
      "Discount": {
         type: "number"
      },
      "Date": {
         type: "date string"
      }
  	},{
      "Item Id": "ITM01",
      "Item Desc": "Desc. Item 01",
      "Store Id": "STR02",
      "Store Desc": "Desc. Store 02",
      "Price": 174,
      "Quantity": 225,
      "Discount": 23,
      "Date": "2011-01-12"
    },
    {
      "Item Id": "ITM01",
      "Item Desc": "Desc. Item 01",
      "Store Id": "STR02",
      "Store Desc": "Desc. Store 02",
      "Price": 502,
      "Quantity": 90,
      "Discount": 17,
      "Date": "2011-01-13"
    },
    {
      "Item Id": "ITM01",
      "Item Desc": "Desc....