JSFiddle - React, Tailwind, and code Playground
by Sengupta
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<h3>
Use the Field List to modify the configuration
</h3>
<div>
<button id="btn" onclick="updateReport()">
Update data
</button>
</div>
<div id="pivotContainer"></div>
<div class="info">
<h3>
Logs Here:<br>
</h3>
<div id="monitor"></div>
</div>
CSS
#monitor {
white-space: pre;
padding: 10px;
overflow: auto;
height: 300px;
box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.302), 0 1px 3px 1px rgba(60, 64, 67, 0.149);
}
.info {
width: 70%;
margin-right: auto;
margin-left: auto;
}
.highlight {
background-color: #8BC34A;
}
JavaScript
var pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
height: 400,
report: {
dataSource: {
type: "api",
url: "https://olap.flexmonster.com:9500",
index: "fm-product-sales"
},
"slice": {
"rows": [{
"uniqueName": "Color"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "Price",
"aggregation": "sum"
}]
}
},
customizeAPIRequest: customizeAPIRequestFunction
});
function updateReport() {
flexmonster.updateData({"type":"api","url":"https://olap.flexmonster.com:9500","index":"fm-product-sales"});
}
function customizeAPIRequestFunction(req) {
let oldText = document.getElementById("monitor").innerText;
oldText = oldText + new Date().toLocaleTimeString() + '\n' + JSON.stringify(req);
document.getElementById("monitor").innerText = oldText + '\n';
}