JSFiddle - React, Tailwind, and code Playground
Conditional formatting
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"></div>
CSS
.highlight-value {
font-style: italic !important;
}
.highlight-member {
font-weight: bold !important;
font-style: italic !important;
}
JavaScript
const highlightedMembers = ["Accessories", "Clothing", "Components"]
const pivot = new Flexmonster({
container: "pivot-container",
componentFolder: "https://cdn.flexmonster.com/",
toolbar: true,
customizeCell: customizeCellFunction,
report: {
dataSource: {
filename: "data/data.csv",
},
slice: {
rows: [{ uniqueName: "Category" }],
columns: [{ uniqueName: "Color" }, { uniqueName: "[Measures]" }],
measures: [{ uniqueName: "Price" }],
},
},
})
function customizeCellFunction(cell, data) {
if (highlightedMembers.includes(data.rows[0]?.caption)) {
if (!isNaN(data.value)) {
//Italic for values in selected rows
cell.addClass("highlight-value")
} else {
//Bold&italic for members in selected rows
cell.addClass("highlight-member")
}
}
}