@fluentui/react-charting 5.24.6 → 5.24.8

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 (62) 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/CommonComponents/CartesianChart.base.d.ts +3 -2
  6. package/lib/components/CommonComponents/CartesianChart.base.js +118 -102
  7. package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
  8. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  9. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  10. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +15 -24
  11. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  12. package/lib/components/ScatterChart/ScatterChart.base.js +22 -23
  13. package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
  14. package/lib/components/VerticalBarChart/VerticalBarChart.base.js +14 -12
  15. package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  16. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +13 -17
  17. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  18. package/lib/utilities/utilities.d.ts +3 -0
  19. package/lib/utilities/utilities.js +25 -38
  20. package/lib/utilities/utilities.js.map +1 -1
  21. package/lib/utilities/vbc-utils.d.ts +18 -0
  22. package/lib/utilities/vbc-utils.js +29 -0
  23. package/lib/utilities/vbc-utils.js.map +1 -1
  24. package/lib-amd/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  25. package/lib-amd/components/CommonComponents/CartesianChart.base.js +117 -101
  26. package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
  27. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  28. package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  29. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
  30. package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  31. package/lib-amd/components/ScatterChart/ScatterChart.base.js +22 -23
  32. package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
  33. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
  34. package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  35. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
  36. package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  37. package/lib-amd/utilities/utilities.d.ts +3 -0
  38. package/lib-amd/utilities/utilities.js +26 -39
  39. package/lib-amd/utilities/utilities.js.map +1 -1
  40. package/lib-amd/utilities/vbc-utils.d.ts +18 -0
  41. package/lib-amd/utilities/vbc-utils.js +34 -1
  42. package/lib-amd/utilities/vbc-utils.js.map +1 -1
  43. package/lib-commonjs/components/CommonComponents/CartesianChart.base.d.ts +3 -2
  44. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +117 -101
  45. package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
  46. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +13 -10
  47. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  48. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +14 -23
  49. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
  50. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +22 -23
  51. package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
  52. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +13 -11
  53. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
  54. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +12 -16
  55. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
  56. package/lib-commonjs/utilities/utilities.d.ts +3 -0
  57. package/lib-commonjs/utilities/utilities.js +27 -40
  58. package/lib-commonjs/utilities/utilities.js.map +1 -1
  59. package/lib-commonjs/utilities/vbc-utils.d.ts +18 -0
  60. package/lib-commonjs/utilities/vbc-utils.js +34 -1
  61. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  62. 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,C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AndRange = (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":";;;;IAEO,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,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AndRange = (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"]}
@@ -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,7 +495,7 @@ 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;
481
500
  var commonSvgToolTipProps = {
482
501
  wrapContent: index_1.wrapContent,
@@ -512,7 +531,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
512
531
  _this.xAxisElement = e;
513
532
  }, id: "xAxisGElement".concat(this.idForGraph),
514
533
  // To add wrap of x axis lables feature, need to remove word height from svg height.
515
- transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this.state._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
534
+ transform: "translate(0, ".concat(svgDimensions.height - this.margins.bottom - this._removalValueForTextTuncate, ")"), className: this._classNames.xAxis }),
516
535
  this.props.xAxisTitle !== undefined && this.props.xAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.xAxisTitle, textProps: {
517
536
  x: this.margins.left + this.state.startFromX + xAxisTitleMaximumAllowedWidth / 2,
518
537
  y: svgDimensions.height - this.titleMargin,
@@ -539,8 +558,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
539
558
  ? this.margins.left + this.state.startFromX
540
559
  : svgDimensions.width - this.margins.right - this.state.startFromX, ", 0)"), className: this._classNames.yAxis }),
541
560
  this.props.secondaryYAxistitle !== undefined && this.props.secondaryYAxistitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.secondaryYAxistitle, textProps: {
542
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
543
- this.state._removalValueForTextTuncate,
561
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
544
562
  y: this._isRtl
545
563
  ? this.state.startFromX - this.titleMargin
546
564
  : svgDimensions.width - this.margins.right,
@@ -553,8 +571,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
553
571
  }, maxWidth: yAxisTitleMaximumAllowedHeight }, commonSvgToolTipProps))))),
554
572
  children,
555
573
  this.props.yAxisTitle !== undefined && this.props.yAxisTitle !== '' && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisTitle, textProps: {
556
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
557
- this.state._removalValueForTextTuncate,
574
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
558
575
  y: this._isRtl
559
576
  ? svgDimensions.width - this.margins.right / 2 + this.titleMargin
560
577
  : this.margins.left / 2 - this.titleMargin,
@@ -566,8 +583,7 @@ var CartesianChartBase = /** @class */ (function (_super) {
566
583
  this.props.yAxisAnnotation !== undefined &&
567
584
  this.props.yAxisAnnotation !== '' &&
568
585
  (this.props.secondaryYAxistitle === undefined || this.props.secondaryYAxistitle === '') && (React.createElement(SVGTooltipText_1.SVGTooltipText, tslib_1.__assign({ content: this.props.yAxisAnnotation, textProps: {
569
- x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 +
570
- this.state._removalValueForTextTuncate,
586
+ x: (yAxisTitleMaximumAllowedHeight - this.margins.bottom) / 2 + this._removalValueForTextTuncate,
571
587
  y: this._isRtl
572
588
  ? this.state.startFromX - this.titleMargin
573
589
  : svgDimensions.width - this.margins.right,