@fluentui/react-charting 5.24.25 → 5.24.26

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.
@@ -330,25 +330,55 @@ export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, color
330
330
  // otherwise, default to colorway from template
331
331
  var colors = extractColor((_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.piecolorway) !== null && _b !== void 0 ? _b : (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.piecolorway) !== null && _g !== void 0 ? _g : (_h = firstData === null || firstData === void 0 ? void 0 : firstData.marker) === null || _h === void 0 ? void 0 : _h.colors, colorMap, isDarkTheme);
332
332
  var mapLegendToDataPoint = {};
333
- (_j = firstData.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, index) {
334
- var value = getNumberAtIndexOrDefault(firstData.values, index);
335
- if (isInvalidValue(value) || value < 0) {
336
- return;
337
- }
338
- var legend = "".concat(label);
339
- // resolve color for each legend from the extracted colors
340
- var color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
341
- if (!mapLegendToDataPoint[legend]) {
342
- mapLegendToDataPoint[legend] = {
343
- legend: legend,
344
- data: value,
345
- color: color,
346
- };
347
- }
348
- else {
349
- mapLegendToDataPoint[legend].data += value;
333
+ if (colors) {
334
+ (_j = firstData.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, index) {
335
+ var value = getNumberAtIndexOrDefault(firstData.values, index);
336
+ if (isInvalidValue(value) || value < 0) {
337
+ return;
338
+ }
339
+ var legend = "".concat(label);
340
+ // resolve color for each legend from the extracted colors
341
+ var color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
342
+ if (!mapLegendToDataPoint[legend]) {
343
+ mapLegendToDataPoint[legend] = {
344
+ legend: legend,
345
+ data: value,
346
+ color: color,
347
+ };
348
+ }
349
+ else {
350
+ mapLegendToDataPoint[legend].data += value;
351
+ }
352
+ });
353
+ }
354
+ else {
355
+ // Sort labels by value descending before mapping
356
+ if (firstData.labels && firstData.values) {
357
+ var labelValuePairs = firstData.labels.map(function (label, index) { return ({
358
+ label: label,
359
+ value: getNumberAtIndexOrDefault(firstData.values, index),
360
+ index: index,
361
+ }); });
362
+ // Filter out invalid values
363
+ var validPairs = labelValuePairs.filter(function (pair) { return !isInvalidValue(pair.value); });
364
+ // Sort descending by value
365
+ validPairs.sort(function (a, b) { return b.value - a.value; });
366
+ validPairs.forEach(function (pair, sortedIdx) {
367
+ var legend = "".concat(pair.label);
368
+ var color = resolveColor(colors, sortedIdx, legend, colorMap, isDarkTheme);
369
+ if (!mapLegendToDataPoint[legend]) {
370
+ mapLegendToDataPoint[legend] = {
371
+ legend: legend,
372
+ data: pair.value,
373
+ color: color,
374
+ };
375
+ }
376
+ else {
377
+ mapLegendToDataPoint[legend].data += pair.value;
378
+ }
379
+ });
350
380
  }
351
- });
381
+ }
352
382
  var width = (_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.width) !== null && _l !== void 0 ? _l : 440;
353
383
  var height = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.height) !== null && _o !== void 0 ? _o : 220;
354
384
  var hideLabels = firstData.textinfo