@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
@@ -1,7 +1,7 @@
1
1
  define(["require", "exports"], function (require, exports) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.calculateAppropriateBarWidth = exports.getClosestPairDiffAndRange = void 0;
4
+ exports.calcBandwidth = exports.calcRequiredWidth = exports.calcTotalBandUnits = exports.calcTotalWidth = exports.calculateAppropriateBarWidth = exports.getClosestPairDiffAndRange = void 0;
5
5
  var getClosestPairDiffAndRange = function (data) {
6
6
  if (data.length < 2) {
7
7
  return;
@@ -34,5 +34,38 @@ define(["require", "exports"], function (require, exports) {
34
34
  return barWidth;
35
35
  };
36
36
  exports.calculateAppropriateBarWidth = calculateAppropriateBarWidth;
37
+ /**
38
+ * Calculates the total width available for rendering bars.
39
+ */
40
+ var calcTotalWidth = function (containerWidth, margins, extraMargin) {
41
+ if (extraMargin === void 0) { extraMargin = 0; }
42
+ return containerWidth - (margins.left || 0) - (margins.right || 0) - extraMargin * 2;
43
+ };
44
+ exports.calcTotalWidth = calcTotalWidth;
45
+ /**
46
+ * Calculates the combined size of all bands and the gaps between them, in units relative to the bandwidth.
47
+ */
48
+ var calcTotalBandUnits = function (numBands, innerPadding) {
49
+ // inner_padding = space_between_bands / (space_between_bands + bandwidth)
50
+ // => space_between_bands = (inner_padding / (1 - inner_padding)) * bandwidth
51
+ var gapToBandRatio = innerPadding / (1 - innerPadding);
52
+ return numBands + (numBands - 1) * gapToBandRatio;
53
+ };
54
+ exports.calcTotalBandUnits = calcTotalBandUnits;
55
+ /**
56
+ * Calculates the total width required to render all bands including the gaps between them.
57
+ */
58
+ var calcRequiredWidth = function (bandwidth, numBands, innerPadding) {
59
+ return bandwidth * (0, exports.calcTotalBandUnits)(numBands, innerPadding);
60
+ };
61
+ exports.calcRequiredWidth = calcRequiredWidth;
62
+ /**
63
+ * Calculates the maximum possible bandwidth such that the combined widths of all bands
64
+ * and the gaps between them exactly fill the total available width.
65
+ */
66
+ var calcBandwidth = function (totalWidth, numBands, innerPadding) {
67
+ return totalWidth / (0, exports.calcTotalBandUnits)(numBands, innerPadding);
68
+ };
69
+ exports.calcBandwidth = calcBandwidth;
37
70
  });
38
71
  //# sourceMappingURL=vbc-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vbc-utils.js","sourceRoot":"../src/","sources":["utilities/vbc-utils.ts"],"names":[],"mappings":";;;;IAAO,IAAM,0BAA0B,GAAG,UAAC,IAAuB;QAChE,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QACD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC;YACpB,OAAA,CAAC,YAAY,IAAI,CAAC,CAAC,CAAE,CAAU,CAAC,OAAO,EAAE,GAAI,CAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAE,CAAY,GAAI,CAAY;QAAjG,CAAiG,CAClG,CAAC;QACF,IAAI,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC;QAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAM,IAAI,GACR,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI;gBACrB,CAAC,CAAE,IAAI,CAAC,CAAC,CAAU,CAAC,OAAO,EAAE,GAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAU,CAAC,OAAO,EAAE;gBAC/D,CAAC,CAAE,IAAI,CAAC,CAAC,CAAY,GAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAY,CAAC;YACpD,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,IAAM,KAAK,GACT,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI;YACrB,CAAC,CAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAU,CAAC,OAAO,EAAE,GAAI,IAAI,CAAC,CAAC,CAAU,CAAC,OAAO,EAAE;YACzE,CAAC,CAAE,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAY,GAAI,IAAI,CAAC,CAAC,CAAY,CAAC;QAC9D,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;IApBW,QAAA,0BAA0B,8BAoBrC;IAEK,IAAM,4BAA4B,GAAG,UAAC,IAAuB,EAAE,UAAkB,EAAE,YAAoB;QAC5G,IAAM,MAAM,GAAG,IAAA,kCAA0B,EAAC,IAAI,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QACM,IAAA,eAAe,GAAW,MAAM,GAAjB,EAAE,KAAK,GAAI,MAAM,GAAV,CAAW;QACxC,mHAAmH;QACnH,+CAA+C;QAC/C,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,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;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAZW,QAAA,4BAA4B,gCAYvC","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":"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","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
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStyles = void 0;
4
- var tslib_1 = require("tslib");
4
+ var index_1 = require("../../utilities/index");
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":";;;;AAEO,IAAM,SAAS,GAAG,UAAC,KAA2B;IACnD,OAAO;QACL,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;KACF,CAAC;AACJ,CAAC,CAAC;AAhBW,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":";;;AACA,+CAAwD;AAEjD,IAAM,SAAS,GAAG,UAAC,KAA2B;IACnD,OAAO;QACL,OAAO,EAAE,IAAA,uBAAe,EAAC,KAAK,CAAC,KAAM,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC;AAJW,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
  }
@@ -34,6 +34,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
34
34
  _this.minLegendContainerHeight = 32;
35
35
  _this._isRtl = (0, Utilities_1.getRTL)();
36
36
  _this._isFirstRender = true;
37
+ /* Used for when WrapXAxisLabels props appeared.
38
+ * To display the total word (space separated words), Need to have more space than usual.
39
+ * This height will get total height need to disaply total word.
40
+ * These value need to be removed from actual svg height/graph height.
41
+ * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
42
+ */
43
+ _this._removalValueForTextTuncate = 0;
37
44
  _this.isIntegralDataset = true;
38
45
  _this.calculateMaxYAxisLabelLength = function (className) {
39
46
  var formatTickLabel = function (str) {
@@ -71,43 +78,14 @@ var CartesianChartBase = /** @class */ (function (_super) {
71
78
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
79
  _this._getData = function (xScale, yScalePrimary, yScaleSecondary) {
73
80
  _this.props.getGraphData &&
74
- _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this.state._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
81
+ _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
75
82
  };
76
83
  _this._onChartLeave = function () {
77
84
  _this.props.onChartMouseLeave && _this.props.onChartMouseLeave();
78
85
  };
79
86
  _this._calculateChartMinWidth = function () {
80
- var labelWidth = 10; // Total padding on the left and right sides of the label
81
- // Case: rotated labels
82
- if (!_this.props.wrapXAxisLables &&
83
- _this.props.rotateXAxisLables &&
84
- _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
85
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
86
- labelWidth += Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
87
- }
88
- // Case: truncated labels
89
- else if (_this.props.showXAxisLablesTooltip) {
90
- var tickValues = _this._tickValues.map(function (val) {
91
- var numChars = _this.props.noOfCharsToTruncate || 4;
92
- return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
93
- });
94
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(tickValues, ".".concat(_this._classNames.xAxis, " text"));
95
- labelWidth += Math.ceil(longestLabelWidth);
96
- }
97
- // Case: wrapped labels
98
- else if (_this.props.wrapXAxisLables) {
99
- var words_1 = [];
100
- _this._tickValues.forEach(function (val) {
101
- words_1.push.apply(words_1, val.toString().split(/\s+/));
102
- });
103
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(words_1, ".".concat(_this._classNames.xAxis, " text"));
104
- labelWidth += Math.max(Math.ceil(longestLabelWidth), 10);
105
- }
106
- // Default case
107
- else {
108
- var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
109
- labelWidth += Math.ceil(longestLabelWidth);
110
- }
87
+ // Adding 10px for padding on both sides
88
+ var labelWidth = _this._calcMaxLabelWidthWithTransform(_this._tickValues) + 10;
111
89
  var minChartWidth = _this.margins.left + _this.margins.right + labelWidth * (_this._tickValues.length - 1);
112
90
  if ([index_1.ChartTypes.GroupedVerticalBarChart, index_1.ChartTypes.VerticalBarChart, index_1.ChartTypes.VerticalStackedBarChart].includes(_this.props.chartType)) {
113
91
  var minDomainMargin = 8;
@@ -133,13 +111,85 @@ var CartesianChartBase = /** @class */ (function (_super) {
133
111
  : 'values')) +
134
112
  '. ');
135
113
  };
114
+ _this._calcMaxLabelWidthWithTransform = function (x) {
115
+ // Case: rotated labels
116
+ if (!_this.props.wrapXAxisLables &&
117
+ _this.props.rotateXAxisLables &&
118
+ _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
119
+ var longestLabelWidth_1 = (0, index_1.calculateLongestLabelWidth)(x, ".".concat(_this._classNames.xAxis, " text"));
120
+ return Math.ceil(longestLabelWidth_1 * Math.cos(Math.PI / 4));
121
+ }
122
+ // Case: truncated labels
123
+ if (_this.props.showXAxisLablesTooltip) {
124
+ var tickValues = x.map(function (val) {
125
+ var numChars = _this.props.noOfCharsToTruncate || 4;
126
+ return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
127
+ });
128
+ var longestLabelWidth_2 = (0, index_1.calculateLongestLabelWidth)(tickValues, ".".concat(_this._classNames.xAxis, " text"));
129
+ return Math.ceil(longestLabelWidth_2);
130
+ }
131
+ // Case: wrapped labels
132
+ if (_this.props.wrapXAxisLables) {
133
+ // FIXME: Calculate the max width of lines instead of words. This requires applying
134
+ // the wrapping transformation earlier to obtain the actual rendered lines.
135
+ var words_1 = [];
136
+ x.forEach(function (val) {
137
+ words_1.push.apply(words_1, val.toString().split(/\s+/));
138
+ });
139
+ // This approach works well in most cases, since overflow typically occurs only when
140
+ // a single word exceeds the specified width — otherwise, the text will wrap as expected.
141
+ var longestLabelWidth_3 = (0, index_1.calculateLongestLabelWidth)(words_1, ".".concat(_this._classNames.xAxis, " text"));
142
+ return Math.max(Math.ceil(longestLabelWidth_3), index_1.DEFAULT_WRAP_WIDTH);
143
+ }
144
+ // Default case
145
+ var longestLabelWidth = (0, index_1.calculateLongestLabelWidth)(x, ".".concat(_this._classNames.xAxis, " text"));
146
+ return Math.ceil(longestLabelWidth);
147
+ };
148
+ _this._transformXAxisLabels = function () {
149
+ var _a, _b, _c;
150
+ _this._removalValueForTextTuncate = 0;
151
+ /*
152
+ * To enable wrapping of x axis tick values or to display complete x axis tick values,
153
+ * we need to calculate how much space it needed to render the text.
154
+ * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
155
+ * Required space will be calculated first time chart rendering and if any width/height of chart updated.
156
+ * */
157
+ if (_this.props.wrapXAxisLables || _this.props.showXAxisLablesTooltip) {
158
+ var maxXAxisLabelWidth = void 0;
159
+ if (_this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
160
+ if ((((_a = _this.props.datasetForXAxisDomain) === null || _a === void 0 ? void 0 : _a.length) || 0) > 1) {
161
+ maxXAxisLabelWidth = _this._xScale.step();
162
+ }
163
+ else {
164
+ maxXAxisLabelWidth = _this.state.containerWidth;
165
+ }
166
+ }
167
+ var wrapLabelProps = {
168
+ node: _this.xAxisElement,
169
+ xAxis: _this._xScale,
170
+ showXAxisLablesTooltip: _this.props.showXAxisLablesTooltip || false,
171
+ noOfCharsToTruncate: _this.props.noOfCharsToTruncate || 4,
172
+ width: maxXAxisLabelWidth,
173
+ };
174
+ _this._removalValueForTextTuncate = (_b = (0, index_1.createWrapOfXLabels)(wrapLabelProps)) !== null && _b !== void 0 ? _b : 0;
175
+ }
176
+ if (!_this.props.wrapXAxisLables &&
177
+ _this.props.rotateXAxisLables &&
178
+ _this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
179
+ var rotateLabelProps = {
180
+ node: _this.xAxisElement,
181
+ xAxis: _this._xScale,
182
+ };
183
+ var rotatedHeight = (_c = (0, index_1.rotateXAxisLabels)(rotateLabelProps)) !== null && _c !== void 0 ? _c : 0;
184
+ // this.margins.bottom is used as padding here
185
+ _this._removalValueForTextTuncate = rotatedHeight + _this.margins.bottom;
186
+ }
187
+ };
136
188
  _this.state = {
137
189
  containerHeight: 0,
138
190
  containerWidth: 0,
139
191
  _width: _this.props.width || 600,
140
192
  _height: _this.props.height || 350,
141
- _removalValueForTextTuncate: 0,
142
- isRemoveValCalculated: true,
143
193
  startFromX: 0,
144
194
  };
145
195
  _this.idForGraph = (0, Utilities_1.getId)('chart_');
@@ -227,23 +277,6 @@ var CartesianChartBase = /** @class */ (function (_super) {
227
277
  if (prevProps.height !== this.props.height || prevProps.width !== this.props.width) {
228
278
  this._fitParentContainer();
229
279
  }
230
- if (!this.props.wrapXAxisLables &&
231
- this.props.rotateXAxisLables &&
232
- this.props.xAxisType === index_1.XAxisTypes.StringAxis) {
233
- var rotateLabelProps = {
234
- node: this.xAxisElement,
235
- xAxis: this._xScale,
236
- };
237
- var rotatedHeight = (0, index_1.rotateXAxisLabels)(rotateLabelProps);
238
- if (this.state.isRemoveValCalculated &&
239
- this.state._removalValueForTextTuncate !== rotatedHeight + this.margins.bottom &&
240
- rotatedHeight > 0) {
241
- this.setState({
242
- _removalValueForTextTuncate: rotatedHeight + this.margins.bottom,
243
- isRemoveValCalculated: false,
244
- });
245
- }
246
- }
247
280
  if (chartTypesWithStringYAxis.includes(this.props.chartType) &&
248
281
  this.props.showYAxisLables &&
249
282
  this.yAxisElement &&
@@ -303,7 +336,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
303
336
  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,
304
337
  // This is only used for Horizontal Bar Chart with Axis for y as string axis
305
338
  this.state.startFromX),
306
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
339
+ // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
340
+ // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
341
+ // However, if transformation props are enabled, the updated _removalValueForTextTuncate
342
+ // will only be available in the next render, as it's set after the axis is created.
343
+ // Solution: Delay the creation of gridlines until after the transformation has been applied,
344
+ // or precompute the required height for transformed labels (_removalValueForTextTuncate).
345
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
307
346
  margins: this.margins,
308
347
  xAxisElement: this.xAxisElement,
309
348
  showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true,
@@ -314,27 +353,8 @@ var CartesianChartBase = /** @class */ (function (_super) {
314
353
  xAxisInnerPadding: this.props.xAxisInnerPadding,
315
354
  xAxisOuterPadding: this.props.xAxisOuterPadding,
316
355
  containerWidth: this.state.containerWidth,
317
- hideTickOverlap: this.props.hideTickOverlap &&
318
- !this.props.rotateXAxisLables &&
319
- !this.props.showXAxisLablesTooltip &&
320
- !this.props.wrapXAxisLables,
321
- };
322
- var YAxisParams = {
323
- margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
324
- containerWidth: this.state.containerWidth,
325
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
326
- yAxisElement: this.yAxisElement,
327
- yAxisTickFormat: this.props.yAxisTickFormat,
328
- yAxisTickCount: this.props.yAxisTickCount,
329
- yMinValue: this.props.yMinValue || 0,
330
- yMaxValue: this.props.yMaxValue || 0,
331
- tickPadding: 10,
332
- maxOfYVal: this.props.maxOfYVal,
333
- yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
334
- // please note these padding default values must be consistent in here
335
- // and the parent chart(HBWA/Vertical etc..) for more details refer example
336
- // http://using-d3js.com/04_07_ordinal_scales.html
337
- yAxisPadding: this.props.yAxisPadding || 0,
356
+ hideTickOverlap: this.props.hideTickOverlap,
357
+ calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform,
338
358
  };
339
359
  /**
340
360
  * These scales used for 2 purposes.
@@ -360,25 +380,24 @@ var CartesianChartBase = /** @class */ (function (_super) {
360
380
  }
361
381
  this._xScale = xScale;
362
382
  this._tickValues = tickValues;
363
- /*
364
- * To enable wrapping of x axis tick values or to display complete x axis tick values,
365
- * we need to calculate how much space it needed to render the text.
366
- * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
367
- * Required space will be calculated first time chart rendering and if any width/height of chart updated.
368
- * */
369
- if (this.props.wrapXAxisLables || this.props.showXAxisLablesTooltip) {
370
- var wrapLabelProps = {
371
- node: this.xAxisElement,
372
- xAxis: xScale,
373
- showXAxisLablesTooltip: this.props.showXAxisLablesTooltip || false,
374
- noOfCharsToTruncate: this.props.noOfCharsToTruncate || 4,
375
- };
376
- var temp = xScale && (0, index_1.createWrapOfXLabels)(wrapLabelProps);
377
- // this value need to be updated for draw graph updated. So instead of using private value, using set state.
378
- if (this.state.isRemoveValCalculated && this.state._removalValueForTextTuncate !== temp) {
379
- this.setState({ _removalValueForTextTuncate: temp, isRemoveValCalculated: false });
380
- }
381
- }
383
+ this._transformXAxisLabels();
384
+ var YAxisParams = {
385
+ margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
386
+ containerWidth: this.state.containerWidth,
387
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
388
+ yAxisElement: this.yAxisElement,
389
+ yAxisTickFormat: this.props.yAxisTickFormat,
390
+ yAxisTickCount: this.props.yAxisTickCount,
391
+ yMinValue: this.props.yMinValue || 0,
392
+ yMaxValue: this.props.yMaxValue || 0,
393
+ tickPadding: 10,
394
+ maxOfYVal: this.props.maxOfYVal,
395
+ yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
396
+ // please note these padding default values must be consistent in here
397
+ // and the parent chart(HBWA/Vertical etc..) for more details refer example
398
+ // http://using-d3js.com/04_07_ordinal_scales.html
399
+ yAxisPadding: this.props.yAxisPadding || 0,
400
+ };
382
401
  /**
383
402
  * These scales used for 2 purposes.
384
403
  * 1. To create x and y axis
@@ -403,7 +422,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
403
422
  var YAxisParamsSecondary = {
404
423
  margins: this.margins,
405
424
  containerWidth: this.state.containerWidth,
406
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
425
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
407
426
  yAxisElement: this.yAxisElementSecondary,
408
427
  yAxisTickFormat: this.props.yAxisTickFormat,
409
428
  yAxisTickCount: this.props.yAxisTickCount,
@@ -476,8 +495,14 @@ var CartesianChartBase = /** @class */ (function (_super) {
476
495
  var yAxisTitleMaximumAllowedHeight = svgDimensions.height -
477
496
  this.margins.bottom -
478
497
  this.margins.top -
479
- this.state._removalValueForTextTuncate -
498
+ this._removalValueForTextTuncate -
480
499
  this.titleMargin;
500
+ var commonSvgToolTipProps = {
501
+ wrapContent: index_1.wrapContent,
502
+ theme: this.props.theme,
503
+ showBackground: true,
504
+ className: this._classNames.svgTooltip,
505
+ };
481
506
  /**
482
507
  * We have use the {@link defaultTabbableElement } to fix
483
508
  * the Focus not landing on chart while tabbing, instead goes to legend.
@@ -506,21 +531,21 @@ var CartesianChartBase = /** @class */ (function (_super) {
506
531
  _this.xAxisElement = e;
507
532
  }, id: "xAxisGElement".concat(this.idForGraph),
508
533
  // To add wrap of x axis lables feature, need to remove word height from svg height.
509
- transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this.state._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
510
- this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.xAxisTitle, textProps: {
534
+ transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
535
+ this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.xAxisTitle, textProps: {
511
536
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
512
537
  y: svgDimensions.height - this.titleMargin,
513
538
  className: this._classNames.axisTitle,
514
539
  textAnchor: 'middle',
515
540
  'aria-hidden': true,
516
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
517
- this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.xAxisAnnotation, textProps: {
541
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
542
+ this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.xAxisAnnotation, textProps: {
518
543
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
519
544
  y: this.titleMargin + 3,
520
545
  className: this._classNames.axisAnnotation,
521
546
  textAnchor: 'middle',
522
547
  'aria-hidden': true,
523
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
548
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
524
549
  React.createElement("g", { ref: function (e) {
525
550
  _this.yAxisElement = e;
526
551
  }, id: "yAxisGElement".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
@@ -532,9 +557,8 @@ var CartesianChartBase = /** @class */ (function (_super) {
532
557
  }, id: "yAxisGElementSecondary".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
533
558
  ? this.margins.left + this.state.startFromX
534
559
  : svgDimensions.width - this.margins.right - this.state.startFromX, ", 0)"), className: this._classNames.yAxis }),
535
- this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.secondaryYAxistitle, textProps: {
536
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
537
- this.state._removalValueForTextTuncate,
560
+ this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.secondaryYAxistitle, textProps: {
561
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
538
562
  y: this._isRtl
539
563
  ? this.state.startFromX - this.titleMargin
540
564
  : svgDimensions.width - this.margins.right,
@@ -544,11 +568,10 @@ var CartesianChartBase = /** @class */ (function (_super) {
544
568
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
545
569
  className: this._classNames.axisTitle,
546
570
  'aria-hidden': true,
547
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
571
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
548
572
  children,
549
- this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.yAxisTitle, textProps: {
550
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
551
- this.state._removalValueForTextTuncate,
573
+ this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisTitle, textProps: {
574
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
552
575
  y: this._isRtl
553
576
  ? svgDimensions.width - this.margins.right / 2 + this.titleMargin
554
577
  : this.margins.left / 2 - this.titleMargin,
@@ -556,12 +579,11 @@ var CartesianChartBase = /** @class */ (function (_super) {
556
579
  transform: "translate(0,\n ".concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
557
580
  className: this._classNames.axisTitle,
558
581
  'aria-hidden': true,
559
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
582
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))),
560
583
  this.props.yAxisAnnotation !== undefined &&
561
584
  this.props.yAxisAnnotation !== '' &&
562
- (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText_1.SVGTooltipText, { content: this.props.yAxisAnnotation, textProps: {
563
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
564
- this.state._removalValueForTextTuncate,
585
+ (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisAnnotation, textProps: {
586
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
565
587
  y: this._isRtl
566
588
  ? this.state.startFromX - this.titleMargin
567
589
  : svgDimensions.width - this.margins.right,
@@ -571,7 +593,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
571
593
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
572
594
  className: this._classNames.axisAnnotation,
573
595
  'aria-hidden': true,
574
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: index_1.wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
596
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
575
597
  !this.props.hideLegend && (React.createElement("div", { ref: function (e) { return (_this.legendContainer = e); }, className: this._classNames.legendContainer }, this.props.legendBars)),
576
598
  callout && React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") }, callout)));
577
599
  };