JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
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="pivotContainer"></div>
<div class="output" id="output">Output will appear here</div>
CSS
.output {
width: 80%;
height: 300px;
margin-left: auto;
margin-right: auto;
padding: 20px;
background: rgba(242, 242, 242, 1);
font-family: Menlo, Monaco, "Courier New", Courier, monospace;
white-space: pre;
font-size: 16px;
font-weight: 400;
overflow-y: scroll;
margin-top: 20px;
}
JavaScript
let pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
RecordId: {
type: "id"
}
}
},
"slice": {
"rows": [{
"uniqueName": "Country"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Category",
"aggregation": "distinctcount"
}]
},
"options": {
"drillThrough": false
}
}
});
flexmonster.on("celldoubleclick", cell => {
if(cell.type == "value") {
showOutput("Records used for this intersection: " + cell.recordId);
}
});
function getData() {
return [{
"Category": "Accessories",
"Size": "262 oz",
"Color": "red",
"Destination": "Australia",
"Business Type": "Specialty Bike Shop",
"Country": "Australia",
"Price": 174,
"Quantity": 225,
"Discount": 23,
"RecordId": 1
},
{
"Category": "Accessories",
"Size": "214 oz",
"Color": "yellow",
"Destination": "Canada",
"Business Type": "Specialty Bike Shop",
"Country": "Canada",
"Price": 502,
"Quantity": 90,
"Discount": 17,
"RecordId": 2
},
{
"Category": "Components",
"Size": "97 oz",
"Color": "red",
"Destination": "Germany",
"Business Type": "Value Added Reseller",
"Country": "Canada",
"Price": 485,
"Quantity": 329,
"Discount": 62,
"RecordId": 3
},
{
"Category": "Components",
"Size": "272 oz",
"Color": "blue",
"Destination": "United Kingdom",
"Business Type": "Value Added Reseller",
"Country": "France",
"Price": 212,
"Quantity": 4057,
"Discount": 27,
"RecordId": 4
},
{
"Category": "Components",
"Size": "334 oz",
"Color": "red",
...