JSFiddle - React, Tailwind, and code Playground
by Flexmonster Pivot Table
January 16, 2020
HTML
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<div class="description">Try to change the report</div>
<div id="notification">Something has been changed</div>
<div id="pivot-container"></div>
CSS
#notification {
border: 2px solid #df3800;
background: white;
color: #df3800;
text-transform: uppercase;
cursor: default;
display: inline-block;
-webkit-transition: all .3s;
transition: all .3s;
font-weight: bold;
padding: 10px 10px;
font-size: 14px;
opacity: 0;
position: absolute;
z-index: 20;
left: 50%;
top: 15px;
transform: translate(-50%, 0)
}
.description {
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
margin: 15px 0px 15px 5px;
}
JavaScript
new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
filename: "data/sales.csv"
},
slice: {
columns: [{
uniqueName: "Month"
}, {
uniqueName: "[Measures]"
}],
rows: [{
uniqueName: "Category",
filter: {
members: [
"category.[condiments].[bbq sauce]",
"category.[breakfast cereals].[corn flakes]",
"category.[confectionery]",
"category.[bakery].[chocolate biscuits]",
"category.[fruit preserves].[apple jam]",
"category.[bakery].[apple cake]",
"category.[soups].[tomato soup]"
]
}
}],
measures: [{
"uniqueName": "Revenue",
"aggregation": "sum",
"format": "2sfou03a"
}]
},
conditions: [{
formula: "#value < 2500",
measure: "Revenue",
format: {
backgroundColor: "#df3800",
color: "#FFFFFF"
},
isTotal: false
}, {
formula: "#value > 20000",
measure: "Revenue",
format: {
backgroundColor: "#00A45A",
color: "#FFFFFF"
},
isTotal: false
}],
formats: [{
name: "2sfou03a",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2,
currencySymbol: "$",
currencySymbolAlign: "left",
nullValue: "",
textAlign: "right",
isPercent: false
}]
}
});
flexmonster.on('reportchange', 'notify');
function notify() {
var notification = document.getElementById('notification');
notification.style.opacity = 1;
setTimeout(function() { notification.style.opacity = 0; }, 1000);
}