JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

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

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

JavaScript

var jsonData = [{
    id: 123,
    title: 'Rolling Stones',
    author: {
      id: 345,
      name: 'O. Henry'
    },
    month: 'January'
  },
  {
    id: 865,
    title: 'Some book',
    author: {
      id: 883,
      name: 'Jim Smith'
    },
    month: 'June'
  },
  {
    id: 981,
    title: 'Another book',
    author: {
      id: 884,
      name: 'Jim Smith'
    },
    month: 'June'
  }
];

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  report: {
    dataSource: {
      data: preprocessData(jsonData)
    },
     slice: {
      columns: [{
          uniqueName: "month"
        }
      ],
      rows: [
      {
          uniqueName: "author"
        },
      {
        uniqueName: "[Measures]"
      }, ],
      measures: [{
        uniqueName: "title",
        aggregation: "count",
        caption: "books"
      }]
    } 
  }
});


function preprocessData(data) {
  let i;
  let authorId;
  let authorName;
  for (i = 0; i < data.length; i++) {
    authorId = data[i].author.id;
    authorName = data[i].author.name;
  	data[i].author = `${authorName} (ID: ${authorId})`;
  }
  console.log(data);
  return data;
}