@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
- import { __assign } from "tslib";
1
+ import { getTooltipStyle } from '../../utilities/index';
2
2
  export var getStyles = function (props) {
3
3
  return {
4
- tooltip: __assign(__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 }),
4
+ tooltip: getTooltipStyle(props.theme),
5
5
  };
6
6
  };
7
7
  //# sourceMappingURL=AreaChart.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AreaChart.styles.js","sourceRoot":"../src/","sources":["components/AreaChart/AreaChart.styles.ts"],"names":[],"mappings":";AAEA,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAA2B;IACnD,OAAO;QACL,OAAO,wBACF,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","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,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,IAAM,SAAS,GAAG,UAAC,KAA2B;IACnD,OAAO;QACL,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,KAAM,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC","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
  }
@@ -5,7 +5,7 @@ import { Callout } from '@fluentui/react/lib/Callout';
5
5
  import { FocusZone, FocusZoneDirection } from '@fluentui/react-focus';
6
6
  import { select as d3Select } from 'd3-selection';
7
7
  import { formatToLocaleString } from '@fluentui/chart-utilities';
8
- import { createNumericXAxis, createStringXAxis, getAccessibleDataObject, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, Points, pointTypes, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, getSecureProps, truncateString, tooltipOfAxislabels, } from '../../utilities/index';
8
+ import { createNumericXAxis, createStringXAxis, getAccessibleDataObject, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, Points, pointTypes, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, getSecureProps, truncateString, tooltipOfAxislabels, DEFAULT_WRAP_WIDTH, } from '../../utilities/index';
9
9
  import { Shape } from '../Legends/index';
10
10
  import { SVGTooltipText } from '../../utilities/SVGTooltipText';
11
11
  var getClassNames = classNamesFunction();
@@ -31,6 +31,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
31
31
  _this.minLegendContainerHeight = 32;
32
32
  _this._isRtl = getRTL();
33
33
  _this._isFirstRender = true;
34
+ /* Used for when WrapXAxisLabels props appeared.
35
+ * To display the total word (space separated words), Need to have more space than usual.
36
+ * This height will get total height need to disaply total word.
37
+ * These value need to be removed from actual svg height/graph height.
38
+ * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
39
+ */
40
+ _this._removalValueForTextTuncate = 0;
34
41
  _this.isIntegralDataset = true;
35
42
  _this.calculateMaxYAxisLabelLength = function (className) {
36
43
  var formatTickLabel = function (str) {
@@ -68,43 +75,14 @@ var CartesianChartBase = /** @class */ (function (_super) {
68
75
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
76
  _this._getData = function (xScale, yScalePrimary, yScaleSecondary) {
70
77
  _this.props.getGraphData &&
71
- _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this.state._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
78
+ _this.props.getGraphData(xScale, yScalePrimary, _this.state.containerHeight - _this._removalValueForTextTuncate, _this.state.containerWidth, _this.xAxisElement, _this.yAxisElement, yScaleSecondary);
72
79
  };
73
80
  _this._onChartLeave = function () {
74
81
  _this.props.onChartMouseLeave && _this.props.onChartMouseLeave();
75
82
  };
76
83
  _this._calculateChartMinWidth = function () {
77
- var labelWidth = 10; // Total padding on the left and right sides of the label
78
- // Case: rotated labels
79
- if (!_this.props.wrapXAxisLables &&
80
- _this.props.rotateXAxisLables &&
81
- _this.props.xAxisType === XAxisTypes.StringAxis) {
82
- var longestLabelWidth = calculateLongestLabelWidth(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
83
- labelWidth += Math.ceil(longestLabelWidth * Math.cos(Math.PI / 4));
84
- }
85
- // Case: truncated labels
86
- else if (_this.props.showXAxisLablesTooltip) {
87
- var tickValues = _this._tickValues.map(function (val) {
88
- var numChars = _this.props.noOfCharsToTruncate || 4;
89
- return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
90
- });
91
- var longestLabelWidth = calculateLongestLabelWidth(tickValues, ".".concat(_this._classNames.xAxis, " text"));
92
- labelWidth += Math.ceil(longestLabelWidth);
93
- }
94
- // Case: wrapped labels
95
- else if (_this.props.wrapXAxisLables) {
96
- var words_1 = [];
97
- _this._tickValues.forEach(function (val) {
98
- words_1.push.apply(words_1, val.toString().split(/\s+/));
99
- });
100
- var longestLabelWidth = calculateLongestLabelWidth(words_1, ".".concat(_this._classNames.xAxis, " text"));
101
- labelWidth += Math.max(Math.ceil(longestLabelWidth), 10);
102
- }
103
- // Default case
104
- else {
105
- var longestLabelWidth = calculateLongestLabelWidth(_this._tickValues, ".".concat(_this._classNames.xAxis, " text"));
106
- labelWidth += Math.ceil(longestLabelWidth);
107
- }
84
+ // Adding 10px for padding on both sides
85
+ var labelWidth = _this._calcMaxLabelWidthWithTransform(_this._tickValues) + 10;
108
86
  var minChartWidth = _this.margins.left + _this.margins.right + labelWidth * (_this._tickValues.length - 1);
109
87
  if ([ChartTypes.GroupedVerticalBarChart, ChartTypes.VerticalBarChart, ChartTypes.VerticalStackedBarChart].includes(_this.props.chartType)) {
110
88
  var minDomainMargin = 8;
@@ -130,13 +108,85 @@ var CartesianChartBase = /** @class */ (function (_super) {
130
108
  : 'values')) +
131
109
  '. ');
132
110
  };
111
+ _this._calcMaxLabelWidthWithTransform = function (x) {
112
+ // Case: rotated labels
113
+ if (!_this.props.wrapXAxisLables &&
114
+ _this.props.rotateXAxisLables &&
115
+ _this.props.xAxisType === XAxisTypes.StringAxis) {
116
+ var longestLabelWidth_1 = calculateLongestLabelWidth(x, ".".concat(_this._classNames.xAxis, " text"));
117
+ return Math.ceil(longestLabelWidth_1 * Math.cos(Math.PI / 4));
118
+ }
119
+ // Case: truncated labels
120
+ if (_this.props.showXAxisLablesTooltip) {
121
+ var tickValues = x.map(function (val) {
122
+ var numChars = _this.props.noOfCharsToTruncate || 4;
123
+ return val.toString().length > numChars ? "".concat(val.toString().slice(0, numChars), "...") : val;
124
+ });
125
+ var longestLabelWidth_2 = calculateLongestLabelWidth(tickValues, ".".concat(_this._classNames.xAxis, " text"));
126
+ return Math.ceil(longestLabelWidth_2);
127
+ }
128
+ // Case: wrapped labels
129
+ if (_this.props.wrapXAxisLables) {
130
+ // FIXME: Calculate the max width of lines instead of words. This requires applying
131
+ // the wrapping transformation earlier to obtain the actual rendered lines.
132
+ var words_1 = [];
133
+ x.forEach(function (val) {
134
+ words_1.push.apply(words_1, val.toString().split(/\s+/));
135
+ });
136
+ // This approach works well in most cases, since overflow typically occurs only when
137
+ // a single word exceeds the specified width — otherwise, the text will wrap as expected.
138
+ var longestLabelWidth_3 = calculateLongestLabelWidth(words_1, ".".concat(_this._classNames.xAxis, " text"));
139
+ return Math.max(Math.ceil(longestLabelWidth_3), DEFAULT_WRAP_WIDTH);
140
+ }
141
+ // Default case
142
+ var longestLabelWidth = calculateLongestLabelWidth(x, ".".concat(_this._classNames.xAxis, " text"));
143
+ return Math.ceil(longestLabelWidth);
144
+ };
145
+ _this._transformXAxisLabels = function () {
146
+ var _a, _b, _c;
147
+ _this._removalValueForTextTuncate = 0;
148
+ /*
149
+ * To enable wrapping of x axis tick values or to display complete x axis tick values,
150
+ * we need to calculate how much space it needed to render the text.
151
+ * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
152
+ * Required space will be calculated first time chart rendering and if any width/height of chart updated.
153
+ * */
154
+ if (_this.props.wrapXAxisLables || _this.props.showXAxisLablesTooltip) {
155
+ var maxXAxisLabelWidth = void 0;
156
+ if (_this.props.xAxisType === XAxisTypes.StringAxis) {
157
+ if ((((_a = _this.props.datasetForXAxisDomain) === null || _a === void 0 ? void 0 : _a.length) || 0) > 1) {
158
+ maxXAxisLabelWidth = _this._xScale.step();
159
+ }
160
+ else {
161
+ maxXAxisLabelWidth = _this.state.containerWidth;
162
+ }
163
+ }
164
+ var wrapLabelProps = {
165
+ node: _this.xAxisElement,
166
+ xAxis: _this._xScale,
167
+ showXAxisLablesTooltip: _this.props.showXAxisLablesTooltip || false,
168
+ noOfCharsToTruncate: _this.props.noOfCharsToTruncate || 4,
169
+ width: maxXAxisLabelWidth,
170
+ };
171
+ _this._removalValueForTextTuncate = (_b = createWrapOfXLabels(wrapLabelProps)) !== null && _b !== void 0 ? _b : 0;
172
+ }
173
+ if (!_this.props.wrapXAxisLables &&
174
+ _this.props.rotateXAxisLables &&
175
+ _this.props.xAxisType === XAxisTypes.StringAxis) {
176
+ var rotateLabelProps = {
177
+ node: _this.xAxisElement,
178
+ xAxis: _this._xScale,
179
+ };
180
+ var rotatedHeight = (_c = rotateXAxisLabels(rotateLabelProps)) !== null && _c !== void 0 ? _c : 0;
181
+ // this.margins.bottom is used as padding here
182
+ _this._removalValueForTextTuncate = rotatedHeight + _this.margins.bottom;
183
+ }
184
+ };
133
185
  _this.state = {
134
186
  containerHeight: 0,
135
187
  containerWidth: 0,
136
188
  _width: _this.props.width || 600,
137
189
  _height: _this.props.height || 350,
138
- _removalValueForTextTuncate: 0,
139
- isRemoveValCalculated: true,
140
190
  startFromX: 0,
141
191
  };
142
192
  _this.idForGraph = getId('chart_');
@@ -224,23 +274,6 @@ var CartesianChartBase = /** @class */ (function (_super) {
224
274
  if (prevProps.height !== this.props.height || prevProps.width !== this.props.width) {
225
275
  this._fitParentContainer();
226
276
  }
227
- if (!this.props.wrapXAxisLables &&
228
- this.props.rotateXAxisLables &&
229
- this.props.xAxisType === XAxisTypes.StringAxis) {
230
- var rotateLabelProps = {
231
- node: this.xAxisElement,
232
- xAxis: this._xScale,
233
- };
234
- var rotatedHeight = rotateXAxisLabels(rotateLabelProps);
235
- if (this.state.isRemoveValCalculated &&
236
- this.state._removalValueForTextTuncate !== rotatedHeight + this.margins.bottom &&
237
- rotatedHeight > 0) {
238
- this.setState({
239
- _removalValueForTextTuncate: rotatedHeight + this.margins.bottom,
240
- isRemoveValCalculated: false,
241
- });
242
- }
243
- }
244
277
  if (chartTypesWithStringYAxis.includes(this.props.chartType) &&
245
278
  this.props.showYAxisLables &&
246
279
  this.yAxisElement &&
@@ -300,7 +333,13 @@ var CartesianChartBase = /** @class */ (function (_super) {
300
333
  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,
301
334
  // This is only used for Horizontal Bar Chart with Axis for y as string axis
302
335
  this.state.startFromX),
303
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
336
+ // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
337
+ // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
338
+ // However, if transformation props are enabled, the updated _removalValueForTextTuncate
339
+ // will only be available in the next render, as it's set after the axis is created.
340
+ // Solution: Delay the creation of gridlines until after the transformation has been applied,
341
+ // or precompute the required height for transformed labels (_removalValueForTextTuncate).
342
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
304
343
  margins: this.margins,
305
344
  xAxisElement: this.xAxisElement,
306
345
  showRoundOffXTickValues: (_e = this.props.showRoundOffXTickValues) !== null && _e !== void 0 ? _e : true,
@@ -311,27 +350,8 @@ var CartesianChartBase = /** @class */ (function (_super) {
311
350
  xAxisInnerPadding: this.props.xAxisInnerPadding,
312
351
  xAxisOuterPadding: this.props.xAxisOuterPadding,
313
352
  containerWidth: this.state.containerWidth,
314
- hideTickOverlap: this.props.hideTickOverlap &&
315
- !this.props.rotateXAxisLables &&
316
- !this.props.showXAxisLablesTooltip &&
317
- !this.props.wrapXAxisLables,
318
- };
319
- var YAxisParams = {
320
- margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
321
- containerWidth: this.state.containerWidth,
322
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
323
- yAxisElement: this.yAxisElement,
324
- yAxisTickFormat: this.props.yAxisTickFormat,
325
- yAxisTickCount: this.props.yAxisTickCount,
326
- yMinValue: this.props.yMinValue || 0,
327
- yMaxValue: this.props.yMaxValue || 0,
328
- tickPadding: 10,
329
- maxOfYVal: this.props.maxOfYVal,
330
- yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
331
- // please note these padding default values must be consistent in here
332
- // and the parent chart(HBWA/Vertical etc..) for more details refer example
333
- // http://using-d3js.com/04_07_ordinal_scales.html
334
- yAxisPadding: this.props.yAxisPadding || 0,
353
+ hideTickOverlap: this.props.hideTickOverlap,
354
+ calcMaxLabelWidth: this._calcMaxLabelWidthWithTransform,
335
355
  };
336
356
  /**
337
357
  * These scales used for 2 purposes.
@@ -357,25 +377,24 @@ var CartesianChartBase = /** @class */ (function (_super) {
357
377
  }
358
378
  this._xScale = xScale;
359
379
  this._tickValues = tickValues;
360
- /*
361
- * To enable wrapping of x axis tick values or to display complete x axis tick values,
362
- * we need to calculate how much space it needed to render the text.
363
- * No need to re-calculate every time the chart renders and same time need to get an update. So using setState.
364
- * Required space will be calculated first time chart rendering and if any width/height of chart updated.
365
- * */
366
- if (this.props.wrapXAxisLables || this.props.showXAxisLablesTooltip) {
367
- var wrapLabelProps = {
368
- node: this.xAxisElement,
369
- xAxis: xScale,
370
- showXAxisLablesTooltip: this.props.showXAxisLablesTooltip || false,
371
- noOfCharsToTruncate: this.props.noOfCharsToTruncate || 4,
372
- };
373
- var temp = xScale && createWrapOfXLabels(wrapLabelProps);
374
- // this value need to be updated for draw graph updated. So instead of using private value, using set state.
375
- if (this.state.isRemoveValCalculated && this.state._removalValueForTextTuncate !== temp) {
376
- this.setState({ _removalValueForTextTuncate: temp, isRemoveValCalculated: false });
377
- }
378
- }
380
+ this._transformXAxisLabels();
381
+ var YAxisParams = {
382
+ margins: this.props.getYDomainMargins ? this.props.getYDomainMargins(this.state.containerHeight) : this.margins,
383
+ containerWidth: this.state.containerWidth,
384
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
385
+ yAxisElement: this.yAxisElement,
386
+ yAxisTickFormat: this.props.yAxisTickFormat,
387
+ yAxisTickCount: this.props.yAxisTickCount,
388
+ yMinValue: this.props.yMinValue || 0,
389
+ yMaxValue: this.props.yMaxValue || 0,
390
+ tickPadding: 10,
391
+ maxOfYVal: this.props.maxOfYVal,
392
+ yMinMaxValues: this.props.getMinMaxOfYAxis(points, this.props.yAxisType),
393
+ // please note these padding default values must be consistent in here
394
+ // and the parent chart(HBWA/Vertical etc..) for more details refer example
395
+ // http://using-d3js.com/04_07_ordinal_scales.html
396
+ yAxisPadding: this.props.yAxisPadding || 0,
397
+ };
379
398
  /**
380
399
  * These scales used for 2 purposes.
381
400
  * 1. To create x and y axis
@@ -400,7 +419,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
400
419
  var YAxisParamsSecondary = {
401
420
  margins: this.margins,
402
421
  containerWidth: this.state.containerWidth,
403
- containerHeight: this.state.containerHeight - this.state._removalValueForTextTuncate,
422
+ containerHeight: this.state.containerHeight - this._removalValueForTextTuncate,
404
423
  yAxisElement: this.yAxisElementSecondary,
405
424
  yAxisTickFormat: this.props.yAxisTickFormat,
406
425
  yAxisTickCount: this.props.yAxisTickCount,
@@ -473,8 +492,14 @@ var CartesianChartBase = /** @class */ (function (_super) {
473
492
  var yAxisTitleMaximumAllowedHeight = svgDimensions.height -
474
493
  this.margins.bottom -
475
494
  this.margins.top -
476
- this.state._removalValueForTextTuncate -
495
+ this._removalValueForTextTuncate -
477
496
  this.titleMargin;
497
+ var commonSvgToolTipProps = {
498
+ wrapContent: wrapContent,
499
+ theme: this.props.theme,
500
+ showBackground: true,
501
+ className: this._classNames.svgTooltip,
502
+ };
478
503
  /**
479
504
  * We have use the {@link defaultTabbableElement } to fix
480
505
  * the Focus not landing on chart while tabbing, instead goes to legend.
@@ -503,21 +528,21 @@ var CartesianChartBase = /** @class */ (function (_super) {
503
528
  _this.xAxisElement = e;
504
529
  }, id: "xAxisGElement".concat(this.idForGraph),
505
530
  // To add wrap of x axis lables feature, need to remove word height from svg height.
506
- transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this.state._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
507
- this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText, { content: this.props.xAxisTitle, textProps: {
531
+ transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
532
+ this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.xAxisTitle, textProps: {
508
533
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
509
534
  y: svgDimensions.height - this.titleMargin,
510
535
  className: this._classNames.axisTitle,
511
536
  textAnchor: 'middle',
512
537
  'aria-hidden': true,
513
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
514
- this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText, { content: this.props.xAxisAnnotation, textProps: {
538
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
539
+ this.props.xAxisAnnotation !== undefined && this.props.xAxisAnnotation !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.xAxisAnnotation, textProps: {
515
540
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
516
541
  y: this.titleMargin + 3,
517
542
  className: this._classNames.axisAnnotation,
518
543
  textAnchor: 'middle',
519
544
  'aria-hidden': true,
520
- }, maxWidth: xAxisTitleMaximumAllowedWidth, wrapContent: wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
545
+ }, maxWidth: xAxisTitleMaximumAllowedWidth }, commonSvgToolTipProps))),
521
546
  React.createElement("g", { ref: function (e) {
522
547
  _this.yAxisElement = e;
523
548
  }, id: "yAxisGElement".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
@@ -529,9 +554,8 @@ var CartesianChartBase = /** @class */ (function (_super) {
529
554
  }, id: "yAxisGElementSecondary".concat(this.idForGraph), transform: "translate(".concat(this._isRtl
530
555
  ? this.margins.left + this.state.startFromX
531
556
  : svgDimensions.width - this.margins.right - this.state.startFromX, ", 0)"), className: this._classNames.yAxis }),
532
- this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText, { content: this.props.secondaryYAxistitle, textProps: {
533
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
534
- this.state._removalValueForTextTuncate,
557
+ this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.secondaryYAxistitle, textProps: {
558
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
535
559
  y: this._isRtl
536
560
  ? this.state.startFromX - this.titleMargin
537
561
  : svgDimensions.width - this.margins.right,
@@ -541,11 +565,10 @@ var CartesianChartBase = /** @class */ (function (_super) {
541
565
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
542
566
  className: this._classNames.axisTitle,
543
567
  'aria-hidden': true,
544
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
568
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
545
569
  children,
546
- this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText, { content: this.props.yAxisTitle, textProps: {
547
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
548
- this.state._removalValueForTextTuncate,
570
+ this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText, __assign({ content: this.props.yAxisTitle, textProps: {
571
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
549
572
  y: this._isRtl
550
573
  ? svgDimensions.width - this.margins.right / 2 + this.titleMargin
551
574
  : this.margins.left / 2 - this.titleMargin,
@@ -553,12 +576,11 @@ var CartesianChartBase = /** @class */ (function (_super) {
553
576
  transform: "translate(0,\n ".concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
554
577
  className: this._classNames.axisTitle,
555
578
  'aria-hidden': true,
556
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })),
579
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))),
557
580
  this.props.yAxisAnnotation !== undefined &&
558
581
  this.props.yAxisAnnotation !== '' &&
559
- (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText, { content: this.props.yAxisAnnotation, textProps: {
560
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
561
- this.state._removalValueForTextTuncate,
582
+ (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText, __assign({ content: this.props.yAxisAnnotation, textProps: {
583
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
562
584
  y: this._isRtl
563
585
  ? this.state.startFromX - this.titleMargin
564
586
  : svgDimensions.width - this.margins.right,
@@ -568,7 +590,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
568
590
  : this.margins.right / 2 + this.titleMargin, ",\n ").concat(svgDimensions.height - this.margins.bottom - this.margins.top - this.titleMargin, ")rotate(-90)"),
569
591
  className: this._classNames.axisAnnotation,
570
592
  'aria-hidden': true,
571
- }, maxWidth: yAxisTitleMaximumAllowedHeight, wrapContent: wrapContent, theme: this.props.theme, showBackground: true, className: this._classNames.svgTooltip })))),
593
+ }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
572
594
  !this.props.hideLegend && (React.createElement("div", { ref: function (e) { return (_this.legendContainer = e); }, className: this._classNames.legendContainer }, this.props.legendBars)),
573
595
  callout && React.createElement(React.Suspense, { fallback: React.createElement("div", null, "Loading...") }, callout)));
574
596
  };