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>
JavaScript
let pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData(),
mapping: {
"Date1": {
type: "datetime",
},
"Date2": {
type: "datetime",
}
}
},
slice: {
rows: [{
uniqueName: "Date1"
},
{
uniqueName: "Date2",
}
],
columns: [{
uniqueName: "[Measures]"
}],
measures: [
{
"uniqueName": "Difference",
"formula": "(max(\"Date1\") - max(\"Date2\"))/86400000",
"format": "numberOfDays"
}]
},
formats: [
{
"name": "numberOfDays",
"decimalPlaces": 0
}
],
options: {
grid: {
type: "flat",
showTotals: "off",
showGrandTotals: "off"
},
dateTimePattern: "yyyy-MM-dd"
},
"conditions": [
{
"formula": "#value > 35",
"measure": "Difference",
"format": {
"backgroundColor": "#FFF9C4",
"color": "#000000",
"fontFamily": "Arial",
"fontSize": "12px"
}
}
],
}
});
function getData() {
return [{
"Date1": 1667551668000,
"Date2": 1664869668000
},
{
"Date1": 1667551668000,
"Date2": 1667292468000
},
{
"Date1": 1667551668000,
"Date2": 1655365668000
},]
}