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">The component will appear here</div>
JavaScript
var pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
report: {
dataSource: {
data: getData()
},
slice: {
columns: [{
uniqueName: "Color"
}],
rows: [{
uniqueName: 'Measures'
}],
measures: [{
uniqueName: "Price"
},
{
uniqueName: "Quantity"
}
]
},
options: {
viewType: "charts",
chart: {
type: "column_line"
}
}
}
});
flexmonster.on('afterchartdraw', function() {
if (flexmonster.getOptions().chart.type = "column_line") {
let bars = document.getElementsByClassName('fm-bar');
let circles = document.getElementsByClassName('fm-circle');
for (let i = 0; i < bars.length; i++) {
circles[i].setAttribute('cx', parseInt(bars[i].getAttribute('x')) + (bars[i].getAttribute('width')) / 2);
circles[i].setAttribute('transform', bars[i].parentElement.getAttribute('transform'));
}
}
});
function getData() {
return [{
"Color": {
"type": "string"
},
"M": {
"type": "month",
"caption": "Month"
},
"W": {
"type": "weekday",
"caption": "Week Day"
},
"Country": {
"type": "level",
"hierarchy": "Geography",
"level": "Country"
},
"State": {
"type": "level",
"hierarchy": "Geography",
"level": "State",
"parent": "Country"
},
"City": {
"type": "level",
"hierarchy": "Geography",
"parent": "State"
},
"Price": {
"type": "number"
},
"Quantity": {
"type": "number"
}
},
{
"Color": "green",
"M": "September",
"W": "Wed",
"Country": "Canada",
"State": "Ontario",
"City": "Toronto",
"Price": 174,
"Quantity": 22
},
{
"Color": "red",
"M":...