Manage how entire rows, columns, or specific cells are styled within the pivot table component.
Play with the demo on a larger screen: save this link for later or watch the video review now.
const pivot = new Flexmonster({
container: "#pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
height: 600,
report: {
dataSource: {
type: "csv",
filename: "https://cdn.flexmonster.com/data/data.csv",
},
slice: {
rows: [
{
uniqueName: "Country",
},
{
uniqueName: "Business Type",
},
],
columns: [
{
uniqueName: "Color",
},
{
uniqueName: "[Measures]",
},
],
measures: [
{
uniqueName: "Quantity",
aggregation: "percentofcolumn",
},
],
expands: {
expandAll: true,
},
},
formats: [
{
decimalPlaces: 2,
},
],
},
customizeCell: customizeCellFunction,
});
function customizeCellFunction(cell, data) {
if (data?.type === "value" && !data?.isDrillThrough) {
if (data.value < 5) {
cell.text = `<img src="https://cdn.flexmonster.com/i/empty_pie.svg" class="centered">`;
} else if (data.value >= 5 && data.value < 10) {
cell.text = `<img src="https://cdn.flexmonster.com/i/quarter_pie.svg" class="centered">`;
} else if (data.value >= 10 && data.value < 25) {
cell.text = `<img src="https://cdn.flexmonster.com/i/half_pie.svg" class="centered">`;
} else if (data.value >= 25 && data.value < 50) {
cell.text = `<img src="https://cdn.flexmonster.com/i/three_quarters_pie.svg" class="centered">`;
} else if (data.value >= 50) {
cell.text = `<img src="https://cdn.flexmonster.com/i/full_pie.svg" class="centered">`;
}
}
}
<div id="pivot-container"></div>
img.centered {
display: block !important;
margin: auto !important;
color: transparent !important;
}
#fm-pivot-view .fm-grid-row {
min-height: 47px;
}
What makes Flexmonster different from other solutions on the market is its high customizability. Not only can you change component themes and customize the Toolbar, but you can also replace cell values with any visual content (e.g., with icons), highlight cells based on their data, add hyperlinks, style totals and grand totals, and more.
In this demo, you can see how to substitute numbers with icons based on cell values. Play with the demo's code to learn how you can achieve this with one hook.
Can't find your answer?
Visit the FAQ
Flexmonster Pivot Table & Charts is a JavaScript pivot table component for adding interactive reporting and data analysis to web applications. Users can summarize, filter, sort, and explore data in pivot tables and charts, drill into results, and export reports.
Flexmonster works in plain JavaScript and TypeScript projects. It also integrates with React, Next.js, Angular, Vue, Blazor, and other technologies. See all integration options.
Flexmonster supports JSON and CSV files, SQL databases, MongoDB, Elasticsearch, and Microsoft Analysis Services (SSAS). You can also connect other data sources through your own backend. See supported data sources.
Flexmonster offers licenses for internal corporate use, SaaS products, and OEM distribution. Pricing varies by license and plan. SaaS projects can also use the free SaaS Entry license during development. Learn more on the pricing page.
Yes. Flexmonster offers a 30-day free trial that lets you evaluate all its features. No credit card is required. The trial version has a watermark.
To get started with Flexmonster, follow our integration guide.