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>
<button onclick="toOwnPatients()">Own Patients</button>
<button onclick="toPorPatients()">Portal Patients</button>
<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: [{
"visit": "v1",
"patient": "p1",
"type": "t1",
"own": 1
},
{
"visit": "v2",
"patient": "p1",
"type": "t1",
"own": 1
},
{
"visit": "v3",
"patient": "p2",
"type": "t1",
"own": 0
},
{
"visit": "v4",
"patient": "p3",
"type": "t1",
"own": 1
},
{
"visit": "v5",
"patient": "p4",
"type": "t2",
"own": 1
},
{
"visit": "v6",
"patient": "p5",
"type": "t2",
"own": 0
},
]
},
slice: {
rows: [{
uniqueName: "type"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
"uniqueName": "uniquePatientCount",
"formula": "distinctcount('patient')",
}],
}
}
});
function toOwnPatients() {
pivot.runQuery({
"reportFilters": [{
"uniqueName": "own",
"filter": {
"members": [
"own.[1]"
]
}
}],
"rows": [{
"uniqueName": "type"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName": "uniqueOwnPatientCount",
"formula": "distinctcount('patient')",
"caption": "uniqueOwnPatientCount"
}]
}, );
}
function toPorPatients() {
pivot.runQuery({
"reportFilters": [{
"uniqueName": "own",
"filter": {
"members": [
"own.[0]"
]
}
}],
"rows": [{
"uniqueName": "type"
}],
"columns": [{
"uniqueName": "[Measures]"
}],
"measures": [{
"uniqueName":...