JSON data source

Data source

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div id="pivot-container"></div>

JavaScript

var jsonData = [
	{
    type: 0,
    'date agg': '2017-01-01'
  },
  {
    type: 0,
    'date agg': '2017-01-02'
  },
  {
    type: 0,
    'date agg': '2017-01-03'
  },
  {
    type: 1,
    'date agg': '2017-01-04'
  },
  {
    type: 1,
    'date agg': '2017-01-05'
  },
  {
    type: 1,
    'date agg': '2017-01-06'
  },
];

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      data: jsonData,
      mapping: {
        type: {
          type: "number"
        },
        'date agg': {
        	type: "date string"
        }
      }
    },
    slice: {
      rows: [{
        uniqueName: "type"
      }],
      columns: [{
        uniqueName: "[Measures]"
      }, ],
      measures: [
      {
      	uniqueName: "count",
        formula: "count('date agg')",
        grandTotalCaption: "Count"
      },
      {
      	uniqueName: "date agg",
        aggregation: "min",
        grandTotalCaption: "First visit"
      },
      {
      	uniqueName: "date agg",
        aggregation: "max",
        grandTotalCaption: "Last visit"
      },
      {
      	uniqueName: "special",
        formula: "distinctcount('type') / distinctcount('date agg')",
        grandTotalCaption: "Special"
      }
      ],
    },
  },
});