Flexmonster Software License Agreement (“Agreement”) has been revised and is effective as of October 15, 2026.
The following modifications were made:
Downloading, installing, and/or continuing to use Flexmonster Software after October 15, 2026, constitutes Licensee’s acceptance of the terms and conditions of the modified version of Agreement. If Licensee does not agree to any of these terms and conditions, they must cease using Flexmonster Software and must not download, install, use, access, or continue to access Flexmonster Software. By continuing to use Flexmonster Software or renewing the license or maintenance after the effective date of these modifications to Agreement, Licensee accepts and agrees to be bound by the terms and conditions of the modified Agreement.
Flexmonster Pivot Charts can be customized and adjusted to the user's needs via CSS or via the customizeChartElement() API call. For example, you can change colors for chart elements, add custom attributes, and so on.
This guide contains several use cases of chart element customization. However, they do not demonstrate all the customization possibilities. To see more examples, visit the Examples page.
Using the .fm-charts-color-n selector, you can change the default colors for each chart sector. In this example, we specify six colors. The seventh selector is specified with fill: none so that custom colors are repeated if there are more than six chart sectors. Otherwise, Flexmonster would use its own colors.
.fm-charts-color-1 {
fill: rgb(0, 164, 90) !important;
}
/* CSS rules for chart sectors 2-5 */
.fm-charts-color-6 {
fill: rgb(206, 151, 230) !important;
}
.fm-charts-color-7 {
fill: none !important;
}The customizeChartElement() method allows you to set a function that will be triggered for each chart element during rendering.
Inside the function, information about the chart element (e.g., the measure associated with the element) can be accessed using the data parameter. Based on that information, you can customize the element's representation or functionality through the element parameter of the function. For example, it is possible to add HTML attributes, classes, inline CSS styles, and change the legend element's label.
This example illustrates how chart elements that contain info about a specific field member (e.g., the United States) can be highlighted with a custom color:
Step 1. Define the customizeChartElementFunction() and specify the highlight color and the member that should be highlighted (e.g., the United States):
const pivot = new Flexmonster({
// Other configs
// ...
customizeChartElement: customizeChartElementFunction
});
function customizeChartElementFunction(element, data) {
let newColor = tinycolor("#1a0019");
let memberToHighlight = "country.[united states]";
}Step 2. Create a function to check whether the chart element is related to the necessary member:
function contains(data, memberName) {
if (data && data.rows) {
for (let i = 0; i < data.rows.length; i++) {
if (data.rows[i].uniqueName == memberName) {
return true;
}
}
}
if (data && data.columns) {
for (let i = 0; i < data.columns.length; i++) {
if (data.columns[i].uniqueName == memberName) {
return true;
}
}
}
return false;
}Step 3. By default, expanded chart elements have their own shade of the parent element's color. We will create a function to change a shade for each expanded element related to the necessary member (e.g., the United States):
function applyShade(newColor, oldColor) {
// Get the lightness of the default color
// Here we divide it by 2 to adjust the default lightness
// and get a darker color as a result
let colorLightness = tinycolor(oldColor).toHsl().l/2;
// Apply the lightness to the new color
let result = newColor.toHsl();
result.l = colorLightness;
// Return the created color shade
return tinycolor(result).toHexString();
}Note that this function uses the TinyColor library for color conversions. You can include the library in your project with the following script:
<script
src="https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js">
</script>
Step 4. If a chart element is related to the necessary member (e.g., the United States), highlight the element. Note that each chart type should be handled separately because of differences in element structures:
function customizeChartElementFunction(element, data) {
// Code from step 1
if (contains(data, memberToHighlight)) {
switch (data.chartType) {
case "line":
case "scatter":
element.style.stroke = applyShade(newColor, element.style.stroke);
break;
case "pie":
if (element.querySelector("path")) {
element.querySelector("path").style.fill = applyShade(
newColor,
element.querySelector("path").style.fill
);
}
break;
case "column_line":
if (element.classList.contains("fm-line") || element.classList.contains("fm-circle")) {
element.style.stroke = applyShade(newColor, element.style.stroke);
}
if (element.classList.contains("fm-bar")) {
element.style.fill = applyShade(newColor, element.style.fill);
}
break;
default:
element.style.fill = applyShade(newColor, element.style.fill);
}
}
}Step 5. Update the chart legend item's color:
function customizeChartElementFunction(element, data) {
// Code from steps 1 and 4
if (data && data.type === "legend") {
if (data.member && data.member.uniqueName === memberToHighlight && !data.isExpanded) {
element.querySelector(".fm-icon-display").style.backgroundColor =
applyShade(newColor, data.color);
}
if (
data.tuple &&
isChild(data.tuple, data.member.uniqueName, memberToHighlight) &&
!data.isExpanded
) {
element.querySelector(".fm-icon-display").style.backgroundColor =
applyShade(newColor, data.color);
}
}
}The isChild() function checks whether a legend element’s member is a child of a specific member.
Can't find your answer here?
Visit the FAQ page
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 three licensing models: a Single Corporate License for internal use by one company (from $799/year), a SaaS License for embedding Flexmonster into a multi-tenant platform (from $2,499/year), and an OEM License for vendors distributing Flexmonster inside a product installed at other businesses (from $1,499/year for a 3-license bundle). Every license allows an unlimited number of developers and covers development, staging, and production environments at no extra charge.
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.