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>
<button onclick="getRowCount()">Get Row Count</button>
<div class="output-container" id="row-count-container" contenteditable="true"></div>
<button onclick="getColumnCount()">Get Column Count</button>
<div class="output-container" id="column-count-container" contenteditable="true"></div>
<div id="pivot-container"></div>
CSS
.output-container {
border: 2px solid #df3800;
background: #fdfd96;
color: #df3800;
text-transform: uppercase;
cursor: pointer;
margin: 10px 20px 10px 0px;
display: inline-block;
transition: all .3s;
font-weight: normal;
padding: 10px 10px;
font-size: 14px;
min-width: 50px;
}
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
type: "json",
data: getData()
},
slice: {
rows: [{
uniqueName: "Country"
}, {
uniqueName: "Category"
}, {
uniqueName: "[Measures]"
}],
columns: [{
uniqueName: "Color"
}],
measures: [{
uniqueName: "Price"
}, {
uniqueName: "Quantity"
}],
},
options: {
configuratorActive: false
}
},
width: "100%",
height: 370
});
function getRowCount() {
document.querySelector("#row-count-container").innerText = pivot.gridRowCount();
}
function getColumnCount() {
document.querySelector("#column-count-container").innerText = pivot.gridColumnCount();
}
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
}, {
"Category": "Accessories",
"Size": "214 oz",
"Color": "yellow",
"Destination": "Canada",
"Business Type": "Specialty Bike Shop",
"Country": "Canada",
"Price": 502,
"Quantity": 90,
"Discount": 17
}, {
"Category": "Components",
"Size": "235 oz",
"Color": "green",
"Destination": "Australia",
"Business Type": "Warehouse",
"Country": "Australia",
"Price": 551,
"Quantity": 1950,
"Discount": 51
}, {
"Category": "Components",
"Size": "307 oz",
"Color": "white",
"Destination": "United Kingdom",
"Business Type": "Warehouse",
"Country": "Canada",
"Price": 842,
"Quantity": 8212,
"Discount": 55
}, {
"Category": "Bikes",
"Size": "334 oz",
"Color": "red",
"Destination": "United States",
"Business Type": "Value Added Reseller",
"Country":...