JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<button onclick="getFilter()">Get filter</button>
<div id="pivot-container"></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 endpointUrl = "https://olap.flexmonster.com:9500/";
let index = "nonexistent_index";
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 550,
toolbar: true,
report: {
"dataSource": {
"type": "api",
"url": pivotEndpoint,
"index": index,
},
"slice": {
"rows": [
{
"uniqueName": "Date##Calendar##Calendar Month",
}
],
"columns": [
{
"uniqueName": "[Measures]"
}
],
"measures": [
{
"uniqueName": "Weight",
"aggregation": "sum"
}
]
}
}
});
function pivotEndpoint(requestStringified, successCallback, errorCallback) {
let request = JSON.parse(requestStringified);
let response;
if(request.type === 'handshake') {
response = {"success":true,"version":"2\u002e8\u002e5"};
}
else if(request.type === 'fields') {
response = {
"fields": [
{
"uniqueName": "Date##Calendar##Calendar Month",
"folder": "Date",
"type": "string",
"caption": "Date\\Calendar Month"
},
{
"uniqueName": "Weight",
"type": "number",
"caption": "Weight"
},
],
"aggregations": {
"any": [
"count",
"distinctcount"
],
"date": [
"count",
"distinctcount",
"min",
"max"
],
"number": [
"sum",
"average",
"count",
"distinctcount",
"min",
"max"
]
},
"filters": {
"date": {
"members": true,
"query": [
"equal",
"not_equal",
"after",
"after_equal",
"before",
"before_equal",
"between",
"not_between",
"last",
"current",
...