@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.
@@ -409,12 +409,12 @@ export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, color
409
409
  };
410
410
  };
411
411
  export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
412
- var _a, _b, _c, _d;
412
+ var _a, _b, _c, _d, _e, _f, _g, _h;
413
413
  var mapXToDataPoints = {};
414
414
  var yMaxValue = 0;
415
415
  var yMinValue = 0;
416
416
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
417
- var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
417
+ var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
418
418
  var colorScale = undefined;
419
419
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
420
420
  input.data.forEach(function (series, index1) {
@@ -485,8 +485,53 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
485
485
  });
486
486
  });
487
487
  });
488
+ var xCategories = (_b = (_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.x) !== null && _b !== void 0 ? _b : [];
489
+ ((_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.shapes) !== null && _d !== void 0 ? _d : [])
490
+ .filter(function (shape) { return shape.type === 'line'; })
491
+ .forEach(function (shape, shapeIdx) {
492
+ var _a, _b, _c;
493
+ var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
494
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
495
+ var resolveX = function (val) {
496
+ if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
497
+ return xCategories[val];
498
+ }
499
+ return val;
500
+ };
501
+ var x0Key = resolveX(shape.x0);
502
+ var x1Key = resolveX(shape.x1);
503
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
504
+ var resolveY = function (val) {
505
+ if (shape.yref === 'paper') {
506
+ if (val === 0) {
507
+ return yMinValue;
508
+ }
509
+ if (val === 1) {
510
+ return yMaxValue;
511
+ }
512
+ return yMinValue + val * (yMaxValue - yMinValue);
513
+ }
514
+ return val;
515
+ };
516
+ var y0Val = resolveY(shape.y0);
517
+ var y1Val = resolveY(shape.y1);
518
+ mapXToDataPoints[x0Key].lineData.push({
519
+ legend: "Reference_".concat(shapeIdx),
520
+ y: y0Val,
521
+ color: (_b = rgb(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
522
+ lineOptions: getLineOptions(shape.line),
523
+ useSecondaryYScale: false,
524
+ });
525
+ mapXToDataPoints[x1Key].lineData.push({
526
+ legend: "Reference_".concat(shapeIdx),
527
+ y: y1Val,
528
+ color: (_c = rgb(lineColor).formatHex8()) !== null && _c !== void 0 ? _c : lineColor,
529
+ lineOptions: getLineOptions(shape.line),
530
+ useSecondaryYScale: false,
531
+ });
532
+ });
488
533
  var vsbcData = Object.values(mapXToDataPoints);
489
- return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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));
534
+ return __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__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));
490
535
  };
491
536
  export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
492
537
  var _a, _b, _c;
@@ -654,7 +699,7 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot
654
699
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
655
700
  };
656
701
  var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
657
- var _a, _b, _c, _d;
702
+ var _a, _b, _c, _d, _e, _f;
658
703
  var isScatterMarkers = [
659
704
  'text',
660
705
  'markers',
@@ -669,7 +714,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
669
714
  var isScatterChart = chartType === 'scatter';
670
715
  var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
671
716
  var mode = 'tonexty';
672
- var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
717
+ var _g = getLegendProps(input.data, input.layout, isMultiPlot), legends = _g.legends, hideLegend = _g.hideLegend;
673
718
  var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
674
719
  var chartData = input.data
675
720
  .map(function (series, index) {
@@ -737,6 +782,22 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
737
782
  });
738
783
  })
739
784
  .flat();
785
+ var lineShape = ((_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.shapes) !== null && _c !== void 0 ? _c : [])
786
+ .filter(function (shape) { return shape.type === 'line'; })
787
+ .map(function (shape, shapeIdx) {
788
+ var _a, _b;
789
+ var lineColor = (_a = shape.line) === null || _a === void 0 ? void 0 : _a.color;
790
+ return {
791
+ legend: "Reference_".concat(shapeIdx),
792
+ data: [
793
+ { x: shape.x0, y: shape.y0 },
794
+ { x: shape.x1, y: shape.y1 },
795
+ ],
796
+ color: (_b = rgb(lineColor).formatHex8()) !== null && _b !== void 0 ? _b : lineColor,
797
+ lineOptions: getLineOptions(shape.line),
798
+ useSecondaryYScale: false,
799
+ };
800
+ });
740
801
  var yMinMax = getYMinMaxValues(input.data[0], input.layout);
741
802
  if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
742
803
  var yMinMaxValues = findNumericMinMaxOfY(chartData);
@@ -745,12 +806,12 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
745
806
  }
746
807
  var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
747
808
  var chartProps = {
748
- lineChartData: chartData,
809
+ lineChartData: __spreadArray(__spreadArray([], chartData, true), lineShape, true),
749
810
  };
750
811
  var scatterChartProps = {
751
812
  scatterChartData: chartData,
752
813
  };
753
- var commonProps = __assign(__assign(__assign(__assign(__assign(__assign(__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));
814
+ var commonProps = __assign(__assign(__assign(__assign(__assign(__assign(__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));
754
815
  if (isAreaChart) {
755
816
  return __assign({ data: chartProps, mode: mode }, commonProps);
756
817
  }