@fluentui/react-charting 5.24.27 → 5.24.28

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.
@@ -1077,6 +1077,17 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1077
1077
  }
1078
1078
  return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
1079
1079
  };
1080
+ function resolveCellStyle(raw, rowIndex, colIndex) {
1081
+ var _a, _b;
1082
+ if (Array.isArray(raw)) {
1083
+ var rowEntry = (_a = raw[colIndex]) !== null && _a !== void 0 ? _a : raw[0];
1084
+ if (Array.isArray(rowEntry)) {
1085
+ return (_b = rowEntry[rowIndex]) !== null && _b !== void 0 ? _b : rowEntry[0];
1086
+ }
1087
+ return rowEntry;
1088
+ }
1089
+ return raw;
1090
+ }
1080
1091
  var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
1081
1092
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1082
1093
  var tableData = input.data[0];
@@ -1090,41 +1101,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1090
1101
  })
1091
1102
  : values.map(function (cell) { return cleanText(cell); });
1092
1103
  return cleanedValues.map(function (value, colIndex) {
1093
- var _a, _b, _c, _d, _e, _f, _g, _h;
1094
- var fontColorRaw = (_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color;
1095
- var fontColor;
1096
- if (Array.isArray(fontColorRaw)) {
1097
- var colorEntry = (_b = fontColorRaw[colIndex]) !== null && _b !== void 0 ? _b : fontColorRaw[0];
1098
- if (Array.isArray(colorEntry)) {
1099
- fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
1100
- }
1101
- else if (typeof colorEntry === 'string') {
1102
- fontColor = colorEntry;
1103
- }
1104
- }
1105
- else if (typeof fontColorRaw === 'string') {
1106
- fontColor = fontColorRaw;
1107
- }
1108
- var fontSizeRaw = (_c = header === null || header === void 0 ? void 0 : header.font) === null || _c === void 0 ? void 0 : _c.size;
1109
- var fontSize;
1110
- if (Array.isArray(fontSizeRaw)) {
1111
- var fontSizeEntry = (_d = fontSizeRaw[colIndex]) !== null && _d !== void 0 ? _d : fontSizeRaw[0];
1112
- fontSize = Array.isArray(fontSizeRaw[0])
1113
- ? (_e = fontSizeRaw[0][colIndex]) !== null && _e !== void 0 ? _e : fontSizeRaw[0][0]
1114
- : typeof fontSizeEntry === 'number'
1115
- ? fontSizeEntry
1116
- : undefined;
1117
- }
1118
- else if (typeof fontSizeRaw === 'number') {
1119
- fontSize = fontSizeRaw;
1120
- }
1121
- var updatedColIndex = colIndex >= 1 ? 1 : 0;
1122
- var fillColorRaw = (_f = header === null || header === void 0 ? void 0 : header.fill) === null || _f === void 0 ? void 0 : _f.color;
1123
- var backgroundColor = Array.isArray(fillColorRaw)
1124
- ? (_g = fillColorRaw[updatedColIndex]) !== null && _g !== void 0 ? _g : fillColorRaw[0]
1125
- : fillColorRaw;
1126
- var textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
1127
- var textAlign = Array.isArray(textAlignRaw) ? (_h = textAlignRaw[colIndex]) !== null && _h !== void 0 ? _h : textAlignRaw[0] : textAlignRaw;
1104
+ var _a, _b, _c;
1105
+ //headers are at first row only
1106
+ var rowIndex = 0;
1107
+ var fontColor = resolveCellStyle((_a = header === null || header === void 0 ? void 0 : header.font) === null || _a === void 0 ? void 0 : _a.color, rowIndex, colIndex);
1108
+ var fontSize = resolveCellStyle((_b = header === null || header === void 0 ? void 0 : header.font) === null || _b === void 0 ? void 0 : _b.size, rowIndex, colIndex);
1109
+ var backgroundColor = resolveCellStyle((_c = header === null || header === void 0 ? void 0 : header.fill) === null || _c === void 0 ? void 0 : _c.color, rowIndex, colIndex);
1110
+ var textAlign = resolveCellStyle(header === null || header === void 0 ? void 0 : header.align, rowIndex, colIndex);
1128
1111
  var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (typeof fontColor === 'string' ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (typeof backgroundColor === 'string' ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
1129
1112
  return { value: value, style: style };
1130
1113
  });
@@ -1135,45 +1118,16 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
1135
1118
  : (_g = (_f = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.table) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.cells;
1136
1119
  var rows = columns[0].map(function (_, rowIndex) {
1137
1120
  return columns.map(function (col, colIndex) {
1138
- var _a, _b, _c, _d, _e, _f, _g;
1121
+ var _a, _b, _c;
1139
1122
  var cellValue = col[rowIndex];
1140
1123
  var cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
1141
1124
  var formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number'
1142
1125
  ? formatValue(cleanValue, colIndex, cells)
1143
1126
  : cleanValue;
1144
- var rawFontColor = (_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color;
1145
- var fontColor;
1146
- if (Array.isArray(rawFontColor)) {
1147
- var entry = (_b = rawFontColor[colIndex]) !== null && _b !== void 0 ? _b : rawFontColor[0];
1148
- var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1149
- fontColor = typeof colorValue === 'string' ? colorValue : undefined;
1150
- }
1151
- else if (typeof rawFontColor === 'string') {
1152
- fontColor = rawFontColor;
1153
- }
1154
- var rawFontSize = (_c = cells === null || cells === void 0 ? void 0 : cells.font) === null || _c === void 0 ? void 0 : _c.size;
1155
- var fontSize;
1156
- if (Array.isArray(rawFontSize)) {
1157
- var entry = (_d = rawFontSize[colIndex]) !== null && _d !== void 0 ? _d : rawFontSize[0];
1158
- var fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1159
- fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
1160
- }
1161
- else if (typeof rawFontSize === 'number') {
1162
- fontSize = rawFontSize;
1163
- }
1164
- var updatedColIndex = colIndex >= 1 ? 1 : 0;
1165
- var rawBackgroundColor = (_e = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _e === void 0 ? void 0 : _e.color;
1166
- var backgroundColor;
1167
- if (Array.isArray(rawBackgroundColor)) {
1168
- var entry = (_f = rawBackgroundColor[updatedColIndex]) !== null && _f !== void 0 ? _f : rawBackgroundColor[0];
1169
- var colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
1170
- backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
1171
- }
1172
- else if (typeof rawBackgroundColor === 'string') {
1173
- backgroundColor = rawBackgroundColor;
1174
- }
1175
- var rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? (_g = cells.align[colIndex]) !== null && _g !== void 0 ? _g : cells.align[0] : cells === null || cells === void 0 ? void 0 : cells.align;
1176
- var textAlign = rawTextAlign;
1127
+ var fontColor = resolveCellStyle((_a = cells === null || cells === void 0 ? void 0 : cells.font) === null || _a === void 0 ? void 0 : _a.color, rowIndex, colIndex);
1128
+ var fontSize = resolveCellStyle((_b = cells === null || cells === void 0 ? void 0 : cells.font) === null || _b === void 0 ? void 0 : _b.size, rowIndex, colIndex);
1129
+ var backgroundColor = resolveCellStyle((_c = cells === null || cells === void 0 ? void 0 : cells.fill) === null || _c === void 0 ? void 0 : _c.color, rowIndex, colIndex);
1130
+ var textAlign = resolveCellStyle(cells === null || cells === void 0 ? void 0 : cells.align, rowIndex, colIndex);
1177
1131
  var style = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (fontColor ? { color: fontColor } : {})), (typeof fontSize === 'number' ? { fontSize: fontSize } : {})), (backgroundColor ? { backgroundColor: backgroundColor } : {})), (textAlign ? { textAlign: textAlign } : {}));
1178
1132
  return {
1179
1133
  value: formattedValue,