Column chart
Integration with amCharts 5
by Flexmonster Pivot Table
HTML
<script src="https://cdn.flexmonster.com/flexmonster.js"></script>
<script src="https://cdn.flexmonster.com/lib/flexmonster.amcharts.js"></script>
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Kelly.js"></script>
<div id="pivotContainer">The component will appear here</div>
<div id="amcharts-container"></div>
CSS
@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);
#amcharts-container {
margin: 20px 0 20px 0;
height: 400px;
font-size: 15px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
JavaScript
let pivot = new Flexmonster({
container: "pivotContainer",
componentFolder: "https://cdn.flexmonster.com/",
licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
toolbar: true,
height: 430,
report: {
dataSource: {
filename: "data/data.csv",
},
slice: {
rows: [
{
uniqueName: "Country",
filter: {
exclude: ["country.[united states]"],
},
},
],
columns: [
{
uniqueName: "Color",
},
{
uniqueName: "[Measures]",
},
],
measures: [
{
uniqueName: "Price",
format: "currency",
},
{
uniqueName: "Quantity",
format: "quantity",
},
],
},
formats: [
{
name: "currency",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 2,
currencySymbol: "$",
currencySymbolAlign: "left",
nullValue: "",
textAlign: "right",
},
{
name: "quantity",
thousandsSeparator: ",",
decimalSeparator: ".",
decimalPlaces: 0,
currencySymbol: " psc.",
currencySymbolAlign: "right",
nullValue: "",
textAlign: "right",
},
],
},
reportcomplete: function () {
pivot.off("reportcomplete");
createChart();
},
});
let chart;
let root;
function createChart() {
pivot.amcharts.getData({}, drawChart, updateChart);
}
function drawChart(chartConfig, rawData) {
// Create root element
root = am5.Root.new("amcharts-container");
let data = chartConfig.data;
// Set themes
root.setThemes([am5themes_Animated.new(root), am5themes_Kelly.new(root)]);
// Convert the number format from Flexmonster to a format required by amCharts
let numberFormat = pivot.amcharts.getNumberFormatPattern(
...