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>
<script src="https://cdn.flexmonster.com/lib/flexmonster.highcharts.js"></script>
<script src="https://code.highcharts.com/4.2.2/highcharts.js"></script>
<table cellpadding="10">
<tr>
<td>
<div id="pivot-container"></div>
</td>
</tr>
<tr>
<td>
<div id="highcharts-container" style="width: 100%; height: 300px; display: inline-block;"></div>
</td>
</tr>
</table>
CSS
table {
width: 100%;
border-collapse: collapse;
}
JavaScript
var pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
report: {
dataSource: {
dataSourceType: "json",
data: getJSONData()
},
slice: {
rows: [{
uniqueName: "Discount"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Price"
},
{
uniqueName: "Quantity"
}
],
}
},
height: 280,
reportcomplete: function() {
pivot.off("reportcomplete");
createChart();
}
});
function createChart() {
pivot.highcharts.getData({
type: "line",
valuesOnly: false,
xAxisType: "string",
slice: {
rows: [{
uniqueName: "Discount"
}],
columns: [{
uniqueName: "[Measures]"
}],
measures: [{
uniqueName: "Quantity"
}, {
uniqueName: "Price"
}]
}
},
createAndUpdateChart,
createAndUpdateChart
);
}
function createAndUpdateChart(chartConfig, rawData) {
console.log("rawData: ");
console.log(rawData);
Highcharts.chart('highcharts-container', chartConfig);
}
function getJSONData() {
return [{
"Category": {
"type": "string"
},
"Color": {
"type": "string"
},
"Date": {
"type": "datetime",
"caption": "Date"
},
"Price": {
"type": "number"
},
"Quantity": {
"type": "number"
},
"Discount": {
"type": "string"
}
},
{
"Category": "Accessories",
"Color": "Green",
"Date": "2016-01-08",
"Price": 1740,
"Quantity": 22,
"Discount": "My text 23"
},
{
"Category": "Accessories",
"Color": "Red",
"Date": "2016-02-09",
"Price": 1664,
"Quantity": 19,
"Discount": "My text 7"
},
...