@fluentui/react-charts 9.2.0 → 9.2.2

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/dist/index.d.ts +84 -5
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  6. package/lib/components/ChartTable/ChartTable.js +57 -0
  7. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  8. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  9. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  10. package/lib/components/ChartTable/index.js +3 -0
  11. package/lib/components/ChartTable/index.js.map +1 -0
  12. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  13. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  14. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  15. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  16. package/lib/components/CommonComponents/CartesianChart.js +110 -81
  17. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  18. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  19. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  20. package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
  21. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
  23. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  27. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  28. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  29. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  30. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
  32. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  33. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  34. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  35. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  36. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  37. package/lib/components/Legends/Legends.js.map +1 -1
  38. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  39. package/lib/components/LineChart/LineChart.js.map +1 -1
  40. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  41. package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
  42. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  43. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
  44. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  45. package/lib/index.js +1 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/types/DataPoint.js.map +1 -1
  48. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  49. package/lib/utilities/utilities.js +26 -37
  50. package/lib/utilities/utilities.js.map +1 -1
  51. package/lib/utilities/vbc-utils.js +24 -0
  52. package/lib/utilities/vbc-utils.js.map +1 -1
  53. package/lib-commonjs/ChartTable.js +6 -0
  54. package/lib-commonjs/ChartTable.js.map +1 -0
  55. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  56. package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
  57. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  58. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  59. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  60. package/lib-commonjs/components/ChartTable/index.js +8 -0
  61. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  62. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  63. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  64. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  65. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  66. package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
  67. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  68. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  69. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  70. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
  71. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  72. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
  73. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  74. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  75. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  77. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  78. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  79. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  80. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  81. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
  82. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  83. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  84. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  85. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  86. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  87. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  88. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  89. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  90. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  91. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
  92. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  93. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
  94. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  95. package/lib-commonjs/index.js +1 -0
  96. package/lib-commonjs/index.js.map +1 -1
  97. package/lib-commonjs/types/DataPoint.js.map +1 -1
  98. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  99. package/lib-commonjs/utilities/utilities.js +29 -37
  100. package/lib-commonjs/utilities/utilities.js.map +1 -1
  101. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  102. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  103. package/package.json +9 -9
@@ -15,6 +15,9 @@ _export(exports, {
15
15
  CustomPoints: function() {
16
16
  return CustomPoints;
17
17
  },
18
+ DEFAULT_WRAP_WIDTH: function() {
19
+ return DEFAULT_WRAP_WIDTH;
20
+ },
18
21
  HighContrastSelector: function() {
19
22
  return HighContrastSelector;
20
23
  },
@@ -255,7 +258,7 @@ function defaultYAxisTickFormatter(value) {
255
258
  return yAxisTickFormatterInternal(value);
256
259
  }
257
260
  function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
258
- const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap } = xAxisParams;
261
+ const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
259
262
  const xAxisScale = (0, _d3scale.scaleLinear)().domain([
260
263
  domainNRangeValues.dStartValue,
261
264
  domainNRangeValues.dEndValue
@@ -273,7 +276,7 @@ function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
273
276
  return (0, _chartutilities.formatToLocaleString)(xAxisValue, culture);
274
277
  };
275
278
  if (hideTickOverlap && typeof xAxisCount === 'undefined') {
276
- const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 20;
279
+ const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 20;
277
280
  const [start, end] = xAxisScale.range();
278
281
  tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
279
282
  }
@@ -482,7 +485,7 @@ function getDateFormatLevel(date, useUTC) {
482
485
  return (_matchedFormat_formatLevel = matchedFormat === null || matchedFormat === void 0 ? void 0 : matchedFormat.formatLevel) !== null && _matchedFormat_formatLevel !== void 0 ? _matchedFormat_formatLevel : 7;
483
486
  }
484
487
  function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
485
- const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount } = xAxisParams;
488
+ const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth } = xAxisParams;
486
489
  const isUtcSet = useUTC === true || useUTC === 'utc';
487
490
  const xAxisScale = isUtcSet ? (0, _d3scale.scaleUtc)() : (0, _d3scale.scaleTime)();
488
491
  xAxisScale.domain([
@@ -523,7 +526,7 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
523
526
  }
524
527
  return (0, _chartutilities.formatDateToLocaleString)(domainValue, culture, useUTC ? true : false, false, formatOptions);
525
528
  };
526
- const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 40;
529
+ const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 40;
527
530
  const [start, end] = xAxisScale.range();
528
531
  const maxPossibleTickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
529
532
  tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
@@ -545,7 +548,7 @@ function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLo
545
548
  };
546
549
  }
547
550
  function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
548
- const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap } = xAxisParams;
551
+ const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
549
552
  const xAxisScale = (0, _d3scale.scaleBand)().domain(dataset).range([
550
553
  domainNRangeValues.rStartValue,
551
554
  domainNRangeValues.rEndValue
@@ -557,9 +560,9 @@ function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
557
560
  };
558
561
  if (hideTickOverlap) {
559
562
  let nonOverlappingTickValues = [];
560
- const tickSizes = tickValues.map((value, index)=>calculateLongestLabelWidth([
561
- tickFormat(value, index)
562
- ], '.fui-cart__xAxis text'));
563
+ const tickSizes = tickValues.map((value)=>calcMaxLabelWidth([
564
+ value
565
+ ]));
563
566
  // for LTR
564
567
  let start = 0;
565
568
  let end = containerWidth;
@@ -800,22 +803,21 @@ function silceOrAppendToArray(array, value) {
800
803
  return array.slice(0, pos).concat(array.slice(pos + 1));
801
804
  }
802
805
  }
806
+ const DEFAULT_WRAP_WIDTH = 10;
803
807
  function createWrapOfXLabels(wrapLabelProps) {
804
- const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip } = wrapLabelProps;
808
+ const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip, width = DEFAULT_WRAP_WIDTH } = wrapLabelProps;
805
809
  if (node === null) {
806
810
  return;
807
811
  }
808
812
  const axisNode = (0, _d3selection.select)(node).call(xAxis);
809
813
  let removeVal = 0;
810
- const width = 10;
811
- const arr = [];
814
+ let maxLines = 1;
812
815
  axisNode.selectAll('.tick text').each(function() {
813
816
  const text = (0, _d3selection.select)(this);
814
817
  const totalWord = text.text();
815
818
  const truncatedWord = `${text.text().slice(0, noOfCharsToTruncate)}...`;
816
819
  const totalWordLength = text.text().length;
817
820
  const words = text.text().split(/\s+/).reverse();
818
- arr.push(words.length);
819
821
  let word = '';
820
822
  let line = [];
821
823
  let lineNumber = 0;
@@ -824,9 +826,9 @@ function createWrapOfXLabels(wrapLabelProps) {
824
826
  const dy = parseFloat(text.attr('dy'));
825
827
  let tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('id', 'BaseSpan').attr('dy', dy + 'em').attr('data-', totalWord);
826
828
  if (showXAxisLablesTooltip && totalWordLength > noOfCharsToTruncate) {
827
- tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(truncatedWord);
829
+ tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(truncatedWord);
828
830
  } else if (showXAxisLablesTooltip && totalWordLength <= noOfCharsToTruncate) {
829
- tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(totalWord);
831
+ tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(totalWord);
830
832
  } else {
831
833
  while(word = words.pop()){
832
834
  line.push(word);
@@ -840,30 +842,20 @@ function createWrapOfXLabels(wrapLabelProps) {
840
842
  tspan = text.append('tspan').attr('id', 'WordBreakId').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word);
841
843
  }
842
844
  }
843
- const maxDigit = Math.max(...arr);
844
- let maxHeight = 12; // intial value to render corretly first time
845
- axisNode.selectAll('text').each(()=>{
846
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
847
- const outerHTMLElement = document.getElementById('WordBreakId');
848
- const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
849
- const boxHeight = BoxCordinates && BoxCordinates.height;
850
- if (boxHeight > maxHeight) {
851
- maxHeight = boxHeight;
852
- }
853
- });
854
- // If we take directly maxDigit * maxheight, then it will show more height between x axis tick values and bottom.
855
- // To avoid this, reducing maxDigit value by removing some digit based on legth of word.
856
- let removeDigit = 4;
857
- if (maxDigit <= 2) {
858
- removeDigit = 1;
859
- } else if (maxDigit > 2 && maxDigit <= 6) {
860
- removeDigit = 2;
861
- } else if (maxDigit > 6 && maxDigit <= 9) {
862
- removeDigit = 3;
863
- }
864
- removeVal = (maxDigit - removeDigit) * maxHeight;
865
845
  }
846
+ maxLines = Math.max(maxLines, lineNumber + 1);
866
847
  });
848
+ if (!showXAxisLablesTooltip) {
849
+ let maxHeight = 12; // intial value to render corretly first time
850
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
851
+ const outerHTMLElement = document.getElementById('WordBreakId');
852
+ const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
853
+ const boxHeight = BoxCordinates && BoxCordinates.height;
854
+ if (boxHeight > maxHeight) {
855
+ maxHeight = boxHeight;
856
+ }
857
+ removeVal = (maxLines - 1) * maxHeight;
858
+ }
867
859
  return removeVal > 0 ? removeVal : 0;
868
860
  }
869
861
  function createYAxisLabels(node, yAxis, noOfCharsToTruncate, truncateLabel, isRtl) {
@@ -877,7 +869,7 @@ function createYAxisLabels(node, yAxis, noOfCharsToTruncate, truncateLabel, isRt
877
869
  const totalWord = text.text();
878
870
  const truncatedWord = isRtl ? `...${text.text().slice(0, noOfCharsToTruncate)}` : `${text.text().slice(0, noOfCharsToTruncate)}...`;
879
871
  const totalWordLength = text.text().length;
880
- const padding = truncateLabel ? 1.5 : 1; // ems
872
+ const padding = 0; // ems
881
873
  const y = text.attr('y');
882
874
  const x = text.attr('x');
883
875
  const dy = parseFloat(text.attr('dy'));