@fluentui/react-charts 9.2.1 → 9.2.3

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 (201) hide show
  1. package/CHANGELOG.md +57 -2
  2. package/dist/index.d.ts +168 -15
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js +4 -1
  6. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  9. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  10. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  11. package/lib/components/ChartTable/ChartTable.js +58 -0
  12. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  13. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  14. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  15. package/lib/components/ChartTable/index.js +3 -0
  16. package/lib/components/ChartTable/index.js.map +1 -0
  17. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  18. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  19. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  20. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  21. package/lib/components/CommonComponents/CartesianChart.js +170 -100
  22. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  23. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  24. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  25. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  26. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  27. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  28. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  29. package/lib/components/DeclarativeChart/DeclarativeChart.js +180 -102
  30. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  31. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +100 -0
  32. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +890 -211
  34. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  35. package/lib/components/DonutChart/DonutChart.js +2 -2
  36. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  37. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  38. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  39. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  40. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  41. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  42. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  43. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  44. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  45. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +185 -144
  46. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  47. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  48. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  49. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  50. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  51. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  52. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  53. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  54. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  55. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  56. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  57. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  58. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  59. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  60. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  61. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  62. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  63. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  64. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  65. package/lib/components/Legends/Legends.js.map +1 -1
  66. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  67. package/lib/components/LineChart/LineChart.js +251 -78
  68. package/lib/components/LineChart/LineChart.js.map +1 -1
  69. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  70. package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
  71. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  72. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  73. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  74. package/lib/components/ScatterChart/ScatterChart.js +56 -37
  75. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  76. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  77. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  78. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  79. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  80. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  81. package/lib/components/VerticalBarChart/VerticalBarChart.js +38 -14
  82. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  83. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  84. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  85. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  86. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  87. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +214 -96
  88. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  89. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  90. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  91. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  92. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  93. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  94. package/lib/index.js +1 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/types/DataPoint.js.map +1 -1
  97. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  98. package/lib/utilities/utilities.js +41 -42
  99. package/lib/utilities/utilities.js.map +1 -1
  100. package/lib/utilities/vbc-utils.js +24 -0
  101. package/lib/utilities/vbc-utils.js.map +1 -1
  102. package/lib-commonjs/ChartTable.js +6 -0
  103. package/lib-commonjs/ChartTable.js.map +1 -0
  104. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  105. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  106. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  107. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  109. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/ChartTable/ChartTable.js +69 -0
  111. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  112. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  113. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  114. package/lib-commonjs/components/ChartTable/index.js +8 -0
  115. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  116. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  117. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  118. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  119. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  120. package/lib-commonjs/components/CommonComponents/CartesianChart.js +169 -98
  121. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  122. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  123. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  124. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  125. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  127. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +176 -100
  129. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  130. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +128 -0
  131. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  132. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +909 -209
  133. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  134. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
  135. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  136. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  137. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  138. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  139. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  140. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  141. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  142. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  143. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  144. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +183 -142
  145. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  146. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  147. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  148. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  149. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  151. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  152. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  153. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  154. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  155. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  156. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  157. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  158. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  159. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  160. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  161. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  162. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  163. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  164. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  165. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  166. package/lib-commonjs/components/LineChart/LineChart.js +250 -78
  167. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  168. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  169. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
  170. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  171. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
  172. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  173. package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
  174. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  175. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  176. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  177. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  178. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  179. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  180. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +37 -13
  181. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  182. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  183. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  184. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  185. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  186. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +213 -95
  187. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  188. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  189. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  190. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  191. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  192. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  193. package/lib-commonjs/index.js +1 -0
  194. package/lib-commonjs/index.js.map +1 -1
  195. package/lib-commonjs/types/DataPoint.js.map +1 -1
  196. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  197. package/lib-commonjs/utilities/utilities.js +44 -41
  198. package/lib-commonjs/utilities/utilities.js.map +1 -1
  199. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  200. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  201. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/GanttChart/useGanttChartStyles.styles.ts"],"sourcesContent":["import { GanttChartStyles, GanttChartProps } from '../../index';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nexport const ganttClassNames: SlotClassNames<GanttChartStyles> = {\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n tooltip: '',\n axisTitle: '',\n chartTitle: '',\n opacityChangeOnHover: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n};\n\n/**\n * Apply styling to the GanttChart component\n */\nexport const useGanttChartStyles = (props: GanttChartProps): GanttChartStyles => {\n return {};\n};\n"],"names":["ganttClassNames","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","tooltip","axisTitle","chartTitle","opacityChangeOnHover","shapeStyles","chartWrapper","svgTooltip","chart","useGanttChartStyles","props"],"mappings":"AAGA;;CAEC,GACD;;;;;;;;;;;mBAAaA;;;uBAoBAe;;;;AApBN,MAAMf,kBAAoD;IAC/DC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,sBAAsB;IACtBC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;AACT,EAAE;AAKK,MAAMC,sBAAsB,CAACC;IAClC,OAAO,CAAC;AACV,EAAE"}
1
+ {"version":3,"sources":["../src/components/GanttChart/useGanttChartStyles.styles.ts"],"sourcesContent":["import { GanttChartStyles, GanttChartProps } from '../../index';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nexport const ganttClassNames: SlotClassNames<GanttChartStyles> = {\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n tooltip: '',\n axisTitle: '',\n chartTitle: '',\n opacityChangeOnHover: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n axisAnnotation: '',\n};\n\n/**\n * Apply styling to the GanttChart component\n */\nexport const useGanttChartStyles = (props: GanttChartProps): GanttChartStyles => {\n return {};\n};\n"],"names":["ganttClassNames","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","tooltip","axisTitle","chartTitle","opacityChangeOnHover","shapeStyles","chartWrapper","svgTooltip","chart","axisAnnotation","useGanttChartStyles","props"],"mappings":"AAGA;;CAEC,GACD;;;;;;;;;;;mBAAaA;;;uBAqBAgB;;;;AArBN,MAAMhB,kBAAoD;IAC/DC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,SAAS;IACTC,WAAW;IACXC,YAAY;IACZC,sBAAsB;IACtBC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,gBAAgB;AAClB,EAAE;AAKK,MAAMC,sBAAsB,CAACC;IAClC,OAAO,CAAC;AACV,EAAE"}
@@ -20,20 +20,17 @@ const _index1 = require("../../index");
20
20
  const _imageexportutils = require("../../utilities/image-export-utils");
21
21
  const MIN_DOMAIN_MARGIN = 8;
22
22
  const X1_INNER_PADDING = 0.1;
23
- // x1_inner_padding = space_between_bars / (space_between_bars + bar_width)
24
- // => space_between_bars = (x1_inner_padding / (1 - x1_inner_padding)) * bar_width
25
- /** Rate at which the space between the bars in a group changes wrt the bar width */ const BAR_GAP_RATE = X1_INNER_PADDING / (1 - X1_INNER_PADDING);
26
23
  const VERTICAL_BAR_GAP = 1;
27
24
  const MIN_BAR_HEIGHT = 1;
28
25
  const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
29
- maxBarWidth: 24
26
+ maxBarWidth: 24,
27
+ xAxisCategoryOrder: 'default'
30
28
  }, forwardedRef)=>{
31
29
  var _props_legendProps, _props_legendProps1;
32
30
  const _tooltipId = (0, _reactutilities.useId)('GVBCTooltipId_');
33
31
  const _emptyChartId = (0, _reactutilities.useId)('_GVBC_empty');
34
32
  const _useRtl = (0, _index.useRtl)();
35
33
  let _domainMargin = MIN_DOMAIN_MARGIN;
36
- let _keys = [];
37
34
  let _xAxisLabels = [];
38
35
  let _datasetForBars = [];
39
36
  let _margins = {
@@ -43,13 +40,14 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
43
40
  left: 0
44
41
  };
45
42
  let _groupedVerticalBarGraph = [];
46
- let _refArray = [];
47
43
  let _yMax = 0;
48
44
  let _calloutAnchorPoint = null;
49
45
  let _barWidth = 0;
50
46
  let _groupWidth = 0;
51
47
  let _xAxisInnerPadding = 0;
52
48
  let _xAxisOuterPadding = 0;
49
+ let _legends = [];
50
+ let _legendColorMap = {};
53
51
  const cartesianChartRef = _react.useRef(null);
54
52
  const Y_ORIGIN = 0;
55
53
  const _legendsRef = _react.useRef(null);
@@ -93,44 +91,53 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
93
91
  _barWidth = (0, _index.getBarWidth)(props.barWidth, props.maxBarWidth);
94
92
  // x0_inner_padding = space_between_groups / (space_between_groups + group_width)
95
93
  // space_between_groups = 2 * bar_width
96
- // group_width = keys.length * bar_width + (keys.length - 1) * space_between_bars
97
- _xAxisInnerPadding = (0, _index.getScalePadding)(props.xAxisInnerPadding, undefined, 2 / (2 + keys.length + (keys.length - 1) * BAR_GAP_RATE));
94
+ // group_width = _legends.length * bar_width + (_legends.length - 1) * space_between_bars
95
+ _xAxisInnerPadding = (0, _index.getScalePadding)(props.xAxisInnerPadding, undefined, 2 / (2 + (0, _index.calcTotalBandUnits)(_legends.length, X1_INNER_PADDING)));
98
96
  _xAxisOuterPadding = (0, _index.getScalePadding)(props.xAxisOuterPadding);
99
97
  };
100
98
  const _createDataset = (points)=>{
101
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
100
  const datasetForBars = [];
103
- const dataset = [];
104
101
  points.forEach((point, index)=>{
105
- const singleDatasetPoint = {};
106
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
107
103
  const singleDatasetPointForBars = {};
108
- const singleDataSeries = [];
109
- point.series.forEach((seriesPoint, seriesIndex)=>{
110
- singleDatasetPoint[seriesPoint.key] = seriesPoint.data;
111
- singleDatasetPointForBars[seriesPoint.key] = {
112
- ...seriesPoint
113
- };
114
- singleDataSeries.push(seriesPoint);
104
+ const legendToBarPoint = {};
105
+ point.series.forEach((seriesPoint)=>{
106
+ if (!singleDatasetPointForBars[seriesPoint.legend]) {
107
+ singleDatasetPointForBars[seriesPoint.legend] = [
108
+ {
109
+ ...seriesPoint
110
+ }
111
+ ];
112
+ legendToBarPoint[seriesPoint.legend] = {
113
+ ...seriesPoint
114
+ };
115
+ } else {
116
+ singleDatasetPointForBars[seriesPoint.legend].push({
117
+ ...seriesPoint
118
+ });
119
+ legendToBarPoint[seriesPoint.legend].data += seriesPoint.data;
120
+ }
115
121
  });
116
122
  singleDatasetPointForBars.xAxisPoint = point.name;
117
123
  singleDatasetPointForBars.indexNum = index;
118
- singleDatasetPointForBars.groupSeries = singleDataSeries;
124
+ singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
119
125
  singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
120
126
  datasetForBars.push(singleDatasetPointForBars);
121
- dataset.push(singleDatasetPoint);
122
127
  });
123
128
  return datasetForBars;
124
129
  };
125
130
  const _createDataSetOfGVBC = (points)=>{
126
- const keys = [];
127
- const xAxisLabels = points.map((singlePoint)=>singlePoint.name);
128
- points[0].series.forEach((singleKey)=>{
129
- keys.push(singleKey.key);
131
+ const legends = new Set();
132
+ const xAxisLabels = _getOrderedXAxisLabels(points);
133
+ points.forEach((point)=>{
134
+ point.series.forEach((seriesPoint)=>{
135
+ legends.add(seriesPoint.legend);
136
+ });
130
137
  });
131
138
  const datasetForBars = _createDataset(points);
132
139
  return {
133
- keys,
140
+ legends: Array.from(legends),
134
141
  xAxisLabels,
135
142
  datasetForBars
136
143
  };
@@ -146,36 +153,22 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
146
153
  props.legendProps.onChange(selectedLegends, event, currentLegend);
147
154
  }
148
155
  };
156
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
149
157
  const _getLegendData = (points)=>{
150
- const data = points;
151
- const defaultPalette = [
152
- (0, _index1.getColorFromToken)(_index1.DataVizPalette.color1),
153
- (0, _index1.getColorFromToken)(_index1.DataVizPalette.color2),
154
- (0, _index1.getColorFromToken)(_index1.DataVizPalette.color3),
155
- (0, _index1.getColorFromToken)(_index1.DataVizPalette.color4),
156
- (0, _index1.getColorFromToken)(_index1.DataVizPalette.color5)
157
- ];
158
158
  const actions = [];
159
- data.forEach((singleChartData)=>{
160
- singleChartData.series.forEach((point)=>{
161
- let color = point.color ? point.color : defaultPalette[Math.floor(Math.random() * 4 + 1)];
162
- const checkSimilarLegends = actions.filter((leg)=>leg.title === point.legend && leg.color === color);
163
- if (checkSimilarLegends.length > 0) {
164
- return;
159
+ _legends.forEach((legendTitle)=>{
160
+ const legend = {
161
+ title: legendTitle,
162
+ color: _legendColorMap[legendTitle][0],
163
+ hoverAction: ()=>{
164
+ _handleChartMouseLeave();
165
+ _onLegendHover(legendTitle);
166
+ },
167
+ onMouseOutAction: ()=>{
168
+ _onLegendLeave();
165
169
  }
166
- const legend = {
167
- title: point.legend,
168
- color,
169
- hoverAction: ()=>{
170
- _handleChartMouseLeave();
171
- _onLegendHover(point.legend);
172
- },
173
- onMouseOutAction: ()=>{
174
- _onLegendLeave();
175
- }
176
- };
177
- actions.push(legend);
178
- });
170
+ };
171
+ actions.push(legend);
179
172
  });
180
173
  return /*#__PURE__*/ _react.createElement(_index1.Legends, {
181
174
  legends: actions,
@@ -186,13 +179,60 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
186
179
  legendRef: _legendsRef
187
180
  });
188
181
  };
189
- const points = props.data;
190
- const { keys, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(points);
191
- _keys = keys;
182
+ const _addDefaultColors = (data)=>{
183
+ _legendColorMap = {};
184
+ let colorIndex = 0;
185
+ var _data_map;
186
+ return (_data_map = data === null || data === void 0 ? void 0 : data.map((point)=>{
187
+ var _point_series;
188
+ var _point_series_map;
189
+ return {
190
+ ...point,
191
+ series: (_point_series_map = (_point_series = point.series) === null || _point_series === void 0 ? void 0 : _point_series.map((seriesPoint)=>{
192
+ // TODO: Add support for gradient colors
193
+ let startColor = seriesPoint.color ? seriesPoint.color : (0, _index.getNextColor)(colorIndex, 0);
194
+ let endColor = startColor;
195
+ if (!_legendColorMap[seriesPoint.legend]) {
196
+ _legendColorMap[seriesPoint.legend] = [
197
+ startColor,
198
+ endColor
199
+ ];
200
+ }
201
+ colorIndex += 1;
202
+ var _seriesPoint_color;
203
+ return {
204
+ ...seriesPoint,
205
+ color: (_seriesPoint_color = seriesPoint.color) !== null && _seriesPoint_color !== void 0 ? _seriesPoint_color : _legendColorMap[seriesPoint.legend][0]
206
+ };
207
+ })) !== null && _point_series_map !== void 0 ? _point_series_map : []
208
+ };
209
+ })) !== null && _data_map !== void 0 ? _data_map : [];
210
+ };
211
+ const _getOrderedXAxisLabels = (points)=>{
212
+ if (_xAxisType !== _index.XAxisTypes.StringAxis) {
213
+ return [];
214
+ }
215
+ return (0, _index.sortAxisCategories)(_mapCategoryToValues(points), props.xAxisCategoryOrder);
216
+ };
217
+ const _mapCategoryToValues = (points)=>{
218
+ const categoryToValues = {};
219
+ points.forEach((point)=>{
220
+ if (!categoryToValues[point.name]) {
221
+ categoryToValues[point.name] = [];
222
+ }
223
+ point.series.forEach((seriesPoint)=>{
224
+ categoryToValues[point.name].push(seriesPoint.data);
225
+ });
226
+ });
227
+ return categoryToValues;
228
+ };
229
+ const points = _addDefaultColors(props.data);
230
+ const _xAxisType = (0, _index.getTypeOfAxis)(points[0].name, true);
231
+ const { legends, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(points);
232
+ _legends = legends;
192
233
  _xAxisLabels = xAxisLabels;
193
234
  _datasetForBars = datasetForBars;
194
- const _xAxisType = (0, _index.getTypeOfAxis)(points[0].name, true);
195
- const legends = _getLegendData(points);
235
+ const legendBars = _getLegendData(points);
196
236
  _adjustProps();
197
237
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Add commentMore actions
198
238
  function _getMinMaxOfYAxis(datasetForBars, yAxisType, useSecondaryYScale) {
@@ -252,8 +292,8 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
252
292
  const xScale0 = _createX0Scale(containerWidth);
253
293
  // Setting the bar width here is safe because there are no dependencies earlier in the code
254
294
  // that rely on the width of bars in vertical bar charts with string x-axis.
255
- _barWidth = (0, _index.getBarWidth)(props.barWidth, props.maxBarWidth, xScale0.bandwidth() / (_keys.length + (_keys.length - 1) * BAR_GAP_RATE));
256
- _groupWidth = (_keys.length + (_keys.length - 1) * BAR_GAP_RATE) * _barWidth;
295
+ _barWidth = (0, _index.getBarWidth)(props.barWidth, props.maxBarWidth, (0, _index.calcBandwidth)(xScale0.bandwidth(), _legends.length, X1_INNER_PADDING));
296
+ _groupWidth = (0, _index.calcRequiredWidth)(_barWidth, _legends.length, X1_INNER_PADDING);
257
297
  const xScale1 = _createX1Scale();
258
298
  const allGroupsBars = [];
259
299
  _datasetForBars.forEach((singleSet)=>{
@@ -264,10 +304,6 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
264
304
  const _getMargins = (margins)=>{
265
305
  _margins = margins;
266
306
  };
267
- const _getOpacity = (legendTitle)=>{
268
- const opacity = _legendHighlighted(legendTitle) || _noLegendHighlighted() ? '' : '0.1';
269
- return opacity;
270
- };
271
307
  function updatePosition(newX, newY) {
272
308
  const threshold = 1; // Set a threshold for movement
273
309
  const { x, y } = clickPosition;
@@ -304,93 +340,99 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
304
340
  _calloutAnchorPoint = null;
305
341
  setPopoverOpen(false);
306
342
  };
307
- const onBarFocus = (event, pointData, groupData, refArrayIndexNumber)=>{
343
+ const onBarFocus = (event, pointData, groupData)=>{
308
344
  let x = 0;
309
345
  let y = 0;
310
346
  const targetRect = event.target.getBoundingClientRect();
311
347
  x = targetRect.left + targetRect.width / 2;
312
348
  y = targetRect.top + targetRect.height / 2;
313
349
  updatePosition(x, y);
314
- _refArray.forEach((obj, index)=>{
315
- if (obj.index === pointData.legend && refArrayIndexNumber === index) {
316
- setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
317
- setCalloutLegend(pointData.legend);
318
- setDataForHoverCard(pointData.data);
319
- setColor(pointData.color);
320
- setXCalloutValue(pointData.xAxisCalloutData);
321
- setYCalloutValue(pointData.yAxisCalloutData);
322
- setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
323
- setYValueHover(groupData.groupSeries);
324
- setHoverXValue(pointData.xAxisCalloutData);
325
- }
326
- });
327
- };
328
- const _refCallback = (element, legendTitle, refIndexNumber)=>{
329
- _refArray[refIndexNumber] = {
330
- index: legendTitle,
331
- refElement: element
332
- };
350
+ setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
351
+ setCalloutLegend(pointData.legend);
352
+ setDataForHoverCard(pointData.data);
353
+ setColor(pointData.color);
354
+ setXCalloutValue(pointData.xAxisCalloutData);
355
+ setYCalloutValue(pointData.yAxisCalloutData);
356
+ setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
357
+ setYValueHover(groupData.groupSeries);
358
+ setHoverXValue(pointData.xAxisCalloutData);
333
359
  };
334
360
  const _buildGraph = (singleSet, xScale0, xScale1, yScalePrimary, yScaleSecondary, containerHeight, xElement)=>{
361
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
335
362
  const singleGroup = [];
363
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
336
364
  const barLabelsForGroup = [];
337
- const tempDataSet = Object.keys(datasetForBars[0]).splice(0, keys.length);
338
- tempDataSet.forEach((datasetKey, index)=>{
339
- const refIndexNumber = singleSet.indexNum * tempDataSet.length + index;
340
- const pointData = singleSet[datasetKey];
341
- const yBarScale = pointData.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
342
- if (pointData) {
343
- // To align the centers of the generated bandwidth and the calculated one when they differ,
344
- // use the following addend.
345
- const xPoint = xScale1(datasetKey) + (xScale1.bandwidth() - _barWidth) / 2;
346
- const startColor = pointData.color ? pointData.color : (0, _index.getNextColor)(index, 0);
365
+ // Get the actual legends present at this x-axis point
366
+ const presentLegends = Object.keys(singleSet).filter((key)=>key in _legendColorMap);
367
+ const effectiveGroupWidth = (0, _index.calcRequiredWidth)(_barWidth, presentLegends.length, X1_INNER_PADDING);
368
+ // For stacked bars, center the single bar group in the available space
369
+ // Instead of using the global legend position, use the local position within present legends
370
+ const localScale = (0, _d3scale.scaleBand)().domain(presentLegends).range(_useRtl ? [
371
+ effectiveGroupWidth,
372
+ 0
373
+ ] : [
374
+ 0,
375
+ effectiveGroupWidth
376
+ ]).paddingInner(X1_INNER_PADDING);
377
+ _legends.forEach((legendTitle, legendIndex)=>{
378
+ const barPoints = singleSet[legendTitle];
379
+ if (barPoints) {
380
+ const yBarScale = barPoints[0].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
381
+ var _localScale;
382
+ const xPoint = ((_localScale = localScale(legendTitle)) !== null && _localScale !== void 0 ? _localScale : 0) + (localScale.bandwidth() - _barWidth) / 2;
383
+ const isLegendActive = _legendHighlighted(legendTitle) || _noLegendHighlighted();
384
+ const barOpacity = isLegendActive ? '' : '0.1';
385
+ let barTotalValue = 0;
347
386
  const yBaseline = yBarScale(Y_ORIGIN);
348
387
  let yPositiveStart = yBaseline;
349
388
  let yNegativeStart = yBaseline;
350
389
  let yPoint = Y_ORIGIN;
351
- const barGap = VERTICAL_BAR_GAP / 2 * (index > 0 ? 2 : 0);
352
- const height = Math.max(yBarScale(Y_ORIGIN) - yBarScale(Math.abs(pointData.data)), MIN_BAR_HEIGHT);
353
- if (pointData.data >= Y_ORIGIN) {
354
- yPositiveStart -= height + barGap;
355
- yPoint = yPositiveStart;
356
- } else {
357
- yPoint = yNegativeStart + barGap;
358
- yNegativeStart = yPoint + height;
359
- }
360
- // Not rendering data with 0.
361
- pointData.data && singleGroup.push(/*#__PURE__*/ _react.createElement(_react.Fragment, {
362
- key: `${singleSet.indexNum}-${index}`
363
- }, /*#__PURE__*/ _react.createElement("rect", {
364
- className: classes.opacityChangeOnHover,
365
- height: height,
366
- width: _barWidth,
367
- x: xPoint,
368
- y: yPoint,
369
- opacity: _getOpacity(pointData.legend),
370
- ref: (e)=>{
371
- _refCallback(e, pointData.legend, refIndexNumber);
372
- },
373
- fill: startColor,
374
- rx: 0,
375
- onMouseOver: (event)=>onBarHover(pointData, singleSet, event),
376
- onMouseMove: (event)=>onBarHover(pointData, singleSet, event),
377
- onMouseOut: _onBarLeave,
378
- onFocus: (event)=>onBarFocus(event, pointData, singleSet, refIndexNumber),
379
- onBlur: _onBarLeave,
380
- onClick: pointData.onClick,
381
- "aria-label": getAriaLabel(pointData, singleSet.xAxisPoint),
382
- tabIndex: _legendHighlighted(pointData.legend) || _noLegendHighlighted() ? 0 : undefined,
383
- role: "img"
384
- })));
385
- if (pointData.data && !props.hideLabels && _barWidth >= 16 && (_legendHighlighted(pointData.legend) || _noLegendHighlighted())) {
390
+ barPoints.forEach((pointData, pointIndex)=>{
391
+ if (!pointData.data) {
392
+ // Not rendering data with 0.
393
+ return;
394
+ }
395
+ const barGap = VERTICAL_BAR_GAP / 2 * (pointIndex > 0 ? 2 : 0);
396
+ const height = Math.max(yBarScale(Y_ORIGIN) - yBarScale(Math.abs(pointData.data)), MIN_BAR_HEIGHT);
397
+ const pointColor = pointData.color; // Use the color of the current point
398
+ if (pointData.data >= Y_ORIGIN) {
399
+ yPositiveStart -= height + barGap;
400
+ yPoint = yPositiveStart;
401
+ } else {
402
+ yPoint = yNegativeStart + barGap;
403
+ yNegativeStart = yPoint + height;
404
+ }
405
+ singleGroup.push(/*#__PURE__*/ _react.createElement("rect", {
406
+ key: `${singleSet.indexNum}-${legendIndex}-${pointIndex}`,
407
+ className: classes.opacityChangeOnHover,
408
+ height: height,
409
+ width: _barWidth,
410
+ x: xPoint,
411
+ y: yPoint,
412
+ opacity: barOpacity,
413
+ fill: pointColor,
414
+ rx: 0,
415
+ onMouseOver: (event)=>onBarHover(pointData, singleSet, event),
416
+ onMouseMove: (event)=>onBarHover(pointData, singleSet, event),
417
+ onMouseOut: _onBarLeave,
418
+ onFocus: (event)=>onBarFocus(event, pointData, singleSet),
419
+ onBlur: _onBarLeave,
420
+ onClick: pointData.onClick,
421
+ "aria-label": getAriaLabel(pointData, singleSet.xAxisPoint),
422
+ tabIndex: _legendHighlighted(pointData.legend) || _noLegendHighlighted() ? 0 : undefined,
423
+ role: "img"
424
+ }));
425
+ barTotalValue += pointData.data;
426
+ });
427
+ if (barTotalValue !== null && !props.hideLabels && _barWidth >= 16 && isLegendActive) {
386
428
  barLabelsForGroup.push(/*#__PURE__*/ _react.createElement("text", {
387
- key: `${singleSet.indexNum}-${index}`,
429
+ key: `${singleSet.indexNum}-${legendIndex}`,
388
430
  x: xPoint + _barWidth / 2,
389
- y: pointData.data >= Y_ORIGIN ? yPositiveStart - 6 : yNegativeStart + 12,
431
+ y: barTotalValue >= Y_ORIGIN ? yPositiveStart - 6 : yNegativeStart + 12,
390
432
  textAnchor: "middle",
391
433
  className: classes.barLabel,
392
434
  "aria-hidden": true
393
- }, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(pointData.data) : (0, _index.formatScientificLimitWidth)(pointData.data)));
435
+ }, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(barTotalValue) : (0, _index.formatScientificLimitWidth)(barTotalValue)));
394
436
  }
395
437
  }
396
438
  });
@@ -410,7 +452,7 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
410
452
  }
411
453
  return /*#__PURE__*/ _react.createElement("g", {
412
454
  key: singleSet.indexNum,
413
- transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() - _groupWidth) / 2}, 0)`
455
+ transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() - effectiveGroupWidth) / 2}, 0)`
414
456
  }, singleGroup, barLabelsForGroup);
415
457
  };
416
458
  // For grouped vertical bar chart, First need to define total scale (from start to end)
@@ -427,7 +469,7 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
427
469
  };
428
470
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
429
471
  const _createX1Scale = ()=>{
430
- return (0, _d3scale.scaleBand)().domain(keys) // When there is only one group, xScale0 adds padding around it,
472
+ return (0, _d3scale.scaleBand)().domain(_legends) // When there is only one group, xScale0 adds padding around it,
431
473
  // causing the bandwidth to become smaller than the actual group width.
432
474
  // So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
433
475
  .range(_useRtl ? [
@@ -478,8 +520,7 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
478
520
  return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
479
521
  };
480
522
  const _getDomainMargins = (containerWidth)=>{
481
- /** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
482
- /** Rate at which the space between the groups changes wrt the group width */ const groupGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
523
+ /** Total width available to render the bars */ const totalWidth = (0, _index.calcTotalWidth)(containerWidth, _margins, MIN_DOMAIN_MARGIN);
483
524
  if (_xAxisType === _index.XAxisTypes.StringAxis) {
484
525
  if ((0, _index.isScalePaddingDefined)(props.xAxisOuterPadding)) {
485
526
  // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
@@ -489,19 +530,19 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
489
530
  // Update the bar width so that when CartesianChart rerenders,
490
531
  // the following calculations don't use the previous bar width.
491
532
  _barWidth = (0, _index.getBarWidth)(props.barWidth, props.maxBarWidth);
492
- const groupWidth = (keys.length + (keys.length - 1) * BAR_GAP_RATE) * _barWidth;
493
- /** Total width required to render the groups. Directly proportional to group width */ const reqWidth = (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate) * groupWidth;
533
+ const groupWidth = (0, _index.calcRequiredWidth)(_barWidth, _legends.length, X1_INNER_PADDING);
534
+ /** Total width required to render the groups. Directly proportional to group width */ const reqWidth = (0, _index.calcRequiredWidth)(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
494
535
  if (totalWidth >= reqWidth) {
495
536
  // Center align the chart by setting equal left and right margins for domain
496
537
  _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
497
538
  }
498
539
  } else if (props.mode === 'plotly' && xAxisLabels.length > 1) {
499
540
  // Calculate the remaining width after rendering groups at their maximum allowable width
500
- const groupBandwidth = totalWidth / (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate);
501
- const barBandwidth = groupBandwidth / (keys.length + (keys.length - 1) * BAR_GAP_RATE);
541
+ const groupBandwidth = (0, _index.calcBandwidth)(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
542
+ const barBandwidth = (0, _index.calcBandwidth)(groupBandwidth, _legends.length, X1_INNER_PADDING);
502
543
  const barWidth = (0, _index.getBarWidth)(props.barWidth, props.maxBarWidth, barBandwidth);
503
- const groupWidth = (keys.length + (keys.length - 1) * BAR_GAP_RATE) * barWidth;
504
- let reqWidth = (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate) * groupWidth;
544
+ const groupWidth = (0, _index.calcRequiredWidth)(barWidth, _legends.length, X1_INNER_PADDING);
545
+ let reqWidth = (0, _index.calcRequiredWidth)(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
505
546
  const margin1 = (totalWidth - reqWidth) / 2;
506
547
  let margin2 = Number.POSITIVE_INFINITY;
507
548
  if (!props.hideTickOverlap) {
@@ -523,7 +564,7 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
523
564
  return !(props.data && props.data.length > 0 && props.data.filter((item)=>item.series.length).length > 0);
524
565
  };
525
566
  const _getChartTitle = ()=>{
526
- return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${_keys.length} bars each. `;
567
+ return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${_legends.length} bars each. `;
527
568
  };
528
569
  return !_isChartEmpty() ? /*#__PURE__*/ _react.createElement(_index1.CartesianChart, {
529
570
  ...props,
@@ -534,7 +575,7 @@ const GroupedVerticalBarChart = /*#__PURE__*/ _react.forwardRef((props = {
534
575
  getMinMaxOfYAxis: _getMinMaxOfYAxis,
535
576
  createStringYAxis: _index.createStringYAxis,
536
577
  calloutProps: calloutProps,
537
- legendBars: legends,
578
+ legendBars: legendBars,
538
579
  xAxisType: _xAxisType,
539
580
  createYAxis: _index.createNumericYAxis,
540
581
  datasetForXAxisDomain: _xAxisLabels,