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="pivot-container"></div>
<p>
Select request filter is here:
</p>
<div class="output" id="output">"filter":{
"type":"and",
"value":[
{
"type":"or",
"value":[
{
"field":{
"uniqueName":"Category"
},
"query":{
"begin":"b"
}
},
{
"field":{
"uniqueName":"Color"
},
"query":{
"begin":"b"
}
}
]
}
]
}</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;
}
p {
padding-left: 20px;
font-size: 14px;
font-weight: 600
}
JavaScript
let pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
toolbar: true,
report: {
dataSource: {
type: "api",
url: "https://olap.flexmonster.com:9500",
index: "fm-product-sales",
mapping: {
"Category": {
type: "string",
hierarchy: "Item"
},
"Color": {
type: "string",
hierarchy: "Item",
parent: "Category"
}
}
},
slice: {
rows: [{
uniqueName: "Item",
filter: {
query: {
begin: "b"
}
}
}],
columns: [{
uniqueName: "Country"
}, {
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price",
aggregation: "sum"
}]
}
}
});
pivot.expandAllData();