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://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js"></script>

<div class='container'>
  <span style='font-size:16px'>
    retro
  </span>
  <div class="color-square" style="background-color: #bb3e03;"></div>
  <div class="color-square" style="background-color: #ca6702;"></div>
  <div class="color-square" style="background-color: #ee9b00;"></div>
  <div class="color-square" style="background-color: #fcbf49;"></div>
  <div class="color-square" style="background-color:#94d2bd;"></div>
  <div class="color-square" style="background-color: #0a9396;"></div>
  <div class="color-square" style="background-color: #026273;"></div>

</div>

<div class='container'>
  <span style='font-size:16px'>
    fresh
  </span>
  <div class="color-square" style="background-color: #24658d"></div>
  <div class="color-square" style="background-color: #429eb0;"></div>
  <div class="color-square" style="background-color: #379a86;"></div>
  <div class="color-square" style="background-color: #388968;"></div>
  <div class="color-square" style="background-color:#8fb140;"></div>
  <div class="color-square" style="background-color: #cad849;"></div>
  <div class="color-square" style="background-color: #115a43;"></div>

</div>
<br>
<div class='container'>
  Select chart colors:
  <select id='colors'>
    <option value="retro">retro</option>
    <option value='fresh'>fresh</option>
  </select>
</div>
<br><br>

<div id="pivot-container"></div>

CSS

/* .fm-charts-color-1 {
  fill: rgb(0, 164, 90) !important;
}

.fm-charts-color-2 {
  fill: rgb(223, 56, 0) !important;
}

.fm-charts-color-3 {
  fill: rgb(255, 184, 0) !important;
}

.fm-charts-color-4 {
  fill: rgb(109, 59, 216) !important;
}

.fm-charts-color-5 {
  fill: rgb(0, 117, 255) !important;
}

.fm-charts-color-6 {
  fill: rgb(206, 151, 230) !important;
}

.fm-charts-color-7 {
  fill: none !important;
} */

/* #fm-pivot-view .fm-bar,
#fm-pivot-view .fm-charts-view .fm-chart-legend ul li .fm-icon-display,
#fm-pivot-view .fm-line,
#fm-pivot-view .fm-arc path,
#fm-pivot-view .fm-bar-stack,
#fm-pivot-view .fm-scatter-point {
  opacity: 70% !important;
} */

select{
  border: 2px solid #333;
  background: #fff;
  color: #333;
  margin: 5px 0;
  display: inline-block;
  transition: all .3s;
  font-weight: normal;
  padding: 10px 10px;
  font-size: 14px;
    text-transform: uppercase;
  cursor: pointer;
}

.container{
  align-items: center;
   text-transform: uppercase;
  display: inline-flex;
  padding: 15px;
  column-gap: 10px;
  font-size:16px;
}

.color-square {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 5px;
  
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 500,
  toolbar: true,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }],
      columns: [{
          uniqueName: "Color"
        },
        {
          uniqueName: "[Measures]"
        }
      ],
      measures: [{
        uniqueName: "Price",
        format: "currency"
      }]
    },
    options: {
      viewType: "charts",
      chart: {
        type: "column"
      }
    },
    formats: [{
      name: "currency",
      currencySymbol: "$",
    }]
  }
});
let fmColors = {};

pivot.on("reportcomplete", () => {
  pivot.off("reportcomplete");
  fetchInitialColors();
  pivot.customizeChartElement(customizeFunction);
})

const colorSelect = document.getElementById('colors');
const colors = {
  "retro": [tinycolor('#bb3e03'), tinycolor('#ca6702'), tinycolor('#ee9b00'), tinycolor('#fcbf49'), tinycolor('#94d2bd'), tinycolor('#0a9396'), tinycolor('#026273')],
  "fresh": [tinycolor('#24658d'), tinycolor('#429eb0'), tinycolor('#379a86'), tinycolor('#388968'), tinycolor('#8fb140'), tinycolor('#cad849'), tinycolor('#115a43')]
};
let selectedColors = colors.fresh;

colorSelect.addEventListener('change', (event) => {
  selectedColors = colors[event.target.value];
  fetchInitialColors();
  pivot.customizeChartElement(customizeFunction);
});


function customizeFunction(element, data) {
  if (data.type == "legend") {
    element.querySelector(".fm-icon-display").style.backgroundColor = fmColors[data.label];
  } else {
    element.style.fill = fmColors[data.label];
  }
}

function fetchInitialColors() {
    const noMeasuresColumns = pivot.getReport().slice.columns.filter(c=>c.uniqueName!=='[Measures]');
    
    const memberLabels = pivot.getMembers(noMeasuresColumns[0].uniqueName).map(m => m.caption);
  for (let i in memberLabels) {
   ...