@fluentui/react-charting 5.24.33 → 5.24.35

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.
@@ -418,12 +418,12 @@ var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, co
418
418
  };
419
419
  exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
420
420
  var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
421
- var _a, _b, _c, _d;
421
+ var _a, _b, _c, _d, _e, _f, _g, _h;
422
422
  var mapXToDataPoints = {};
423
423
  var yMaxValue = 0;
424
424
  var yMinValue = 0;
425
425
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
426
- var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
426
+ var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
427
427
  var colorScale = undefined;
428
428
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
429
429
  input.data.forEach(function (series, index1) {
@@ -494,8 +494,53 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
494
494
  });
495
495
  });
496
496
  });
497
+ var xCategories = (_b = (_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : [];
498
+ ((_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.shapes) !== null && _d !== void 0 ? _d : [])
499
+ .filter(function (shape) { return shape.type === 'line'; })
500
+ .forEach(function (shape, shapeIdx) {
501
+ var _a, _b, _c;
502
+ var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
503
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
504
+ var resolveX = function (val) {
505
+ if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
506
+ return xCategories[val];
507
+ }
508
+ return val;
509
+ };
510
+ var x0Key = resolveX(shape.x0);
511
+ var x1Key = resolveX(shape.x1);
512
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
513
+ var resolveY = function (val) {
514
+ if (shape.yref === 'paper') {
515
+ if (val === 0) {
516
+ return yMinValue;
517
+ }
518
+ if (val === 1) {
519
+ return yMaxValue;
520
+ }
521
+ return yMinValue + val * (yMaxValue - yMinValue);
522
+ }
523
+ return val;
524
+ };
525
+ var y0Val = resolveY(shape.y0);
526
+ var y1Val = resolveY(shape.y1);
527
+ mapXToDataPoints[x0Key].lineData.push({
528
+ legend: "Reference_".concat(shapeIdx),
529
+ y: y0Val,
530
+ color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
531
+ lineOptions: getLineOptions(shape.line),
532
+ useSecondaryYScale: false,
533
+ });
534
+ mapXToDataPoints[x1Key].lineData.push({
535
+ legend: "Reference_".concat(shapeIdx),
536
+ y: y1Val,
537
+ color: (_c = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _c !== void 0 ? _c : lineColor,
538
+ lineOptions: getLineOptions(shape.line),
539
+ useSecondaryYScale: false,
540
+ });
541
+ });
497
542
  var vsbcData = Object.values(mapXToDataPoints);
498
- return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
543
+ return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_h = vsbcData[0]) === null || _h === void 0 ? void 0 : _h.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
499
544
  };
500
545
  exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
501
546
  var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
@@ -669,7 +714,7 @@ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, color
669
714
  };
670
715
  exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
671
716
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
672
- var _a, _b, _c, _d;
717
+ var _a, _b, _c, _d, _e, _f;
673
718
  var isScatterMarkers = [
674
719
  'text',
675
720
  'markers',
@@ -684,8 +729,9 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
684
729
  var isScatterChart = chartType === 'scatter';
685
730
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
686
731
  var mode = 'tonexty';
687
- var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
732
+ var _g = getLegendProps(input.data, input.layout, isMultiPlot), legends = _g.legends, hideLegend = _g.hideLegend;
688
733
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
734
+ var shouldWrapLabels = false;
689
735
  var chartData = input.data
690
736
  .map(function (series, index) {
691
737
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -701,6 +747,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
701
747
  var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
702
748
  var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
703
749
  var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
750
+ shouldWrapLabels = shouldWrapLabels || (isXString && !isXDate);
704
751
  var legend = legends[index];
705
752
  // resolve color for each legend's lines from the extracted colors
706
753
  var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, (_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, isDarkTheme);
@@ -752,6 +799,22 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
752
799
  });
753
800
  })
754
801
  .flat();
802
+ var lineShape = ((_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.shapes) !== null && _c !== void 0 ? _c : [])
803
+ .filter(function (shape) { return shape.type === 'line'; })
804
+ .map(function (shape, shapeIdx) {
805
+ var _a, _b;
806
+ var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
807
+ return {
808
+ legend: "Reference_".concat(shapeIdx),
809
+ data: [
810
+ { x: shape.x0, y: shape.y0 },
811
+ { x: shape.x1, y: shape.y1 },
812
+ ],
813
+ color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
814
+ lineOptions: getLineOptions(shape.line),
815
+ useSecondaryYScale: false,
816
+ };
817
+ });
755
818
  var yMinMax = getYMinMaxValues(input.data[0], input.layout);
756
819
  if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
757
820
  var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
@@ -760,12 +823,12 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
760
823
  }
761
824
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
762
825
  var chartProps = {
763
- lineChartData: chartData,
826
+ lineChartData: tslib_1.__spreadArray(tslib_1.__spreadArray([], chartData, true), lineShape, true),
764
827
  };
765
828
  var scatterChartProps = {
766
829
  scatterChartData: chartData,
767
830
  };
768
- var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
831
+ var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.width, height: (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000, shouldWrapLabels: shouldWrapLabels }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
769
832
  if (isAreaChart) {
770
833
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
771
834
  }