pace-table-lib 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8781,27 +8781,48 @@
8781
8781
  if (rowIndex < fixedRowCount || columnIndex < fixedColCount) return null;
8782
8782
  const rowIdxHeat = rowIndex - fixedRowCount;
8783
8783
  const colIdxHeat = columnIndex - fixedColCount;
8784
- const isPercentageMode = DataField?.percentageBy?.toLowerCase?.() && DataField.percentageBy.toLowerCase() !== "absolute";
8784
+ let pct;
8785
+ let innerDivBg = "none";
8786
+ if (isDataBarOn) {
8787
+ if (showDataBarValOnTooltip) {
8788
+ const val = dataBarMatrix[rowIdxHeat]?.[colIdxHeat];
8789
+ if (val !== void 0) pct = `${(val * 100).toFixed(2)}%`;
8790
+ }
8791
+ innerDivBg = getBgColorForDataBar(rowIdxHeat, colIdxHeat);
8792
+ }
8793
+ const parent = measuresBySlice[rowIdxHeat]?.sliceMark?.[0];
8794
+ const parentBg = parent ? parentBandColorMap[parent] : void 0;
8795
+ let outerDivBg = "none";
8796
+ if (ShowHeatMap) {
8797
+ outerDivBg = getBgColorForHetMap(rowIdxHeat, colIdxHeat);
8798
+ } else {
8799
+ outerDivBg = parentBg ?? dataColors.evenColor;
8800
+ }
8801
+ const baseStyle = {
8802
+ ...style,
8803
+ ...dataCellFont,
8804
+ background: outerDivBg
8805
+ };
8785
8806
  const isLastRow = rowIndex === rowCount - 1;
8786
8807
  const isLastCol = columnIndex === columnCount - 1;
8787
- const val = dataBarMatrix[rowIdxHeat]?.[colIdxHeat];
8788
- const pct = isDataBarOn && showDataBarValOnTooltip && val !== void 0 ? `${(val * 100).toFixed(2)}%` : void 0;
8789
- const innerDivBg = isDataBarOn ? getBgColorForDataBar(rowIdxHeat, colIdxHeat) : "none";
8790
- const parent = measuresBySlice[rowIdxHeat]?.sliceMark?.[0];
8791
- const outerDivBg = ShowHeatMap ? getBgColorForHetMap(rowIdxHeat, colIdxHeat) : parent ? parentBandColorMap[parent] : dataColors.evenColor;
8792
- const baseStyle = { ...style, ...dataCellFont, background: outerDivBg };
8793
8808
  let rawValue;
8794
8809
  let isBold = true;
8795
8810
  const bgColorForTotals = getBgColorForCell(rowCount - fixedRowCount, dataColors);
8796
8811
  if (isColTotalOn && isRowTotalOn && !headerAtStart && isLastRow && isLastCol) {
8797
8812
  baseStyle.background = bgColorForTotals;
8798
- rawValue = isPercentageMode ? 1 : grandTotal;
8813
+ rawValue = grandTotal;
8814
+ if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
8815
+ rawValue = 1;
8816
+ }
8799
8817
  } else if (isColTotalOn && !headerAtStart && isLastRow) {
8800
8818
  baseStyle.background = bgColorForTotals;
8801
- rawValue = isPercentageMode ? 1 : columnTotalRow[colIdxHeat]?.columnTotal;
8819
+ rawValue = columnTotalRow[colIdxHeat]?.columnTotal;
8820
+ if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
8821
+ rawValue = 1;
8822
+ }
8802
8823
  } else if (isRowTotalOn && !headerAtStart && isLastCol) {
8803
8824
  rawValue = 1;
8804
- } else if (isPercentageMode) {
8825
+ } else if (DataField.hasOwnProperty("percentageBy") && DataField?.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
8805
8826
  if (DataField?.percentageBy === "Row-wise") {
8806
8827
  rawValue = getPercentageBy(measuresBySlice[rowIdxHeat]?.measures?.[colIdxHeat], measuresBySlice[rowIdxHeat].rowTotal);
8807
8828
  } else {
@@ -8813,23 +8834,39 @@
8813
8834
  isBold = false;
8814
8835
  }
8815
8836
  if (rawValue === void 0) return null;
8816
- const dimName = dimensionMarks[colIdxHeat]?.[fixedRowCount - 1];
8837
+ const dimName = dimensionMarks[colIdxHeat]?.[fixedRowCount - 1] ?? void 0;
8817
8838
  const formattingObj = getMeasureFormattingObj(dimName);
8818
8839
  const conditionalFormatObj = getConditionalFormat(rawValue, CONDITIONAL_FORMAT_FOR.VALUE);
8819
8840
  const numberFormat = conditionalFormatObj?.numberFormat ?? formattingObj.numberFormat;
8820
8841
  const decimalPrecision = conditionalFormatObj?.decimalPrecision ?? formattingObj.decimalPrecision;
8821
8842
  const displayUnits = conditionalFormatObj?.displayUnits ?? formattingObj.displayUnits;
8822
- let formattedValue = formatValue(rawValue, numberFormat, decimalPrecision, displayUnits);
8823
- if (isPercentageMode) formattedValue = formatValue(rawValue, VALUE_FORMAT_OBJ.PERCENT_SHORT);
8824
- const finalStyle = {
8843
+ let formattedValue = formatValue(
8844
+ rawValue,
8845
+ numberFormat,
8846
+ decimalPrecision,
8847
+ displayUnits
8848
+ );
8849
+ if (DataField.hasOwnProperty("percentageBy") && DataField?.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
8850
+ formattedValue = formatValue(rawValue, VALUE_FORMAT_OBJ.PERCENT_SHORT);
8851
+ }
8852
+ let finalStyle = {
8825
8853
  ...baseStyle,
8826
- fontWeight: isBold ? "bold" : "normal",
8827
- ...conditionalFormatObj?.fontFamily && { fontFamily: conditionalFormatObj.fontFamily },
8828
- ...conditionalFormatObj?.fontSize && { fontSize: conditionalFormatObj.fontSize },
8829
- ...conditionalFormatObj?.backgroundColor && { background: conditionalFormatObj.backgroundColor },
8830
- ...conditionalFormatObj?.color && { color: conditionalFormatObj.color }
8854
+ fontWeight: isBold ? "bold" : "normal"
8831
8855
  };
8832
- return renderDataCell(formattedValue, finalStyle, "data_div", "data_label_div", pct, innerDivBg);
8856
+ if (conditionalFormatObj) {
8857
+ if (conditionalFormatObj.fontFamily) finalStyle.fontFamily = conditionalFormatObj.fontFamily;
8858
+ if (conditionalFormatObj.fontSize) finalStyle.fontSize = conditionalFormatObj.fontSize;
8859
+ if (conditionalFormatObj.backgroundColor) finalStyle.background = conditionalFormatObj.backgroundColor;
8860
+ if (conditionalFormatObj.color) finalStyle.color = conditionalFormatObj.color;
8861
+ }
8862
+ return renderDataCell(
8863
+ formattedValue,
8864
+ finalStyle,
8865
+ "data_div",
8866
+ "data_label_div",
8867
+ pct,
8868
+ innerDivBg
8869
+ );
8833
8870
  };
8834
8871
  function getBgColorForHetMap(rowIdx, colIdx) {
8835
8872
  return heatColorMatrix[rowIdx][colIdx];