@fluentui/react-charts 9.2.1 → 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 (101) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/dist/index.d.ts +79 -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 +164 -77
  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/utilities/FocusableTooltipText.js.map +1 -1
  48. package/lib/utilities/utilities.js +26 -37
  49. package/lib/utilities/utilities.js.map +1 -1
  50. package/lib/utilities/vbc-utils.js +24 -0
  51. package/lib/utilities/vbc-utils.js.map +1 -1
  52. package/lib-commonjs/ChartTable.js +6 -0
  53. package/lib-commonjs/ChartTable.js.map +1 -0
  54. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  55. package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
  56. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  57. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  58. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  59. package/lib-commonjs/components/ChartTable/index.js +8 -0
  60. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  61. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  62. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  63. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  64. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  65. package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
  66. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  67. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  68. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  69. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
  70. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  71. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
  72. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  73. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
  74. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  75. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  77. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  78. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  79. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  80. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
  81. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  82. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  83. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  84. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  85. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  86. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  87. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  88. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  89. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  90. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
  91. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  92. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
  93. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  94. package/lib-commonjs/index.js +1 -0
  95. package/lib-commonjs/index.js.map +1 -1
  96. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  97. package/lib-commonjs/utilities/utilities.js +29 -37
  98. package/lib-commonjs/utilities/utilities.js.map +1 -1
  99. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  100. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  101. package/package.json +9 -9
@@ -63,7 +63,7 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
63
63
  * @export
64
64
  * @param {IXAxisParams} xAxisParams
65
65
  */ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
66
- const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap } = xAxisParams;
66
+ const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
67
67
  const xAxisScale = d3ScaleLinear().domain([
68
68
  domainNRangeValues.dStartValue,
69
69
  domainNRangeValues.dEndValue
@@ -81,7 +81,7 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
81
81
  return formatToLocaleString(xAxisValue, culture);
82
82
  };
83
83
  if (hideTickOverlap && typeof xAxisCount === 'undefined') {
84
- const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 20;
84
+ const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 20;
85
85
  const [start, end] = xAxisScale.range();
86
86
  tickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
87
87
  }
@@ -295,7 +295,7 @@ export function getDateFormatLevel(date, useUTC) {
295
295
  * @param {IXAxisParams} xAxisParams
296
296
  * @param {ITickParams} tickParams
297
297
  */ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC, chartType) {
298
- const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount } = xAxisParams;
298
+ const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, calcMaxLabelWidth } = xAxisParams;
299
299
  const isUtcSet = useUTC === true || useUTC === 'utc';
300
300
  const xAxisScale = isUtcSet ? d3ScaleUtc() : d3ScaleTime();
301
301
  xAxisScale.domain([
@@ -336,7 +336,7 @@ export function getDateFormatLevel(date, useUTC) {
336
336
  }
337
337
  return formatDateToLocaleString(domainValue, culture, useUTC ? true : false, false, formatOptions);
338
338
  };
339
- const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 40;
339
+ const longestLabelWidth = calcMaxLabelWidth(xAxisScale.ticks().map(tickFormat)) + 40;
340
340
  const [start, end] = xAxisScale.range();
341
341
  const maxPossibleTickCount = Math.min(Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth)), 10);
342
342
  tickCount = Math.min(maxPossibleTickCount, xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : tickCount);
@@ -366,7 +366,7 @@ export function getDateFormatLevel(date, useUTC) {
366
366
  * @param {string[]} dataset
367
367
  * @returns
368
368
  */ export function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
369
- const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap } = xAxisParams;
369
+ const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap, calcMaxLabelWidth } = xAxisParams;
370
370
  const xAxisScale = d3ScaleBand().domain(dataset).range([
371
371
  domainNRangeValues.rStartValue,
372
372
  domainNRangeValues.rEndValue
@@ -378,9 +378,9 @@ export function getDateFormatLevel(date, useUTC) {
378
378
  };
379
379
  if (hideTickOverlap) {
380
380
  let nonOverlappingTickValues = [];
381
- const tickSizes = tickValues.map((value, index)=>calculateLongestLabelWidth([
382
- tickFormat(value, index)
383
- ], '.fui-cart__xAxis text'));
381
+ const tickSizes = tickValues.map((value)=>calcMaxLabelWidth([
382
+ value
383
+ ]));
384
384
  // for LTR
385
385
  let start = 0;
386
386
  let end = containerWidth;
@@ -654,6 +654,7 @@ export function getUnique(arr, comp) {
654
654
  return array.slice(0, pos).concat(array.slice(pos + 1));
655
655
  }
656
656
  }
657
+ export const DEFAULT_WRAP_WIDTH = 10;
657
658
  /**
658
659
  * This method used for wrapping of x axis labels (tick values).
659
660
  * It breaks down given text value by space separated and calculates the total height needed to display all the words.
@@ -663,21 +664,19 @@ export function getUnique(arr, comp) {
663
664
  * @param {IWrapLabelProps} wrapLabelProps
664
665
  * @returns
665
666
  */ export function createWrapOfXLabels(wrapLabelProps) {
666
- const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip } = wrapLabelProps;
667
+ const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip, width = DEFAULT_WRAP_WIDTH } = wrapLabelProps;
667
668
  if (node === null) {
668
669
  return;
669
670
  }
670
671
  const axisNode = d3Select(node).call(xAxis);
671
672
  let removeVal = 0;
672
- const width = 10;
673
- const arr = [];
673
+ let maxLines = 1;
674
674
  axisNode.selectAll('.tick text').each(function() {
675
675
  const text = d3Select(this);
676
676
  const totalWord = text.text();
677
677
  const truncatedWord = `${text.text().slice(0, noOfCharsToTruncate)}...`;
678
678
  const totalWordLength = text.text().length;
679
679
  const words = text.text().split(/\s+/).reverse();
680
- arr.push(words.length);
681
680
  let word = '';
682
681
  let line = [];
683
682
  let lineNumber = 0;
@@ -686,9 +685,9 @@ export function getUnique(arr, comp) {
686
685
  const dy = parseFloat(text.attr('dy'));
687
686
  let tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('id', 'BaseSpan').attr('dy', dy + 'em').attr('data-', totalWord);
688
687
  if (showXAxisLablesTooltip && totalWordLength > noOfCharsToTruncate) {
689
- tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(truncatedWord);
688
+ tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(truncatedWord);
690
689
  } else if (showXAxisLablesTooltip && totalWordLength <= noOfCharsToTruncate) {
691
- tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(totalWord);
690
+ tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', dy + 'em').text(totalWord);
692
691
  } else {
693
692
  while(word = words.pop()){
694
693
  line.push(word);
@@ -702,30 +701,20 @@ export function getUnique(arr, comp) {
702
701
  tspan = text.append('tspan').attr('id', 'WordBreakId').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word);
703
702
  }
704
703
  }
705
- const maxDigit = Math.max(...arr);
706
- let maxHeight = 12; // intial value to render corretly first time
707
- axisNode.selectAll('text').each(()=>{
708
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
709
- const outerHTMLElement = document.getElementById('WordBreakId');
710
- const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
711
- const boxHeight = BoxCordinates && BoxCordinates.height;
712
- if (boxHeight > maxHeight) {
713
- maxHeight = boxHeight;
714
- }
715
- });
716
- // If we take directly maxDigit * maxheight, then it will show more height between x axis tick values and bottom.
717
- // To avoid this, reducing maxDigit value by removing some digit based on legth of word.
718
- let removeDigit = 4;
719
- if (maxDigit <= 2) {
720
- removeDigit = 1;
721
- } else if (maxDigit > 2 && maxDigit <= 6) {
722
- removeDigit = 2;
723
- } else if (maxDigit > 6 && maxDigit <= 9) {
724
- removeDigit = 3;
725
- }
726
- removeVal = (maxDigit - removeDigit) * maxHeight;
727
704
  }
705
+ maxLines = Math.max(maxLines, lineNumber + 1);
728
706
  });
707
+ if (!showXAxisLablesTooltip) {
708
+ let maxHeight = 12; // intial value to render corretly first time
709
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
710
+ const outerHTMLElement = document.getElementById('WordBreakId');
711
+ const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
712
+ const boxHeight = BoxCordinates && BoxCordinates.height;
713
+ if (boxHeight > maxHeight) {
714
+ maxHeight = boxHeight;
715
+ }
716
+ removeVal = (maxLines - 1) * maxHeight;
717
+ }
729
718
  return removeVal > 0 ? removeVal : 0;
730
719
  }
731
720
  /**
@@ -743,7 +732,7 @@ yAxis, noOfCharsToTruncate, truncateLabel, isRtl) {
743
732
  const totalWord = text.text();
744
733
  const truncatedWord = isRtl ? `...${text.text().slice(0, noOfCharsToTruncate)}` : `${text.text().slice(0, noOfCharsToTruncate)}...`;
745
734
  const totalWordLength = text.text().length;
746
- const padding = truncateLabel ? 1.5 : 1; // ems
735
+ const padding = 0; // ems
747
736
  const y = text.attr('y');
748
737
  const x = text.attr('x');
749
738
  const dy = parseFloat(text.attr('dy'));