@fluentui/react-charting 5.24.33 → 5.24.34

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,7 +729,7 @@ 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);
689
734
  var chartData = input.data
690
735
  .map(function (series, index) {
@@ -752,6 +797,22 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
752
797
  });
753
798
  })
754
799
  .flat();
800
+ var lineShape = ((_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.shapes) !== null && _c !== void 0 ? _c : [])
801
+ .filter(function (shape) { return shape.type === 'line'; })
802
+ .map(function (shape, shapeIdx) {
803
+ var _a, _b;
804
+ var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
805
+ return {
806
+ legend: "Reference_".concat(shapeIdx),
807
+ data: [
808
+ { x: shape.x0, y: shape.y0 },
809
+ { x: shape.x1, y: shape.y1 },
810
+ ],
811
+ color: (_b = (0, d3_color_1.rgb)(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
812
+ lineOptions: getLineOptions(shape.line),
813
+ useSecondaryYScale: false,
814
+ };
815
+ });
755
816
  var yMinMax = getYMinMaxValues(input.data[0], input.layout);
756
817
  if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
757
818
  var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
@@ -760,12 +821,12 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
760
821
  }
761
822
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
762
823
  var chartProps = {
763
- lineChartData: chartData,
824
+ lineChartData: tslib_1.__spreadArray(tslib_1.__spreadArray([], chartData, true), lineShape, true),
764
825
  };
765
826
  var scatterChartProps = {
766
827
  scatterChartData: chartData,
767
828
  };
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));
829
+ 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 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
769
830
  if (isAreaChart) {
770
831
  return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
771
832
  }