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
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 430,
toolbar: true,
report: {
dataSource: {
dataSourceType: "json",
data: [
{
"referral": "r1",
"patient": "patient1",
"own": 1,
"active": 0,
"age": 12
},
{
"referral": "r2",
"patient": "patient1",
"own": 0,
"active": 1,
"age": 35
},
{
"referral": "r3",
"patient": "patient2",
"own": 1,
"active": 1,
"age": 87
},
{
"referral": "r4",
"patient": "patient3",
"own": 0,
"active": 1,
"age": 2
},
]
},
slice: {
rows: [{uniqueName: "referral"}],
columns: [{uniqueName: "[Measures]"}],
measures: [
{
"uniqueName": "uniquePatientCount",
"formula": "distinctcount(\"patient\")",
},
{
"uniqueName": "uniqueOwnPatientCount",
"formula": "if('own' == 1, distinctcount(\"patient\"), )"
},
{
"uniqueName": "uniqueActivePatientCount",
"formula": "if('active' == 1, distinctcount(\"patient\"), )"
},
{
"uniqueName": "uniqueOwnActivePatientCount",
"formula": "if('own' == 1 and 'active' == 1, distinctcount(\"patient\"), )"
},
{
"uniqueName": "uniqueAdultPatientCount",
"formula": "if('age' > 18, distinctcount(\"patient\"), )"
}
],
}
}
});