API calls setFilter, getFilter, clearFilter
Slice configuration
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="getFilter()">Get Filter</button>
<button onclick="clearFilter()">Clear Filter</button>
<button onclick="startUpdates()">Flash Data</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 pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 470,
report: {
dataSource: {
data: [
{
"Country": "Australia",
"City": "Canberra",
"Contact First Name": "Riki",
"Deal Size": "Small",
"Contact Last Name": "Carle",
"Product Code": "OP139",
"Quantity": 109,
"Price": 677,
"Status": "On Hold",
"Phone": "473-632-1982",
"Retail Category": "Home & kitchen",
"Order Date": "2019-09-23",
"CurrencyID": "AUD",
"Date": "2019-09-23",
"Sales": 73793
},
{
"Country": "Japan",
"City": "Tokyo",
"Contact First Name": "Elwira",
"Deal Size": "Small",
"Contact Last Name": "Persent",
"Product Code": "SR81",
"Quantity": 98,
"Price": 417,
"Status": "On Hold",
"Phone": "365-218-6144",
"Retail Category": "Grocery & gourmet food",
"Order Date": "2019-10-20",
"CurrencyID": "JPY",
"Date": "2019-10-20",
"Sales": 40866
}]
},
slice: {
rows: [
{
uniqueName: "Country",
},
],
columns: [
{
uniqueName: "[Measures]",
},
],
measures: [
{
uniqueName: "Price",
},
],
},
},
});
function getFilter() {
let filter = flexmonster.getFilter("Country");
showOutput(JSON.stringify(filter, null, 4));
}
function clearFilter() {
flexmonster.clearFilter("Country");
}
function showOutput(content) {
document.getElementById("output").innerText = content;
} function startUpdates(){
setInterval(() => {
const number = Math.random()
const updatedDoc = [{
"Country": "Japan" + number,
"City": "Tokyo",
"Contact First Name": "Elwira",
"Deal Size": "Small",
"Contact Last Name": "Persent",
"Product Code": "SR81",
"Quantity": 98,
"Price": 417,
"Status": "On Hold",
"Phone": "365-218-6144",
"Retail Category": "Grocery & gourmet food",
"Order...