@fluentui/react-charting 5.24.5 → 5.24.7

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 (134) hide show
  1. package/CHANGELOG.json +43 -1
  2. package/CHANGELOG.md +22 -2
  3. package/dist/react-charting.js +1 -1
  4. package/dist/react-charting.min.js +1 -1
  5. package/lib/components/AreaChart/AreaChart.styles.js +2 -2
  6. package/lib/components/AreaChart/AreaChart.styles.js.map +1 -1
  7. package/lib/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  8. package/lib/components/CommonComponents/CartesianChart.base.js +134 -112
  9. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  10. package/lib/components/CommonComponents/CartesianChart.styles.js +35 -62
  11. package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  12. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  13. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  14. package/lib/components/DonutChart/DonutChart.styles.js +2 -18
  15. package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
  16. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +15 -24
  17. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  18. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
  19. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  20. package/lib/components/LineChart/LineChart.styles.js +3 -11
  21. package/lib/components/LineChart/LineChart.styles.js.map +1 -1
  22. package/lib/components/SankeyChart/SankeyChart.styles.js +2 -1
  23. package/lib/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  24. package/lib/components/ScatterChart/ScatterChart.styles.js +3 -14
  25. package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  26. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +14 -12
  27. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  28. package/lib/components/VerticalBarChart/VerticalBarChart.styles.js +3 -14
  29. package/lib/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  30. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +13 -17
  31. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  32. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
  33. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  34. package/lib/utilities/Common.styles.d.ts +6 -0
  35. package/lib/utilities/Common.styles.js +51 -0
  36. package/lib/utilities/Common.styles.js.map +1 -0
  37. package/lib/utilities/SVGTooltipText.d.ts +1 -1
  38. package/lib/utilities/SVGTooltipText.js.map +1 -1
  39. package/lib/utilities/index.d.ts +1 -0
  40. package/lib/utilities/index.js +1 -0
  41. package/lib/utilities/index.js.map +1 -1
  42. package/lib/utilities/utilities.d.ts +3 -0
  43. package/lib/utilities/utilities.js +25 -38
  44. package/lib/utilities/utilities.js.map +1 -1
  45. package/lib/utilities/vbc-utils.d.ts +18 -0
  46. package/lib/utilities/vbc-utils.js +29 -0
  47. package/lib/utilities/vbc-utils.js.map +1 -1
  48. package/lib-amd/components/AreaChart/AreaChart.styles.js +2 -2
  49. package/lib-amd/components/AreaChart/AreaChart.styles.js.map +1 -1
  50. package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  51. package/lib-amd/components/CommonComponents/CartesianChart.base.js +133 -111
  52. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  53. package/lib-amd/components/CommonComponents/CartesianChart.styles.js +33 -61
  54. package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  55. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  56. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  57. package/lib-amd/components/DonutChart/DonutChart.styles.js +2 -17
  58. package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
  59. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
  60. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  61. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -13
  62. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  63. package/lib-amd/components/LineChart/LineChart.styles.js +3 -10
  64. package/lib-amd/components/LineChart/LineChart.styles.js.map +1 -1
  65. package/lib-amd/components/SankeyChart/SankeyChart.styles.js +2 -2
  66. package/lib-amd/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  67. package/lib-amd/components/ScatterChart/ScatterChart.styles.js +3 -13
  68. package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  69. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
  70. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  71. package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js +3 -13
  72. package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  73. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
  74. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  75. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -13
  76. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  77. package/lib-amd/utilities/Common.styles.d.ts +6 -0
  78. package/lib-amd/utilities/Common.styles.js +57 -0
  79. package/lib-amd/utilities/Common.styles.js.map +1 -0
  80. package/lib-amd/utilities/SVGTooltipText.d.ts +1 -1
  81. package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
  82. package/lib-amd/utilities/index.d.ts +1 -0
  83. package/lib-amd/utilities/index.js +2 -1
  84. package/lib-amd/utilities/index.js.map +1 -1
  85. package/lib-amd/utilities/utilities.d.ts +3 -0
  86. package/lib-amd/utilities/utilities.js +26 -39
  87. package/lib-amd/utilities/utilities.js.map +1 -1
  88. package/lib-amd/utilities/vbc-utils.d.ts +18 -0
  89. package/lib-amd/utilities/vbc-utils.js +34 -1
  90. package/lib-amd/utilities/vbc-utils.js.map +1 -1
  91. package/lib-commonjs/components/AreaChart/AreaChart.styles.js +2 -2
  92. package/lib-commonjs/components/AreaChart/AreaChart.styles.js.map +1 -1
  93. package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  94. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +133 -111
  95. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  96. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +33 -60
  97. package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
  98. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  99. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  100. package/lib-commonjs/components/DonutChart/DonutChart.styles.js +2 -18
  101. package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
  102. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
  103. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  104. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
  105. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
  106. package/lib-commonjs/components/LineChart/LineChart.styles.js +3 -11
  107. package/lib-commonjs/components/LineChart/LineChart.styles.js.map +1 -1
  108. package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js +2 -1
  109. package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js.map +1 -1
  110. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +3 -14
  111. package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -1
  112. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
  113. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  114. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js +3 -14
  115. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
  116. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
  117. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  118. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
  119. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
  120. package/lib-commonjs/utilities/Common.styles.d.ts +6 -0
  121. package/lib-commonjs/utilities/Common.styles.js +58 -0
  122. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  123. package/lib-commonjs/utilities/SVGTooltipText.d.ts +1 -1
  124. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  125. package/lib-commonjs/utilities/index.d.ts +1 -0
  126. package/lib-commonjs/utilities/index.js +1 -0
  127. package/lib-commonjs/utilities/index.js.map +1 -1
  128. package/lib-commonjs/utilities/utilities.d.ts +3 -0
  129. package/lib-commonjs/utilities/utilities.js +27 -40
  130. package/lib-commonjs/utilities/utilities.js.map +1 -1
  131. package/lib-commonjs/utilities/vbc-utils.d.ts +18 -0
  132. package/lib-commonjs/utilities/vbc-utils.js +34 -1
  133. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  134. package/package.json +1 -1
@@ -28,4 +28,33 @@ export var calculateAppropriateBarWidth = function (data, totalWidth, innerPaddi
28
28
  var barWidth = Math.floor((totalWidth * closestPairDiff * (1 - innerPadding)) / (range + closestPairDiff * (1 - innerPadding)));
29
29
  return barWidth;
30
30
  };
31
+ /**
32
+ * Calculates the total width available for rendering bars.
33
+ */
34
+ export var calcTotalWidth = function (containerWidth, margins, extraMargin) {
35
+ if (extraMargin === void 0) { extraMargin = 0; }
36
+ return containerWidth - (margins.left || 0) - (margins.right || 0) - extraMargin * 2;
37
+ };
38
+ /**
39
+ * Calculates the combined size of all bands and the gaps between them, in units relative to the bandwidth.
40
+ */
41
+ export var calcTotalBandUnits = function (numBands, innerPadding) {
42
+ // inner_padding = space_between_bands / (space_between_bands + bandwidth)
43
+ // => space_between_bands = (inner_padding / (1 - inner_padding)) * bandwidth
44
+ var gapToBandRatio = innerPadding / (1 - innerPadding);
45
+ return numBands + (numBands - 1) * gapToBandRatio;
46
+ };
47
+ /**
48
+ * Calculates the total width required to render all bands including the gaps between them.
49
+ */
50
+ export var calcRequiredWidth = function (bandwidth, numBands, innerPadding) {
51
+ return bandwidth * calcTotalBandUnits(numBands, innerPadding);
52
+ };
53
+ /**
54
+ * Calculates the maximum possible bandwidth such that the combined widths of all bands
55
+ * and the gaps between them exactly fill the total available width.
56
+ */
57
+ export var calcBandwidth = function (totalWidth, numBands, innerPadding) {
58
+ return totalWidth / calcTotalBandUnits(numBands, innerPadding);
59
+ };
31
60
  //# sourceMappingURL=vbc-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vbc-utils.js","sourceRoot":"../src/","sources":["utilities/vbc-utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,IAAuB;IAChE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC;QACpB,OAAA,CAAC,YAAY,IAAI,CAAC,CAAC,CAAE,CAAU,CAAC,OAAO,EAAE,GAAI,CAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAE,CAAY,GAAI,CAAY;IAAjG,CAAiG,CAClG,CAAC;IACF,IAAI,OAAO,GAAG,MAAM,CAAC,SA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CAAC,UAAU,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CACrG,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC","sourcesContent":["export const getClosestPairDiffAndRange = (data: number[] | Date[]): [number, number] | undefined => {\n if (data.length < 2) {\n return;\n }\n data = data.sort((a, b) =>\n a instanceof Date ? (a as Date).getTime() - (b as Date).getTime() : (a as number) - (b as number),\n );\n let minDiff = Number.MAX_VALUE;\n for (let i = 1; i < data.length; i++) {\n const diff =\n data[i] instanceof Date\n ? (data[i] as Date).getTime() - (data[i - 1] as Date).getTime()\n : (data[i] as number) - (data[i - 1] as number);\n minDiff = Math.min(minDiff, diff);\n }\n const range =\n data[0] instanceof Date\n ? (data[data.length - 1] as Date).getTime() - (data[0] as Date).getTime()\n : (data[data.length - 1] as number) - (data[0] as number);\n return [minDiff, range];\n};\n\nexport const calculateAppropriateBarWidth = (data: number[] | Date[], totalWidth: number, innerPadding: number) => {\n const result = getClosestPairDiffAndRange(data);\n if (!result || result[1] === 0) {\n return 16;\n }\n const [closestPairDiff, range] = result;\n // Refer to https://microsoft.github.io/fluentui-charting-contrib/docs/rfcs/fix-overlapping-bars-on-continuous-axes\n // for the derivation of the following formula.\n const barWidth = Math.floor(\n (totalWidth * closestPairDiff * (1 - innerPadding)) / (range + closestPairDiff * (1 - innerPadding)),\n );\n return barWidth;\n};\n"]}
1
+ {"version":3,"file":"vbc-utils.js","sourceRoot":"../src/","sources":["utilities/vbc-utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,0BAA0B,GAAG,UAAC,IAAuB;IAChE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC;QACpB,OAAA,C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C,QAAQ,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import { IMargins } from './utilities';\n\nexport const getClosestPairDiffAndRange = (data: number[] | Date[]): [number, number] | undefined => {\n if (data.length < 2) {\n return;\n }\n data = data.sort((a, b) =>\n a instanceof Date ? (a as Date).getTime() - (b as Date).getTime() : (a as number) - (b as number),\n );\n let minDiff = Number.MAX_VALUE;\n for (let i = 1; i < data.length; i++) {\n const diff =\n data[i] instanceof Date\n ? (data[i] as Date).getTime() - (data[i - 1] as Date).getTime()\n : (data[i] as number) - (data[i - 1] as number);\n minDiff = Math.min(minDiff, diff);\n }\n const range =\n data[0] instanceof Date\n ? (data[data.length - 1] as Date).getTime() - (data[0] as Date).getTime()\n : (data[data.length - 1] as number) - (data[0] as number);\n return [minDiff, range];\n};\n\nexport const calculateAppropriateBarWidth = (data: number[] | Date[], totalWidth: number, innerPadding: number) => {\n const result = getClosestPairDiffAndRange(data);\n if (!result || result[1] === 0) {\n return 16;\n }\n const [closestPairDiff, range] = result;\n // Refer to https://microsoft.github.io/fluentui-charting-contrib/docs/rfcs/fix-overlapping-bars-on-continuous-axes\n // for the derivation of the following formula.\n const barWidth = Math.floor(\n (totalWidth * closestPairDiff * (1 - innerPadding)) / (range + closestPairDiff * (1 - innerPadding)),\n );\n return barWidth;\n};\n\n/**\n * Calculates the total width available for rendering bars.\n */\nexport const calcTotalWidth = (containerWidth: number, margins: IMargins, extraMargin = 0): number => {\n return containerWidth - (margins.left || 0) - (margins.right || 0) - extraMargin * 2;\n};\n\n/**\n * Calculates the combined size of all bands and the gaps between them, in units relative to the bandwidth.\n */\nexport const calcTotalBandUnits = (numBands: number, innerPadding: number) => {\n // inner_padding = space_between_bands / (space_between_bands + bandwidth)\n // => space_between_bands = (inner_padding / (1 - inner_padding)) * bandwidth\n const gapToBandRatio = innerPadding / (1 - innerPadding);\n return numBands + (numBands - 1) * gapToBandRatio;\n};\n\n/**\n * Calculates the total width required to render all bands including the gaps between them.\n */\nexport const calcRequiredWidth = (bandwidth: number, numBands: number, innerPadding: number) => {\n return bandwidth * calcTotalBandUnits(numBands, innerPadding);\n};\n\n/**\n * Calculates the maximum possible bandwidth such that the combined widths of all bands\n * and the gaps between them exactly fill the total available width.\n */\nexport const calcBandwidth = (totalWidth: number, numBands: number, innerPadding: number) => {\n return totalWidth / calcTotalBandUnits(numBands, innerPadding);\n};\n"]}
@@ -1,10 +1,10 @@
1
- define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
1
+ define(["require", "exports", "../../utilities/index"], function (require, exports, index_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getStyles = void 0;
5
5
  var getStyles = function (props) {
6
6
  return {
7
- tooltip: tslib_1.__assign(tslib_1.__assign({}, props.theme.fonts.medium), { display: 'flex', flexDirection: 'column', padding: '8px', position: 'absolute', textAlign: 'center', top: '0px', background: props.theme.semanticColors.bodyBackground, borderRadius: '2px', pointerEvents: 'none', color: props.theme.semanticColors.bodyText }),
7
+ tooltip: (0, index_1.getTooltipStyle)(props.theme),
8
8
  };
9
9
  };
10
10
  exports.getStyles = getStyles;
@@ -1 +1 @@
1
- {"version":3,"file":"AreaChart.styles.js","sourceRoot":"../src/","sources":["components/AreaChart/AreaChart.styles.ts"],"names":[],"mappings":";;;;IAEO,IAAM,SAAS,GAAG,UAAC,KAA2B;QACnD,OAAO;YACL,OAAO,wCACF,KAAK,CAAC,KAAM,CAAC,KAAK,CAAC,MAAM,KAC5B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,UAAU,EACpB,SAAS,EAAE,QAAQ,EACnB,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,KAAK,CAAC,KAAM,CAAC,cAAc,CAAC,cAAc,EACtD,YAAY,EAAE,KAAK,EACnB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,KAAK,CAAC,KAAM,CAAC,cAAc,CAAC,QAAQ,GAC5C;SACF,CAAC;IACJ,CAAC,CAAC;IAhBW,QAAA,SAAS,aAgBpB","sourcesContent":["import { IAreaChartStyleProps, IAreaChartStyles } from './AreaChart.types';\n\nexport const getStyles = (props: IAreaChartStyleProps): IAreaChartStyles => {\n return {\n tooltip: {\n ...props.theme!.fonts.medium,\n display: 'flex',\n flexDirection: 'column',\n padding: '8px',\n position: 'absolute',\n textAlign: 'center',\n top: '0px',\n background: props.theme!.semanticColors.bodyBackground,\n borderRadius: '2px',\n pointerEvents: 'none',\n color: props.theme!.semanticColors.bodyText,\n },\n };\n};\n"]}
1
+ {"version":3,"file":"AreaChart.styles.js","sourceRoot":"../src/","sources":["components/AreaChart/AreaChart.styles.ts"],"names":[],"mappings":";;;;IAGO,IAAM,SAAS,GAAG,UAAC,KAA2B;QACnD,OAAO;YACL,OAAO,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,KAAM,CAAC;SACvC,CAAC;IACJ,CAAC,CAAC;IAJW,QAAA,SAAS,aAIpB","sourcesContent":["import { IAreaChartStyleProps, IAreaChartStyles } from './AreaChart.types';\nimport { getTooltipStyle } from '../../utilities/index';\n\nexport const getStyles = (props: IAreaChartStyleProps): IAreaChartStyles => {\n return {\n tooltip: getTooltipStyle(props.theme!),\n };\n};\n"]}
@@ -6,8 +6,6 @@ export interface ICartesianChartState {
6
6
  containerHeight: number;
7
7
  _width: number;
8
8
  _height: number;
9
- isRemoveValCalculated?: boolean;
10
- _removalValueForTextTuncate?: number;
11
9
  startFromX: number;
12
10
  }
13
11
  /**
@@ -32,6 +30,7 @@ export declare class CartesianChartBase extends React.Component<IModifiedCartesi
32
30
  private _tickValues;
33
31
  private titleMargin;
34
32
  private _isFirstRender;
33
+ private _removalValueForTextTuncate;
35
34
  private _xScale;
36
35
  private isIntegralDataset;
37
36
  private _tooltipId;
@@ -62,4 +61,6 @@ export declare class CartesianChartBase extends React.Component<IModifiedCartesi
62
61
  private _calculateChartMinWidth;
63
62
  private _getChartDescription;
64
63
  private _getAxisTitle;
64
+ private _calcMaxLabelWidthWithTransform;
65
+ private _transformXAxisLabels;
65
66
  }
@@ -25,6 +25,13 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
25
25
  _this.minLegendContainerHeight = 32;
26
26
  _this._isRtl = (0, Utilities_1.getRTL)();
27
27
  _this._isFirstRender = true;
28
+ /* Used for when WrapXAxisLabels props appeared.
29
+ * To display the total word (space separated words), Need to have more space than usual.
30
+ * This height will get total height need to disaply total word.
31
+ * These value need to be removed from actual svg height/graph height.
32
+ * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
33
+ */
34
+ _this._removalValueForTextTuncate = 0;
28
35
  _this.isIntegralDataset = true;
29
36
  _this.calculateMaxYAxisLabelLength = function (className) {
30
37
  var formatTickLabel = function (str) {
@@ -62,43 +69,14 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
62
69
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
70
  _this._getData = function (xScale, yScalePrimary, yScaleSecondary) {
64
71
  _this.props.getGraphData &&
65
- _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this.state._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
72
+ _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
66
73
  };
67
74
  _this._onChartLeave = function () {
68
75
  _this.props.onChartMouseLeave && _this.props.onChartMouseLeave();
69
76
  };
70
77
  _this._calculateChartMinWidth = function () {
71
- var labelWidth = 10; // Total padding on the left and right sides of the label
72
- // Case: rotated labels
73
- if (!_this.props.wrapXAxisLables &&
74
- _this.props.rotateXAxisLables &&
75
- _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
76
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
77
- labelWidth += Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
78
- }
79
- // Case: truncated labels
80
- else if (_this.props.showXAxisLablesTooltip) {
81
- var tickValues = _this._tickValues.map(function (val) {
82
- var numChars = _this.props.noOfCharsToTruncate || 4;
83
- return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
84
- });
85
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(tickValues, ".".concat(_this._classNames.xAxis, " text"));
86
- labelWidth += Math.ceil(longestLabelWidth);
87
- }
88
- // Case: wrapped labels
89
- else if (_this.props.wrapXAxisLables) {
90
- var words_1 = [];
91
- _this._tickValues.forEach(function (val) {
92
- words_1.push.apply(words_1, val.toString().split(/\s+/));
93
- });
94
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(words_1, ".".concat(_this._classNames.xAxis, " text"));
95
- labelWidth += Math.max(Math.ceil(longestLabelWidth), 10);
96
- }
97
- // Default case
98
- else {
99
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
100
- labelWidth += Math.ceil(longestLabelWidth);
101
- }
78
+ // Adding 10px for padding on both sides
79
+ var labelWidth = _this._calcMaxLabelWidthWithTransform(_this._tickValues) + 10;
102
80
  var minChartWidth = _this.margins.left + _this.margins.right + labelWidth * (_this._tickValues.length - 1);
103
81
  if ([index_1.ChartTypes.GroupedVerticalBarChart, index_1.ChartTypes.VerticalBarChart, index_1.ChartTypes.VerticalStackedBarChart].includes(_this.props.chartType)) {
104
82
  var minDomainMargin = 8;
@@ -124,13 +102,85 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
124
102
  : 'values')) +
125
103
  '. ');
126
104
  };
105
+ _this._calcMaxLabelWidthWithTransform = function (x) {
106
+ // Case: rotated labels
107
+ if (!_this.props.wrapXAxisLables &&
108
+ _this.props.rotateXAxisLables &&
109
+ _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
110
+ var longestLabelWidth_1 = (0, index_1.calculateLongestLabelWidth)(x, ".".concat(_this._classNames.xAxis, " text"));
111
+ return Math.ceil(longestLabelWidth_1 * Math.cos(Math.PI / 4));
112
+ }
113
+ // Case: truncated labels
114
+ if (_this.props.showXAxisLablesTooltip) {
115
+ var tickValues = x.map(function (val) {
116
+ var numChars = _this.props.noOfCharsToTruncate || 4;
117
+ return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
118
+ });
119
+ var longestLabelWidth_2 = (0, index_1.calculateLongestLabelWidth)(tickValues, ".".concat(_this._classNames.xAxis, " text"));
120
+ return Math.ceil(longestLabelWidth_2);
121
+ }
122
+ // Case: wrapped labels
123
+ if (_this.props.wrapXAxisLables) {
124
+ // FIXME: Calculate the max width of lines instead of words. This requires applying
125
+ // the wrapping transformation earlier to obtain the actual rendered lines.
126
+ var words_1 = [];
127
+ x.forEach(function (val) {
128
+ words_1.push.apply(words_1, val.toString().split(/\s+/));
129
+ });
130
+ // This approach works well in most cases, since overflow typically occurs only when
131
+ // a single word exceeds the specified width — otherwise, the text will wrap as expected.
132
+ var longestLabelWidth_3 = (0, index_1.calculateLongestLabelWidth)(words_1, ".".concat(_this._classNames.xAxis, " text"));
133
+ return Math.max(Math.ceil(longestLabelWidth_3), index_1.DEFAULT_WRAP_WIDTH);
134
+ }
135
+ // Default case
136
+ var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(x, ".".concat(_this._classNames.xAxis, " text"));
137
+ return Math.ceil(longestLabelWidth);
138
+ };
139
+ _this._transformXAxisLabels = function () {
140
+ var _a, _b, _c;
141
+ _this._removalValueForTextTuncate = 0;
142
+ /*
143
+ * To enable wrapping of x axis tick values or to display complete x axis tick values,
144
+ * we need to calculate how much space it needed to render the text.
145
+ * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
146
+ * Required space will be calculated first time chart rendering and if any width/height of chart updated.
147
+ * */
148
+ if (_this.props.wrapXAxisLables || _this.props.showXAxisLablesTooltip) {
149
+ var maxXAxisLabelWidth = void 0;
150
+ if (_this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
151
+ if ((((_a = _this.props.datasetForXAxisDomain) === null || _a === void 0 ? void 0 : _a.length) || 0) > 1) {
152
+ maxXAxisLabelWidth = _this._xScale.step();
153
+ }
154
+ else {
155
+ maxXAxisLabelWidth = _this.state.containerWidth;
156
+ }
157
+ }
158
+ var wrapLabelProps = {
159
+ node: _this.xAxisElement,
160
+ xAxis: _this._xScale,
161
+ showXAxisLablesTooltip: _this.props.showXAxisLablesTooltip || false,
162
+ noOfCharsToTruncate: _this.props.noOfCharsToTruncate || 4,
163
+ width: maxXAxisLabelWidth,
164
+ };
165
+ _this._removalValueForTextTuncate = (_b = (0, index_1.createWrapOfXLabels)(wrapLabelProps)) !== null && _b !== void 0 ? _b : 0;
166
+ }
167
+ if (!_this.props.wrapXAxisLables &&
168
+ _this.props.rotateXAxisLables &&
169
+ _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
170
+ var rotateLabelProps = {
171
+ node: _this.xAxisElement,
172
+ xAxis: _this._xScale,
173
+ };
174
+ var rotatedHeight = (_c = (0, index_1.rotateXAxisLabels)(rotateLabelProps)) !== null && _c !== void 0 ? _c : 0;
175
+ // this.margins.bottom is used as padding here
176
+ _this._removalValueForTextTuncate = rotatedHeight + _this.margins.bottom;
177
+ }
178
+ };
127
179
  _this.state = {
128
180
  containerHeight: 0,
129
181
  containerWidth: 0,
130
182
  _width: _this.props.width || 600,
131
183
  _height: _this.props.height || 350,
132
- _removalValueForTextTuncate: 0,
133
- isRemoveValCalculated: true,
134
184
  startFromX: 0,
135
185
  };
136
186
  _this.idForGraph = (0, Utilities_1.getId)('chart_');
@@ -218,23 +268,6 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
218
268
  if (prevProps.height !== this.props.height || prevProps.width !== this.props.width) {
219
269
  this._fitParentContainer();
220
270
  }
221
- if (!this.props.wrapXAxisLables &&
222
- this.props.rotateXAxisLables &&
223
- this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
224
- var rotateLabelProps = {
225
- node: this.xAxisElement,
226
- xAxis: this._xScale,
227
- };
228
- var rotatedHeight = (0, index_1.rotateXAxisLabels)(rotateLabelProps);
229
- if (this.state.isRemoveValCalculated &&
230
- this.state._removalValueForTextTuncate !== rotatedHeight + this.margins.bottom &&
231
- rotatedHeight > 0) {
232
- this.setState({
233
- _removalValueForTextTuncate: rotatedHeight + this.margins.bottom,
234
- isRemoveValCalculated: false,
235
- });
236
- }
237
- }
238
271
  if (chartTypesWithStringYAxis.includes(this.props.chartType) &&
239
272
  this.props.showYAxisLables &&
240
273
  this.yAxisElement &&
@@ -294,7 +327,13 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
294
327
  domainNRangeValues: this.props.getDomainNRangeValues(points, this.props.getDomainMargins ? this.props.getDomainMargins(this.state.containerWidth) : this.margins, this.state.containerWidth, chartType, this._isRtl, this.props.xAxisType, this.props.barwidth, this.props.tickValues,
295
328
  // This is only used for Horizontal Bar Chart with Axis for y as string axis
296
329
  this.state.startFromX),
297
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
330
+ // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
331
+ // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
332
+ // However, if transformation props are enabled, the updated _removalValueForTextTuncate
333
+ // will only be available in the next render, as it's set after the axis is created.
334
+ // Solution: Delay the creation of gridlines until after the transformation has been applied,
335
+ // or precompute the required height for transformed labels (_removalValueForTextTuncate).
336
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
298
337
  margins: this.margins,
299
338
  xAxisElement: this.xAxisElement,
300
339
  showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true,
@@ -305,27 +344,8 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
305
344
  xAxisInnerPadding: this.props.xAxisInnerPadding,
306
345
  xAxisOuterPadding: this.props.xAxisOuterPadding,
307
346
  containerWidth: this.state.containerWidth,
308
- hideTickOverlap: this.props.hideTickOverlap &&
309
- !this.props.rotateXAxisLables &&
310
- !this.props.showXAxisLablesTooltip &&
311
- !this.props.wrapXAxisLables,
312
- };
313
- var YAxisParams = {
314
- margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
315
- containerWidth: this.state.containerWidth,
316
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
317
- yAxisElement: this.yAxisElement,
318
- yAxisTickFormat: this.props.yAxisTickFormat,
319
- yAxisTickCount: this.props.yAxisTickCount,
320
- yMinValue: this.props.yMinValue || 0,
321
- yMaxValue: this.props.yMaxValue || 0,
322
- tickPadding: 10,
323
- maxOfYVal: this.props.maxOfYVal,
324
- yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
325
- // please note these padding default values must be consistent in here
326
- // and the parent chart(HBWA/Vertical etc..) for more details refer example
327
- // http://using-d3js.com/04_07_ordinal_scales.html
328
- yAxisPadding: this.props.yAxisPadding || 0,
347
+ hideTickOverlap: this.props.hideTickOverlap,
348
+ calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform,
329
349
  };
330
350
  /**
331
351
  * These scales used for 2 purposes.
@@ -351,25 +371,24 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
351
371
  }
352
372
  this._xScale = xScale;
353
373
  this._tickValues = tickValues;
354
- /*
355
- * To enable wrapping of x axis tick values or to display complete x axis tick values,
356
- * we need to calculate how much space it needed to render the text.
357
- * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
358
- * Required space will be calculated first time chart rendering and if any width/height of chart updated.
359
- * */
360
- if (this.props.wrapXAxisLables || this.props.showXAxisLablesTooltip) {
361
- var wrapLabelProps = {
362
- node: this.xAxisElement,
363
- xAxis: xScale,
364
- showXAxisLablesTooltip: this.props.showXAxisLablesTooltip || false,
365
- noOfCharsToTruncate: this.props.noOfCharsToTruncate || 4,
366
- };
367
- var temp = xScale && (0, index_1.createWrapOfXLabels)(wrapLabelProps);
368
- // this value need to be updated for draw graph updated. So instead of using private value, using set state.
369
- if (this.state.isRemoveValCalculated && this.state._removalValueForTextTuncate !== temp) {
370
- this.setState({ _removalValueForTextTuncate: temp, isRemoveValCalculated: false });
371
- }
372
- }
374
+ this._transformXAxisLabels();
375
+ var YAxisParams = {
376
+ margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
377
+ containerWidth: this.state.containerWidth,
378
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
379
+ yAxisElement: this.yAxisElement,
380
+ yAxisTickFormat: this.props.yAxisTickFormat,
381
+ yAxisTickCount: this.props.yAxisTickCount,
382
+ yMinValue: this.props.yMinValue || 0,
383
+ yMaxValue: this.props.yMaxValue || 0,
384
+ tickPadding: 10,
385
+ maxOfYVal: this.props.maxOfYVal,
386
+ yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
387
+ // please note these padding default values must be consistent in here
388
+ // and the parent chart(HBWA/Vertical etc..) for more details refer example
389
+ // http://using-d3js.com/04_07_ordinal_scales.html
390
+ yAxisPadding: this.props.yAxisPadding || 0,
391
+ };
373
392
  /**
374
393
  * These scales used for 2 purposes.
375
394
  * 1. To create x and y axis
@@ -394,7 +413,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
394
413
  var YAxisParamsSecondary = {
395
414
  margins: this.margins,
396
415
  containerWidth: this.state.containerWidth,
397
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
416
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
398
417
  yAxisElement: this.yAxisElementSecondary,
399
418
  yAxisTickFormat: this.props.yAxisTickFormat,
400
419
  yAxisTickCount: this.props.yAxisTickCount,
@@ -467,8 +486,14 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
467
486
  var yAxisTitleMaximumAllowedHeight = svgDimensions.height -
468
487
  this.margins.bottom -
469
488
  this.margins.top -
470
- this.state._removalValueForTextTuncate -
489
+ this._removalValueForTextTuncate -
471
490
  this.titleMargin;
491
+ var commonSvgToolTipProps = {
492
+ wrapContent: index_1.wrapContent,
493
+ theme: this.props.theme,
494
+ showBackground: true,
495
+ className: this._classNames.svgTooltip,
496
+ };
472
497
  /**
473
498
  * We have use the {@link defaultTabbableElement } to fix
474
499
  * the Focus not landing on chart while tabbing, instead goes to legend.
@@ -497,21 +522,21 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
497
522
  _this.xAxisElement = e;
498
523
  }, id: "xAxisGElement".concat(this.idForGraph),
499
524
  // To add wrap of x axis lables feature, need to remove word height from svg height.
500
- transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this.state._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
501
- this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.xAxisTitle, textProps: {
525
+ transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
526
+ this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.xAxisTitle, textProps: {
502
527
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
503
528
  y: svgDimensions.height - this.titleMargin,
504
529
  className: this._classNames.axisTitle,
505
530
  textAnchor: 'middle',
506
531
  'aria-hidden': true,
507
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
508
- this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.xAxisAnnotation, textProps: {
532
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
533
+ this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.xAxisAnnotation, textProps: {
509
534
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
510
535
  y: this.titleMargin + 3,
511
536
  className: this._classNames.axisAnnotation,
512
537
  textAnchor: 'middle',
513
538
  'aria-hidden': true,
514
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
539
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
515
540
  React.createElement("g", { ref: function (e) {
516
541
  _this.yAxisElement = e;
517
542
  }, id: "yAxisGElement".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
@@ -523,9 +548,8 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
523
548
  }, id: "yAxisGElementSecondary".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
524
549
  ? this.margins.left + this.state.startFromX
525
550
  : svgDimensions.width - this.margins.right - this.state.startFromX, ", 0)"), className: this._classNames.yAxis }),
526
- this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.secondaryYAxistitle, textProps: {
527
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
528
- this.state._removalValueForTextTuncate,
551
+ this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.secondaryYAxistitle, textProps: {
552
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
529
553
  y: this._isRtl
530
554
  ? this.state.startFromX - this.titleMargin
531
555
  : svgDimensions.width - this.margins.right,
@@ -535,11 +559,10 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
535
559
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
536
560
  className: this._classNames.axisTitle,
537
561
  'aria-hidden': true,
538
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
562
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
539
563
  children,
540
- this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.yAxisTitle, textProps: {
541
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
542
- this.state._removalValueForTextTuncate,
564
+ this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisTitle, textProps: {
565
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
543
566
  y: this._isRtl
544
567
  ? svgDimensions.width - this.margins.right / 2 + this.titleMargin
545
568
  : this.margins.left / 2 - this.titleMargin,
@@ -547,12 +570,11 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
547
570
  transform: "translate(0,\n ".concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
548
571
  className: this._classNames.axisTitle,
549
572
  'aria-hidden': true,
550
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
573
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))),
551
574
  this.props.yAxisAnnotation !== undefined &&
552
575
  this.props.yAxisAnnotation !== '' &&
553
- (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.yAxisAnnotation, textProps: {
554
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
555
- this.state._removalValueForTextTuncate,
576
+ (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisAnnotation, textProps: {
577
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
556
578
  y: this._isRtl
557
579
  ? this.state.startFromX - this.titleMargin
558
580
  : svgDimensions.width - this.margins.right,
@@ -562,7 +584,7 @@ define(["require", "exports", "tslib", "react", "@fluentui/react/lib/Utilities",
562
584
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
563
585
  className: this._classNames.axisAnnotation,
564
586
  'aria-hidden': true,
565
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
587
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
566
588
  !this.props.hideLegend && (React.createElement("div", { ref: function (e) { return (_this.legendContainer = e); }, className: this._classNames.legendContainer }, this.props.legendBars)),
567
589
  callout && React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") }, callout)));
568
590
  };