pace-table-lib 1.0.7 → 1.0.9
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.
- package/dist/components/StaticTable/HelperFunctions.d.ts +1 -0
- package/dist/components/StaticTable/StaticTableTypeDec.types.d.ts +2 -0
- package/dist/pace-table-lib.es.js +93 -125
- package/dist/pace-table-lib.es.js.map +1 -1
- package/dist/pace-table-lib.umd.js +93 -125
- package/dist/pace-table-lib.umd.js.map +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -8051,45 +8051,48 @@
|
|
|
8051
8051
|
return new Date(ms);
|
|
8052
8052
|
}
|
|
8053
8053
|
function formatDate(value, formatKey) {
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8054
|
+
try {
|
|
8055
|
+
const date = toDateFromExcel(value);
|
|
8056
|
+
const day = pad(date.getDate());
|
|
8057
|
+
const month = pad(date.getMonth() + 1);
|
|
8058
|
+
const year = date.getFullYear();
|
|
8059
|
+
const shortYear = year.toString().slice(-2);
|
|
8060
|
+
const monthShort = MONTHS_SHORT[date.getMonth()];
|
|
8061
|
+
const monthFull = MONTHS_FULL[date.getMonth()];
|
|
8062
|
+
switch (formatKey) {
|
|
8063
|
+
case DATE_FORMAT_OBJ.DD_MM_YYYY:
|
|
8064
|
+
return `${day}-${month}-${year}`;
|
|
8065
|
+
case DATE_FORMAT_OBJ.MM_DD_YYYY:
|
|
8066
|
+
return `${month}-${day}-${year}`;
|
|
8067
|
+
case DATE_FORMAT_OBJ.YYYY_MM_DD:
|
|
8068
|
+
return `${year}-${month}-${day}`;
|
|
8069
|
+
case DATE_FORMAT_OBJ.YYYY:
|
|
8070
|
+
return `${year}`;
|
|
8071
|
+
case DATE_FORMAT_OBJ.DD_MM:
|
|
8072
|
+
return `${day}-${month}`;
|
|
8073
|
+
case DATE_FORMAT_OBJ.MMM_YY:
|
|
8074
|
+
return `${monthShort}-${shortYear}`;
|
|
8075
|
+
case DATE_FORMAT_OBJ.YY_MMM:
|
|
8076
|
+
return `${shortYear}-${monthShort}`;
|
|
8077
|
+
case DATE_FORMAT_OBJ.MM_YYYY:
|
|
8078
|
+
return `${month}-${year}`;
|
|
8079
|
+
case DATE_FORMAT_OBJ.YYYY_MM:
|
|
8080
|
+
return `${year}-${month}`;
|
|
8081
|
+
case DATE_FORMAT_OBJ.MMMM_YYYY:
|
|
8082
|
+
return `${monthFull}-${year}`;
|
|
8083
|
+
case DATE_FORMAT_OBJ.MMMM_YY:
|
|
8084
|
+
return `${monthFull}-${shortYear}`;
|
|
8085
|
+
case DATE_FORMAT_OBJ.DD_MMM:
|
|
8086
|
+
return `${day}-${monthShort}`;
|
|
8087
|
+
case DATE_FORMAT_OBJ.DD_MMM_YY:
|
|
8088
|
+
return `${day}-${monthShort}-${shortYear}`;
|
|
8089
|
+
case DATE_FORMAT_OBJ.DD_MMM_YYYY:
|
|
8090
|
+
return `${day}-${monthShort}-${year}`;
|
|
8091
|
+
}
|
|
8092
|
+
} catch (error) {
|
|
8093
|
+
console.log(error);
|
|
8092
8094
|
}
|
|
8095
|
+
return value;
|
|
8093
8096
|
}
|
|
8094
8097
|
function formatValue(value, format, decimalValues = 2, displayUnit = DISPLAY_UNITS_OBJ.NONE) {
|
|
8095
8098
|
try {
|
|
@@ -8152,8 +8155,8 @@
|
|
|
8152
8155
|
}
|
|
8153
8156
|
} catch (error) {
|
|
8154
8157
|
console.error("Error in formatValue:", error);
|
|
8155
|
-
return value;
|
|
8156
8158
|
}
|
|
8159
|
+
return value;
|
|
8157
8160
|
}
|
|
8158
8161
|
function getFontStyleObj(stylePayload) {
|
|
8159
8162
|
let baseStyleObj = {
|
|
@@ -8260,6 +8263,14 @@
|
|
|
8260
8263
|
if (format.hasOwnProperty("decimalPrecision")) obj.decimalPrecision = format.decimalPrecision;
|
|
8261
8264
|
if (format.hasOwnProperty("displayUnits")) obj.displayUnits = format.displayUnits;
|
|
8262
8265
|
}
|
|
8266
|
+
function getPercentageBy(dataValue, totalValue) {
|
|
8267
|
+
const num = Number(dataValue);
|
|
8268
|
+
const den = Number(totalValue);
|
|
8269
|
+
if (isNaN(num) || isNaN(den)) return num;
|
|
8270
|
+
if (den === 0) return num;
|
|
8271
|
+
const percentage = num / den;
|
|
8272
|
+
return percentage;
|
|
8273
|
+
}
|
|
8263
8274
|
const renderDataCell = (label, styles, className, childClassName, toolTip, dataBarBg) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { title: toolTip ?? label, className, style: styles, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: childClassName, style: { fontFamily: styles.fontFamily, textAlign: styles.justifyContent, background: dataBarBg ?? "none" }, children: label }) });
|
|
8264
8275
|
function StaticTable({
|
|
8265
8276
|
tableData,
|
|
@@ -8429,20 +8440,6 @@
|
|
|
8429
8440
|
}
|
|
8430
8441
|
);
|
|
8431
8442
|
}, [rawDataMatrix, isDataBarOn, KPI.KPIBaseFormat]);
|
|
8432
|
-
const percentageMatrix = React.useMemo(() => {
|
|
8433
|
-
console.log("Calculating percentage matrix");
|
|
8434
|
-
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy?.toLowerCase() !== "absolute")
|
|
8435
|
-
return computeMatrix(
|
|
8436
|
-
rawDataMatrix,
|
|
8437
|
-
DataField.percentageBy,
|
|
8438
|
-
(v, min, max) => {
|
|
8439
|
-
if (max === min) return 1;
|
|
8440
|
-
const pct = (v - min) / (max - min);
|
|
8441
|
-
return Math.min(1, Math.max(0, pct));
|
|
8442
|
-
}
|
|
8443
|
-
);
|
|
8444
|
-
console.log(DataField?.percentageBy);
|
|
8445
|
-
}, [rawDataMatrix, DataField, DataField?.percentageBy]);
|
|
8446
8443
|
const cornerCells = React.useMemo(() => {
|
|
8447
8444
|
const cells = [];
|
|
8448
8445
|
const baseStyle = {
|
|
@@ -8529,9 +8526,7 @@
|
|
|
8529
8526
|
DisplayUnits
|
|
8530
8527
|
);
|
|
8531
8528
|
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8532
|
-
|
|
8533
|
-
const lastVal = lastRow && lastRow[lastRow?.length - 1];
|
|
8534
|
-
label = formatValue(lastVal, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8529
|
+
label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8535
8530
|
}
|
|
8536
8531
|
cells.push({
|
|
8537
8532
|
label,
|
|
@@ -8605,7 +8600,13 @@
|
|
|
8605
8600
|
const parent = dimensionMarks[i][0] ?? "";
|
|
8606
8601
|
if (isFirstOccurrence(dimensionMarks, i, level)) {
|
|
8607
8602
|
const span = getSpan(dimensionMarks, i, level);
|
|
8608
|
-
|
|
8603
|
+
let colLabel = getCleanString(dimensionMarks[i][level]);
|
|
8604
|
+
if (tableData.hasOwnProperty("columnDateFormatObj") && tableData?.columnDateFormatObj) {
|
|
8605
|
+
const dFormat = tableData.columnDateFormatObj[level];
|
|
8606
|
+
if (dFormat) {
|
|
8607
|
+
colLabel = formatValue(colLabel, dFormat);
|
|
8608
|
+
}
|
|
8609
|
+
}
|
|
8609
8610
|
levelStyle.background = parentColorMap[parent];
|
|
8610
8611
|
const finalStyleForColumn = getFinalStyleObj(STYLE_FOR.COLUMN, levelStyle, colLabel, level);
|
|
8611
8612
|
headers.push({
|
|
@@ -8626,8 +8627,7 @@
|
|
|
8626
8627
|
let label = formatValue(item.columnTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
|
|
8627
8628
|
const innerBg = getBgColorForDataBar(0, idx);
|
|
8628
8629
|
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8629
|
-
|
|
8630
|
-
label = formatValue(percentageVal, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8630
|
+
label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8631
8631
|
}
|
|
8632
8632
|
headers.push({
|
|
8633
8633
|
...dataCellFont,
|
|
@@ -8693,7 +8693,13 @@
|
|
|
8693
8693
|
}
|
|
8694
8694
|
if (isFirstOccurrence(marks, i, level)) {
|
|
8695
8695
|
const span = getSpan(marks, i, level);
|
|
8696
|
-
|
|
8696
|
+
let rowLabel = marks[i][level];
|
|
8697
|
+
if (tableData.hasOwnProperty("rowDateFormatObj") && tableData?.rowDateFormatObj) {
|
|
8698
|
+
const dFormat = tableData.rowDateFormatObj[level];
|
|
8699
|
+
if (dFormat) {
|
|
8700
|
+
rowLabel = formatValue(rowLabel, dFormat);
|
|
8701
|
+
}
|
|
8702
|
+
}
|
|
8697
8703
|
const finalStyleForRow = getFinalStyleObj(STYLE_FOR.ROW, baseStyleObj, rowLabel, level, groupIndex);
|
|
8698
8704
|
headers.push({
|
|
8699
8705
|
...finalStyleForRow,
|
|
@@ -8718,10 +8724,7 @@
|
|
|
8718
8724
|
let label = formatValue(row.rowTotal, NumberFormat, DataFieldDecimalPrecision, DisplayUnits);
|
|
8719
8725
|
const innerBg = getBgColorForDataBar(i, dataBarMatrix[0]?.length - 1);
|
|
8720
8726
|
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8721
|
-
|
|
8722
|
-
const percentageVal = rowData[rowData?.length - 1];
|
|
8723
|
-
label = formatValue(percentageVal, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8724
|
-
console.log(rawDataMatrix);
|
|
8727
|
+
label = formatValue(1, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8725
8728
|
}
|
|
8726
8729
|
headers.push({
|
|
8727
8730
|
...dataCellFont,
|
|
@@ -8778,90 +8781,55 @@
|
|
|
8778
8781
|
if (rowIndex < fixedRowCount || columnIndex < fixedColCount) return null;
|
|
8779
8782
|
const rowIdxHeat = rowIndex - fixedRowCount;
|
|
8780
8783
|
const colIdxHeat = columnIndex - fixedColCount;
|
|
8781
|
-
|
|
8782
|
-
let innerDivBg = "none";
|
|
8783
|
-
if (isDataBarOn) {
|
|
8784
|
-
if (showDataBarValOnTooltip) {
|
|
8785
|
-
const val = dataBarMatrix[rowIdxHeat]?.[colIdxHeat];
|
|
8786
|
-
if (val !== void 0) pct = `${(val * 100).toFixed(2)}%`;
|
|
8787
|
-
}
|
|
8788
|
-
innerDivBg = getBgColorForDataBar(rowIdxHeat, colIdxHeat);
|
|
8789
|
-
}
|
|
8790
|
-
const parent = measuresBySlice[rowIdxHeat]?.sliceMark?.[0];
|
|
8791
|
-
const parentBg = parent ? parentBandColorMap[parent] : void 0;
|
|
8792
|
-
let outerDivBg = "none";
|
|
8793
|
-
if (ShowHeatMap) {
|
|
8794
|
-
outerDivBg = getBgColorForHetMap(rowIdxHeat, colIdxHeat);
|
|
8795
|
-
} else {
|
|
8796
|
-
outerDivBg = parentBg ?? dataColors.evenColor;
|
|
8797
|
-
}
|
|
8798
|
-
const baseStyle = {
|
|
8799
|
-
...style,
|
|
8800
|
-
...dataCellFont,
|
|
8801
|
-
background: outerDivBg
|
|
8802
|
-
};
|
|
8784
|
+
const isPercentageMode = DataField?.percentageBy?.toLowerCase?.() && DataField.percentageBy.toLowerCase() !== "absolute";
|
|
8803
8785
|
const isLastRow = rowIndex === rowCount - 1;
|
|
8804
8786
|
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 };
|
|
8805
8793
|
let rawValue;
|
|
8806
8794
|
let isBold = true;
|
|
8807
8795
|
const bgColorForTotals = getBgColorForCell(rowCount - fixedRowCount, dataColors);
|
|
8808
8796
|
if (isColTotalOn && isRowTotalOn && !headerAtStart && isLastRow && isLastCol) {
|
|
8809
8797
|
baseStyle.background = bgColorForTotals;
|
|
8810
|
-
rawValue = grandTotal;
|
|
8811
|
-
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8812
|
-
const lastRow = percentageMatrix && percentageMatrix[percentageMatrix.length - 1];
|
|
8813
|
-
rawValue = lastRow && lastRow[lastRow?.length - 1];
|
|
8814
|
-
}
|
|
8798
|
+
rawValue = isPercentageMode ? 1 : grandTotal;
|
|
8815
8799
|
} else if (isColTotalOn && !headerAtStart && isLastRow) {
|
|
8816
8800
|
baseStyle.background = bgColorForTotals;
|
|
8817
|
-
rawValue = columnTotalRow[colIdxHeat]?.columnTotal;
|
|
8818
|
-
if (DataField.hasOwnProperty("percentageBy") && DataField.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8819
|
-
rawValue = percentageMatrix && percentageMatrix[percentageMatrix.length - 1][colIdxHeat];
|
|
8820
|
-
}
|
|
8801
|
+
rawValue = isPercentageMode ? 1 : columnTotalRow[colIdxHeat]?.columnTotal;
|
|
8821
8802
|
} else if (isRowTotalOn && !headerAtStart && isLastCol) {
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8803
|
+
rawValue = 1;
|
|
8804
|
+
} else if (isPercentageMode) {
|
|
8805
|
+
if (DataField?.percentageBy === "Row-wise") {
|
|
8806
|
+
rawValue = getPercentageBy(measuresBySlice[rowIdxHeat]?.measures?.[colIdxHeat], measuresBySlice[rowIdxHeat].rowTotal);
|
|
8807
|
+
} else {
|
|
8808
|
+
rawValue = getPercentageBy(measuresBySlice[rowIdxHeat]?.measures?.[colIdxHeat], tableData.columnTotalRow[rowIdxHeat].columnTotal);
|
|
8809
|
+
}
|
|
8826
8810
|
isBold = false;
|
|
8827
8811
|
} else {
|
|
8828
8812
|
rawValue = measuresBySlice[rowIdxHeat]?.measures?.[colIdxHeat];
|
|
8829
8813
|
isBold = false;
|
|
8830
8814
|
}
|
|
8831
8815
|
if (rawValue === void 0) return null;
|
|
8832
|
-
const dimName = dimensionMarks[colIdxHeat]?.[fixedRowCount - 1]
|
|
8816
|
+
const dimName = dimensionMarks[colIdxHeat]?.[fixedRowCount - 1];
|
|
8833
8817
|
const formattingObj = getMeasureFormattingObj(dimName);
|
|
8834
8818
|
const conditionalFormatObj = getConditionalFormat(rawValue, CONDITIONAL_FORMAT_FOR.VALUE);
|
|
8835
8819
|
const numberFormat = conditionalFormatObj?.numberFormat ?? formattingObj.numberFormat;
|
|
8836
8820
|
const decimalPrecision = conditionalFormatObj?.decimalPrecision ?? formattingObj.decimalPrecision;
|
|
8837
8821
|
const displayUnits = conditionalFormatObj?.displayUnits ?? formattingObj.displayUnits;
|
|
8838
|
-
let formattedValue = formatValue(
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
decimalPrecision,
|
|
8842
|
-
displayUnits
|
|
8843
|
-
);
|
|
8844
|
-
if (DataField.hasOwnProperty("percentageBy") && DataField?.percentageBy && DataField.percentageBy?.toLowerCase() !== "absolute") {
|
|
8845
|
-
formattedValue = formatValue(rawValue, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8846
|
-
}
|
|
8847
|
-
let finalStyle = {
|
|
8822
|
+
let formattedValue = formatValue(rawValue, numberFormat, decimalPrecision, displayUnits);
|
|
8823
|
+
if (isPercentageMode) formattedValue = formatValue(rawValue, VALUE_FORMAT_OBJ.PERCENT_SHORT);
|
|
8824
|
+
const finalStyle = {
|
|
8848
8825
|
...baseStyle,
|
|
8849
|
-
fontWeight: isBold ? "bold" : "normal"
|
|
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 }
|
|
8850
8831
|
};
|
|
8851
|
-
|
|
8852
|
-
if (conditionalFormatObj.fontFamily) finalStyle.fontFamily = conditionalFormatObj.fontFamily;
|
|
8853
|
-
if (conditionalFormatObj.fontSize) finalStyle.fontSize = conditionalFormatObj.fontSize;
|
|
8854
|
-
if (conditionalFormatObj.backgroundColor) finalStyle.background = conditionalFormatObj.backgroundColor;
|
|
8855
|
-
if (conditionalFormatObj.color) finalStyle.color = conditionalFormatObj.color;
|
|
8856
|
-
}
|
|
8857
|
-
return renderDataCell(
|
|
8858
|
-
formattedValue,
|
|
8859
|
-
finalStyle,
|
|
8860
|
-
"data_div",
|
|
8861
|
-
"data_label_div",
|
|
8862
|
-
pct,
|
|
8863
|
-
innerDivBg
|
|
8864
|
-
);
|
|
8832
|
+
return renderDataCell(formattedValue, finalStyle, "data_div", "data_label_div", pct, innerDivBg);
|
|
8865
8833
|
};
|
|
8866
8834
|
function getBgColorForHetMap(rowIdx, colIdx) {
|
|
8867
8835
|
return heatColorMatrix[rowIdx][colIdx];
|