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