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 class="demo-box">
<div class="demo-title">
Orders by Year
</div>
<div id="pivot1-container"></div>
</div>
<div class="demo-box">
<div class="demo-title">
Revenue by City
</div>
<div id="pivot2-container"></div>
</div>
CSS
/* Charts Styles */
/* Make the chart cirles larger */
#fm-pivot-view .fm-chart .fm-circle {
r: 8;
}
/* Change chart colors */
.fm-charts-color-1 {
fill: rgb(0, 164, 90) !important;
}
.fm-charts-color-2 {
fill: rgb(223, 56, 0) !important;
}
.fm-charts-color-3 {
fill: rgb(255, 184, 0) !important;
}
.fm-charts-color-4 {
fill: rgb(109, 59, 216) !important;
}
.fm-charts-color-5 {
fill: rgb(0, 117, 255) !important;
}
#fm-pivot-view .fm-bar,
#fm-pivot-view .fm-charts-view .fm-chart-legend ul li .fm-icon-display,
#fm-pivot-view .fm-line,
#fm-pivot-view .fm-arc path,
#fm-pivot-view .fm-bar-stack,
#fm-pivot-view .fm-scatter-point {
opacity: 70% !important;
}
#fm-yAxis-label,
#fm-xAxis>text,
#fm-yAxis>text {
display: none;
}
/* Layout styles */
.demo-box {
background-color: #fafafa;
position: relative;
padding: 30px;
margin-bottom: 20px;
border: 1px solid #e9e9e9;
}
.demo-title {
font-size: 18px;
margin-bottom: 20px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
JavaScript
var pivot1 = new Flexmonster({
container: "#pivot1-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 500,
report: {
dataSource: {
data: getData(),
mapping: {
"Age": {
"type": "number"
},
"Order Date": {
"type": "date"
},
"City": {
"type": "string"
},
"Amount": {
"type": "number"
},
"Price": {
"type": "number"
},
"Payment Type": {
"type": "string"
},
"Referring Site": {
"type": "string"
},
"Orders": {
"type": "number"
},
"Name": {
"type": "string"
}
}
},
options: {
viewType: "charts",
chart: {
type: "line",
showDataLabels: true
},
configuratorActive: false
},
slice: {
rows: [{
uniqueName: "Order Date.Year"
}],
columns: [{
uniqueName: "[Measures]"
},
{
uniqueName: "Referring Site",
filter: {
measure: {
uniqueName: "Orders",
aggregation: "sum"
},
query: {
top: 2
}
}
}
],
measures: [{
uniqueName: "Orders",
aggregation: "sum"
}],
sorting: {
row: {
type: "desc",
tuple: [],
measure: {
uniqueName: "Orders",
aggregation: "sum"
}
}
}
}
}
});
var pivot2 = new Flexmonster({
container: "#pivot2-container",
componentFolder: "https://cdn.flexmonster.com/",
width: "100%",
height: 500,
report: {
dataSource: {
data: getData(),
mapping: {
"Age": {
"type": "number"
},
"Order Date": {
"type": "date"
},
"City": {
"type": "string"
...