@fluentui/react-charts 0.0.0-nightly-20251110-0407.1 → 0.0.0-nightly-20251111-0407.1

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 (143) hide show
  1. package/CHANGELOG.md +13 -13
  2. package/dist/index.d.ts +12 -44
  3. package/lib/components/AreaChart/useAreaChartStyles.styles.js +8 -5
  4. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  5. package/lib/components/ChartTable/useChartTableStyles.styles.js +59 -39
  6. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  7. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +5 -5
  8. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.js +129 -129
  10. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -10
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  14. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +2 -6
  15. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  16. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
  17. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  18. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +3 -0
  19. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  20. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +23 -8
  21. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  22. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -2
  23. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  24. package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  25. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  26. package/lib/components/GanttChart/GanttChart.js +3 -3
  27. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  28. package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
  29. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
  30. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +8 -5
  32. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  33. package/lib/components/HeatMapChart/HeatMapChart.js +1 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  35. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  36. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +25 -12
  37. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  38. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +4 -4
  39. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  40. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  41. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  42. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  43. package/lib/components/Legends/useLegendsStyles.styles.js +97 -37
  44. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  45. package/lib/components/Legends/useLegendsStyles.styles.raw.js +10 -11
  46. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  47. package/lib/components/LineChart/LineChart.js +1 -1
  48. package/lib/components/LineChart/LineChart.js.map +1 -1
  49. package/lib/components/LineChart/useLineChartStyles.styles.js +12 -9
  50. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  51. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +13 -10
  52. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  53. package/lib/components/ScatterChart/ScatterChart.js +1 -1
  54. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  55. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  56. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +10 -7
  57. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  58. package/lib/components/VerticalBarChart/VerticalBarChart.js +1 -1
  59. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -7
  61. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  62. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
  63. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  64. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  65. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +8 -5
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  67. package/lib/utilities/Common.styles.js +1 -2
  68. package/lib/utilities/Common.styles.js.map +1 -1
  69. package/lib/utilities/Common.styles.raw.js +1 -2
  70. package/lib/utilities/Common.styles.raw.js.map +1 -1
  71. package/lib/utilities/utilities.js +16 -13
  72. package/lib/utilities/utilities.js.map +1 -1
  73. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +11 -14
  74. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  75. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +74 -102
  76. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  77. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +4 -4
  78. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  79. package/lib-commonjs/components/CommonComponents/CartesianChart.js +129 -128
  80. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  81. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  82. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +16 -19
  83. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  84. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -14
  85. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  86. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
  87. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  88. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +3 -0
  89. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  90. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +25 -16
  91. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  92. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +1 -1
  93. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  94. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  95. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  96. package/lib-commonjs/components/GanttChart/GanttChart.js +3 -3
  97. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  98. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
  99. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
  100. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  101. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +11 -14
  102. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  103. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +1 -1
  104. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  105. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  106. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +47 -34
  107. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +3 -3
  109. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  111. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  112. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  113. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +144 -86
  114. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  115. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +9 -10
  116. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  117. package/lib-commonjs/components/LineChart/LineChart.js +1 -1
  118. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  119. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +15 -18
  120. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  121. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +16 -19
  122. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  123. package/lib-commonjs/components/ScatterChart/ScatterChart.js +1 -1
  124. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  125. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  126. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +13 -16
  127. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  128. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
  129. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  130. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +13 -16
  131. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  132. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
  133. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  134. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  135. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +11 -14
  136. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  137. package/lib-commonjs/utilities/Common.styles.js +1 -2
  138. package/lib-commonjs/utilities/Common.styles.js.map +1 -1
  139. package/lib-commonjs/utilities/Common.styles.raw.js +1 -2
  140. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
  141. package/lib-commonjs/utilities/utilities.js +16 -13
  142. package/lib-commonjs/utilities/utilities.js.map +1 -1
  143. package/package.json +13 -13
@@ -19,8 +19,12 @@ const _SVGTooltipText = require("../../utilities/SVGTooltipText");
19
19
  const _ChartAnnotationLayer = require("./Annotations/ChartAnnotationLayer");
20
20
  const _ChartPopover = require("./ChartPopover");
21
21
  const _reacttabster = require("@fluentui/react-tabster");
22
+ const HORIZONTAL_MARGIN_FOR_YAXIS_TITLE = 24;
23
+ const VERTICAL_MARGIN_FOR_XAXIS_TITLE = 20;
24
+ const AXIS_TITLE_PADDING = 8;
25
+ const DEFAULT_MARGIN_WITH_TICKS = 40;
26
+ const DEFAULT_MARGIN_NO_TICKS = 20;
22
27
  const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true, ...props }, forwardedRef)=>{
23
- var _props_margins, _props_margins1, _props_margins2, _props_margins3, _props_margins4, _props_margins5;
24
28
  const chartContainer = _react.useRef(null);
25
29
  let legendContainer;
26
30
  const minLegendContainerHeight = 40;
@@ -32,7 +36,6 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
32
36
  let _reqID;
33
37
  const _useRtl = (0, _index.useRtl)();
34
38
  let _tickValues;
35
- const titleMargin = 8;
36
39
  const _isFirstRender = _react.useRef(true);
37
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
41
  let _xScale;
@@ -48,61 +51,12 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
48
51
  * These value need to be removed from actual svg height/graph height.
49
52
  * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
50
53
  */ let _removalValueForTextTuncate = 0;
54
+ const _yAxisTickText = _react.useRef([]);
51
55
  const [containerWidth, setContainerWidth] = _react.useState(0);
52
56
  const [containerHeight, setContainerHeight] = _react.useState(0);
53
57
  const [startFromX, setStartFromX] = _react.useState(0);
54
58
  const prevWidthRef = _react.useRef(undefined);
55
59
  const prevHeightRef = _react.useRef(undefined);
56
- const chartTypesWithStringYAxis = [
57
- _index.ChartTypes.HorizontalBarChartWithAxis,
58
- _index.ChartTypes.HeatMapChart,
59
- _index.ChartTypes.VerticalStackedBarChart,
60
- _index.ChartTypes.GanttChart,
61
- _index.ChartTypes.ScatterChart
62
- ];
63
- var _props_margins_top, _props_margins_bottom, _props_margins_left, _props_margins_right, _props_margins_right1, _props_margins_left1;
64
- /**
65
- * In RTL mode, Only graph will be rendered left/right. We need to provide left and right margins manually.
66
- * So that, in RTL, left margins becomes right margins and viceversa.
67
- * As graph needs to be drawn perfecty, these values consider as default values.
68
- * Same margins using for all other cartesian charts. Can be accessible through 'getMargins' call back method.
69
- */ // eslint-disable-next-line prefer-const
70
- margins = {
71
- top: (_props_margins_top = (_props_margins = props.margins) === null || _props_margins === void 0 ? void 0 : _props_margins.top) !== null && _props_margins_top !== void 0 ? _props_margins_top : 20,
72
- bottom: (_props_margins_bottom = (_props_margins1 = props.margins) === null || _props_margins1 === void 0 ? void 0 : _props_margins1.bottom) !== null && _props_margins_bottom !== void 0 ? _props_margins_bottom : 35,
73
- right: _useRtl ? (_props_margins_left = (_props_margins2 = props.margins) === null || _props_margins2 === void 0 ? void 0 : _props_margins2.left) !== null && _props_margins_left !== void 0 ? _props_margins_left : 40 : ((_props_margins_right = (_props_margins3 = props.margins) === null || _props_margins3 === void 0 ? void 0 : _props_margins3.right) !== null && _props_margins_right !== void 0 ? _props_margins_right : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20,
74
- left: _useRtl ? ((_props_margins_right1 = (_props_margins4 = props.margins) === null || _props_margins4 === void 0 ? void 0 : _props_margins4.right) !== null && _props_margins_right1 !== void 0 ? _props_margins_right1 : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20 : (_props_margins_left1 = (_props_margins5 = props.margins) === null || _props_margins5 === void 0 ? void 0 : _props_margins5.left) !== null && _props_margins_left1 !== void 0 ? _props_margins_left1 : 40
75
- };
76
- const TITLE_MARGIN_HORIZONTAL = 24;
77
- const TITLE_MARGIN_VERTICAL = 20;
78
- if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
79
- var _props_margins6;
80
- var _props_margins_bottom1;
81
- margins.bottom = (_props_margins_bottom1 = (_props_margins6 = props.margins) === null || _props_margins6 === void 0 ? void 0 : _props_margins6.bottom) !== null && _props_margins_bottom1 !== void 0 ? _props_margins_bottom1 : margins.bottom + TITLE_MARGIN_VERTICAL;
82
- }
83
- if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
84
- var _props_margins7, _props_margins8, _props_margins9, _props_margins10;
85
- var _props_margins_right2, _props_margins_left2;
86
- margins.left = _useRtl ? ((_props_margins_right2 = (_props_margins7 = props.margins) === null || _props_margins7 === void 0 ? void 0 : _props_margins7.right) !== null && _props_margins_right2 !== void 0 ? _props_margins_right2 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL : (_props_margins_left2 = (_props_margins8 = props.margins) === null || _props_margins8 === void 0 ? void 0 : _props_margins8.left) !== null && _props_margins_left2 !== void 0 ? _props_margins_left2 : margins.left + TITLE_MARGIN_HORIZONTAL;
87
- var _props_margins_left3, _props_margins_right3;
88
- margins.right = _useRtl ? (_props_margins_left3 = (_props_margins9 = props.margins) === null || _props_margins9 === void 0 ? void 0 : _props_margins9.left) !== null && _props_margins_left3 !== void 0 ? _props_margins_left3 : margins.left + TITLE_MARGIN_HORIZONTAL : ((_props_margins_right3 = (_props_margins10 = props.margins) === null || _props_margins10 === void 0 ? void 0 : _props_margins10.right) !== null && _props_margins_right3 !== void 0 ? _props_margins_right3 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL;
89
- }
90
- if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
91
- var _props_margins11;
92
- var _props_margins_top1;
93
- margins.top = (_props_margins_top1 = (_props_margins11 = props.margins) === null || _props_margins11 === void 0 ? void 0 : _props_margins11.top) !== null && _props_margins_top1 !== void 0 ? _props_margins_top1 : margins.top + TITLE_MARGIN_VERTICAL;
94
- }
95
- if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
96
- if (_useRtl) {
97
- var _props_margins12;
98
- var _props_margins_right4;
99
- margins.left = (_props_margins_right4 = (_props_margins12 = props.margins) === null || _props_margins12 === void 0 ? void 0 : _props_margins12.right) !== null && _props_margins_right4 !== void 0 ? _props_margins_right4 : margins.right + TITLE_MARGIN_HORIZONTAL;
100
- } else {
101
- var _props_margins13;
102
- var _props_margins_right5;
103
- margins.right = (_props_margins_right5 = (_props_margins13 = props.margins) === null || _props_margins13 === void 0 ? void 0 : _props_margins13.right) !== null && _props_margins_right5 !== void 0 ? _props_margins_right5 : margins.right + TITLE_MARGIN_HORIZONTAL;
104
- }
105
- }
106
60
  const classes = (0, _useCartesianChartStylesstyles.useCartesianChartStyles)(props);
107
61
  const focusAttributes = (0, _reacttabster.useFocusableGroup)();
108
62
  const arrowAttributes = (0, _reacttabster.useArrowNavigationGroup)({
@@ -111,7 +65,7 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
111
65
  // ComponentdidMount and Componentwillunmount logic
112
66
  _react.useEffect(()=>{
113
67
  _fitParentContainer();
114
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.showYAxisLables && yAxisElement && props.yAxisType === _index.YAxisType.StringAxis) {
68
+ if (props.showYAxisLables) {
115
69
  const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
116
70
  if (startFromX !== maxYAxisLabelLength) {
117
71
  setStartFromX(maxYAxisLabelLength);
@@ -136,7 +90,7 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
136
90
  // Update refs with current values
137
91
  prevWidthRef.current = props.width;
138
92
  prevHeightRef.current = props.height;
139
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.showYAxisLables && yAxisElement && props.yAxisType === _index.YAxisType.StringAxis) {
93
+ if (props.showYAxisLables) {
140
94
  const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
141
95
  if (startFromX !== maxYAxisLabelLength) {
142
96
  setStartFromX(maxYAxisLabelLength);
@@ -174,25 +128,15 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
174
128
  }
175
129
  return str;
176
130
  };
177
- return (0, _index.calculateLongestLabelWidth)(props.stringDatasetForYAxisDomain.map((label)=>formatTickLabel(label)), `.${className} text`);
131
+ return (0, _index.calculateLongestLabelWidth)(_yAxisTickText.current.map((label)=>formatTickLabel(label)), `.${className} text`);
178
132
  }
179
133
  const { calloutProps, points, chartType, svgProps, culture, dateLocalizeOptions, timeFormatLocale, customDateTimeFormatter } = props;
180
134
  if (props.parentRef) {
181
135
  _fitParentContainer();
182
136
  }
183
- const margin = {
184
- ...margins
185
- };
186
- // Note: This check is unnecessary since startFromX is only set for charts with string y-axis.
187
- if (chartTypesWithStringYAxis.includes(props.chartType)) {
188
- if (!_useRtl) {
189
- margin.left += startFromX;
190
- } else {
191
- margin.right += startFromX;
192
- }
193
- }
137
+ margins = _calcMargins();
194
138
  // Callback for margins to the chart
195
- props.getmargins && props.getmargins(margin);
139
+ props.getmargins && props.getmargins(margins);
196
140
  let callout = null;
197
141
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
142
  let yScalePrimary;
@@ -203,7 +147,7 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
203
147
  _isFirstRender.current = false;
204
148
  var _props_showRoundOffXTickValues;
205
149
  const XAxisParams = {
206
- domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues, startFromX),
150
+ domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues),
207
151
  // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
208
152
  // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
209
153
  // However, if transformation props are enabled, the updated _removalValueForTextTuncate
@@ -274,10 +218,11 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
274
218
  * 2. To draw the graph.
275
219
  * For area/line chart using same scales. For other charts, creating their own scales to draw the graph.
276
220
  */ const axisData = {
277
- yAxisDomainValues: []
221
+ yAxisDomainValues: [],
222
+ yAxisTickText: []
278
223
  };
279
224
  if (props.yAxisType && props.yAxisType === _index.YAxisType.StringAxis) {
280
- yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, props.barwidth, props.chartType);
225
+ yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, axisData, props.barwidth, props.chartType);
281
226
  } else {
282
227
  // TODO: Since the scale domain values are now computed independently for both the primary and
283
228
  // secondary y-axes, the yMinValue and yMaxValue props are no longer necessary for accurately
@@ -304,42 +249,41 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
304
249
  }
305
250
  yScalePrimary = props.createYAxis(YAxisParams, _useRtl, axisData, isIntegralDataset, chartType, false, props.roundedTicks, props.yScaleType, _useRtl);
306
251
  }
307
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.yAxisType === _index.YAxisType.StringAxis) {
308
- // Removing un wanted tooltip div from DOM, when prop not provided, for proper cleanup
309
- // of unwanted DOM elements, to prevent flacky behaviour in tooltips , that might occur
310
- // in creating tooltips when tooltips are enabled( as we try to recreate a tspan with _tooltipId)
311
- if (!props.showYAxisLablesTooltip) {
312
- try {
313
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
314
- //eslint-disable-next-line no-empty
315
- } catch (e) {}
316
- }
317
- // Used to display tooltip at y axis labels.
318
- if (props.showYAxisLablesTooltip) {
319
- // To create y axis tick values by if specified truncating the rest of the text
320
- // and showing elipsis or showing the whole string,
321
- yScalePrimary && // Note: This function should be invoked within the showYAxisLablesTooltip check,
322
- // as its sole purpose is to truncate labels that exceed the noOfCharsToTruncate limit.
323
- (0, _index.createYAxisLabels)(yAxisElement.current, yScalePrimary, props.noOfCharsToTruncate || 4, props.showYAxisLablesTooltip || false, _useRtl);
324
- const _yAxisElement = (0, _d3selection.select)(yAxisElement.current).call(yScalePrimary);
325
- try {
326
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
327
- //eslint-disable-next-line no-empty
328
- } catch (e) {}
329
- const ytooltipProps = {
330
- tooltipCls: classes.tooltip,
331
- id: _tooltipId,
332
- axis: _yAxisElement
333
- };
334
- _yAxisElement && (0, _index.tooltipOfAxislabels)(ytooltipProps);
335
- }
252
+ _yAxisTickText.current = axisData.yAxisTickText;
253
+ props.getAxisData && props.getAxisData(axisData);
254
+ // Removing un wanted tooltip div from DOM, when prop not provided, for proper cleanup
255
+ // of unwanted DOM elements, to prevent flacky behaviour in tooltips , that might occur
256
+ // in creating tooltips when tooltips are enabled( as we try to recreate a tspan with _tooltipId)
257
+ if (!props.showYAxisLablesTooltip) {
258
+ try {
259
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
260
+ //eslint-disable-next-line no-empty
261
+ } catch (e) {}
262
+ }
263
+ // Used to display tooltip at y axis labels.
264
+ if (props.showYAxisLablesTooltip) {
265
+ // To create y axis tick values by if specified truncating the rest of the text
266
+ // and showing elipsis or showing the whole string,
267
+ yScalePrimary && // Note: This function should be invoked within the showYAxisLablesTooltip check,
268
+ // as its sole purpose is to truncate labels that exceed the noOfCharsToTruncate limit.
269
+ (0, _index.createYAxisLabels)(yAxisElement.current, yScalePrimary, props.noOfCharsToTruncate || 4, props.showYAxisLablesTooltip || false, _useRtl);
270
+ const _yAxisElement = (0, _d3selection.select)(yAxisElement.current).call(yScalePrimary);
271
+ try {
272
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
273
+ //eslint-disable-next-line no-empty
274
+ } catch (e) {}
275
+ const ytooltipProps = {
276
+ tooltipCls: classes.tooltip,
277
+ id: _tooltipId,
278
+ axis: _yAxisElement
279
+ };
280
+ _yAxisElement && (0, _index.tooltipOfAxislabels)(ytooltipProps);
336
281
  }
337
282
  // Call back to the chart.
338
283
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
339
284
  const _getData = (xScale, yScalePrimary, yScaleSecondary)=>{
340
285
  props.getGraphData && props.getGraphData(xScale, yScalePrimary, containerHeight - _removalValueForTextTuncate, containerWidth, xAxisElement.current, yAxisElement.current, yScaleSecondary);
341
286
  };
342
- props.getAxisData && props.getAxisData(axisData);
343
287
  // Callback function for chart, returns axis
344
288
  _getData(xScale, yScalePrimary, yScaleSecondary);
345
289
  children = props.children({
@@ -357,11 +301,10 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
357
301
  width: containerWidth,
358
302
  height: containerHeight
359
303
  };
360
- const _startFromX = startFromX || 0;
361
- const plotWidth = Math.max(0, svgDimensions.width - margins.left - margins.right - _startFromX);
304
+ const plotWidth = Math.max(0, svgDimensions.width - margins.left - margins.right);
362
305
  const plotHeight = Math.max(0, svgDimensions.height - margins.top - margins.bottom - _removalValueForTextTuncate);
363
306
  const plotRect = {
364
- x: _useRtl ? margins.left : margins.left + _startFromX,
307
+ x: margins.left,
365
308
  y: margins.top,
366
309
  width: plotWidth,
367
310
  height: plotHeight
@@ -377,8 +320,11 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
377
320
  yScalePrimary,
378
321
  yScaleSecondary
379
322
  } : undefined;
380
- const xAxisTitleMaximumAllowedWidth = svgDimensions.width - margins.left - margins.right - startFromX;
381
- const yAxisTitleMaximumAllowedHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - titleMargin;
323
+ const xAxisTitleMaxWidth = svgDimensions.width - margins.left - margins.right - AXIS_TITLE_PADDING * 2;
324
+ const yAxisTitleMaxHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - AXIS_TITLE_PADDING * 2;
325
+ const yAxisTitleCenterY = margins.top + AXIS_TITLE_PADDING + yAxisTitleMaxHeight / 2;
326
+ const yAxisTitleCenterX = _useRtl ? svgDimensions.width - AXIS_TITLE_PADDING : HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING;
327
+ const secondaryYAxisTitleCenterX = _useRtl ? HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING : svgDimensions.width - AXIS_TITLE_PADDING;
382
328
  const commonSvgToolTipProps = {
383
329
  wrapContent: _index.wrapContent,
384
330
  showBackground: true,
@@ -498,6 +444,64 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
498
444
  _removalValueForTextTuncate = rotatedHeight + margins.bottom;
499
445
  }
500
446
  }
447
+ function _calcMargins() {
448
+ let _margins = _getDefaultMargins();
449
+ _margins = _applyTitleMargins(_margins);
450
+ _margins = _applyAnnotationMargins(_margins);
451
+ if (_useRtl) {
452
+ _margins = _swapRtlMargins(_margins);
453
+ }
454
+ return {
455
+ ..._margins,
456
+ ...props.margins
457
+ };
458
+ }
459
+ function _getDefaultMargins() {
460
+ return {
461
+ top: DEFAULT_MARGIN_NO_TICKS,
462
+ // Smaller than the default because it is based on the line height rather than
463
+ // the length of the tick labels.
464
+ bottom: DEFAULT_MARGIN_WITH_TICKS - 5,
465
+ // For the actual margin, add the tick size, tick padding, and some extra space to
466
+ // the width of the longest yaxis tick label (startFromX).
467
+ left: Math.max(DEFAULT_MARGIN_WITH_TICKS, startFromX + 20),
468
+ right: props.secondaryYScaleOptions ? DEFAULT_MARGIN_WITH_TICKS : DEFAULT_MARGIN_NO_TICKS
469
+ };
470
+ }
471
+ function _applyTitleMargins(_margins) {
472
+ const updated = {
473
+ ..._margins
474
+ };
475
+ if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
476
+ updated.bottom += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
477
+ }
478
+ if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
479
+ updated.left += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
480
+ }
481
+ if (props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '') {
482
+ updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
483
+ }
484
+ return updated;
485
+ }
486
+ function _applyAnnotationMargins(_margins) {
487
+ const updated = {
488
+ ..._margins
489
+ };
490
+ if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
491
+ updated.top += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
492
+ }
493
+ if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
494
+ updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
495
+ }
496
+ return updated;
497
+ }
498
+ function _swapRtlMargins(_margins) {
499
+ return {
500
+ ..._margins,
501
+ left: _margins.right,
502
+ right: _margins.left
503
+ };
504
+ }
501
505
  /**
502
506
  * We have use the {@link defaultTabbableElement } to fix
503
507
  * the Focus not landing on chart while tabbing, instead goes to legend.
@@ -549,74 +553,71 @@ const CartesianChart = /*#__PURE__*/ _react.forwardRef(({ hideTickOverlap = true
549
553
  ...commonSvgToolTipProps,
550
554
  content: props.xAxisTitle,
551
555
  textProps: {
552
- x: margins.left + startFromX + xAxisTitleMaximumAllowedWidth / 2,
553
- y: svgDimensions.height - titleMargin,
556
+ x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
557
+ y: svgDimensions.height - AXIS_TITLE_PADDING,
554
558
  className: classes.axisTitle,
555
559
  textAnchor: 'middle'
556
560
  },
557
- maxWidth: xAxisTitleMaximumAllowedWidth
561
+ maxWidth: xAxisTitleMaxWidth
558
562
  }), props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '' && /*#__PURE__*/ _react.createElement(_SVGTooltipText.SVGTooltipText, {
559
563
  ...commonSvgToolTipProps,
560
564
  content: props.xAxisAnnotation,
561
565
  textProps: {
562
- x: margins.left + startFromX + xAxisTitleMaximumAllowedWidth / 2,
563
- y: titleMargin + 3,
566
+ x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
567
+ y: VERTICAL_MARGIN_FOR_XAXIS_TITLE - AXIS_TITLE_PADDING,
564
568
  className: classes.axisAnnotation,
565
569
  textAnchor: 'middle',
566
570
  'aria-hidden': true
567
571
  },
568
- maxWidth: xAxisTitleMaximumAllowedWidth
572
+ maxWidth: xAxisTitleMaxWidth
569
573
  }), /*#__PURE__*/ _react.createElement("g", {
570
574
  ref: (e)=>{
571
575
  yAxisElement.current = e;
572
576
  },
573
577
  id: `yAxisGElement${idForGraph}`,
574
- transform: `translate(${_useRtl ? svgDimensions.width - margins.right - startFromX : margins.left + startFromX}, 0)`,
578
+ transform: `translate(${_useRtl ? svgDimensions.width - margins.right : margins.left}, 0)`,
575
579
  className: classes.yAxis
576
580
  }), props.secondaryYScaleOptions && /*#__PURE__*/ _react.createElement("g", null, /*#__PURE__*/ _react.createElement("g", {
577
581
  ref: (e)=>{
578
582
  yAxisElementSecondary.current = e;
579
583
  },
580
584
  id: `yAxisGElementSecondary${idForGraph}`,
581
- transform: `translate(${_useRtl ? margins.left + startFromX : svgDimensions.width - margins.right - startFromX}, 0)`,
585
+ transform: `translate(${_useRtl ? margins.left : svgDimensions.width - margins.right}, 0)`,
582
586
  className: classes.yAxis
583
587
  }), props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '' && /*#__PURE__*/ _react.createElement(_SVGTooltipText.SVGTooltipText, {
584
588
  ...commonSvgToolTipProps,
585
589
  content: props.secondaryYAxistitle,
586
590
  textProps: {
587
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
588
- y: _useRtl ? startFromX - titleMargin : svgDimensions.width - margins.right,
591
+ x: secondaryYAxisTitleCenterX,
592
+ y: yAxisTitleCenterY,
589
593
  textAnchor: 'middle',
590
- transform: `translate(${_useRtl ? margins.right / 2 - titleMargin : margins.right / 2 + titleMargin},
591
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
594
+ transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
592
595
  className: classes.axisTitle
593
596
  },
594
- maxWidth: yAxisTitleMaximumAllowedHeight
597
+ maxWidth: yAxisTitleMaxHeight
595
598
  })), children, props.yAxisTitle !== undefined && props.yAxisTitle !== '' && /*#__PURE__*/ _react.createElement(_SVGTooltipText.SVGTooltipText, {
596
599
  ...commonSvgToolTipProps,
597
600
  content: props.yAxisTitle,
598
601
  textProps: {
599
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
600
- y: _useRtl ? svgDimensions.width - margins.right / 2 + titleMargin : margins.left / 2 - titleMargin,
602
+ x: yAxisTitleCenterX,
603
+ y: yAxisTitleCenterY,
601
604
  textAnchor: 'middle',
602
- transform: `translate(0,
603
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
605
+ transform: `rotate(-90, ${yAxisTitleCenterX}, ${yAxisTitleCenterY})`,
604
606
  className: classes.axisTitle
605
607
  },
606
- maxWidth: yAxisTitleMaximumAllowedHeight
608
+ maxWidth: yAxisTitleMaxHeight
607
609
  }), props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '') && /*#__PURE__*/ _react.createElement(_SVGTooltipText.SVGTooltipText, {
608
610
  ...commonSvgToolTipProps,
609
611
  content: props.yAxisAnnotation,
610
612
  textProps: {
611
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
612
- y: _useRtl ? startFromX - titleMargin : svgDimensions.width - margins.right,
613
+ x: secondaryYAxisTitleCenterX,
614
+ y: yAxisTitleCenterY,
613
615
  textAnchor: 'middle',
614
- transform: `translate(${_useRtl ? margins.right / 2 - titleMargin : margins.right / 2 + titleMargin},
615
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
616
+ transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
616
617
  className: classes.axisAnnotation,
617
618
  'aria-hidden': true
618
619
  },
619
- maxWidth: yAxisTitleMaximumAllowedHeight
620
+ maxWidth: yAxisTitleMaxHeight
620
621
  })), hasAnnotations && annotationContext && /*#__PURE__*/ _react.createElement(_ChartAnnotationLayer.ChartAnnotationLayer, {
621
622
  annotations: annotations,
622
623
  context: annotationContext,