@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,OAAO,MAAMA,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;AAEF;;CAEC,GACD,OAAO,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,OAAO,MAAMA,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;AAEF;;CAEC,GACD,OAAO,MAAMC,sBAAsB,CAACC;IAClC,OAAO,CAAC;AACV,EAAE"}
@@ -4,25 +4,22 @@ import { select as d3Select } from 'd3-selection';
4
4
  import { max as d3Max, min as d3Min } from 'd3-array';
5
5
  import { scaleBand as d3ScaleBand } from 'd3-scale';
6
6
  import { useId } from '@fluentui/react-utilities';
7
- import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextColor, areArraysEqual, calculateLongestLabelWidth, useRtl } from '../../utilities/index';
8
- import { CartesianChart, Legends, DataVizPalette, getColorFromToken } from '../../index';
7
+ import { ChartTypes, getAccessibleDataObject, tooltipOfAxislabels, XAxisTypes, getTypeOfAxis, formatScientificLimitWidth, getScalePadding, getBarWidth, isScalePaddingDefined, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, getNextColor, areArraysEqual, calculateLongestLabelWidth, useRtl, calcRequiredWidth, calcTotalWidth, calcBandwidth, calcTotalBandUnits, sortAxisCategories } from '../../utilities/index';
8
+ import { CartesianChart, Legends } from '../../index';
9
9
  import { toImage } from '../../utilities/image-export-utils';
10
10
  const MIN_DOMAIN_MARGIN = 8;
11
11
  const X1_INNER_PADDING = 0.1;
12
- // x1_inner_padding = space_between_bars / (space_between_bars + bar_width)
13
- // => space_between_bars = (x1_inner_padding / (1 - x1_inner_padding)) * bar_width
14
- /** 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);
15
12
  const VERTICAL_BAR_GAP = 1;
16
13
  const MIN_BAR_HEIGHT = 1;
17
14
  export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
18
- maxBarWidth: 24
15
+ maxBarWidth: 24,
16
+ xAxisCategoryOrder: 'default'
19
17
  }, forwardedRef)=>{
20
18
  var _props_legendProps, _props_legendProps1;
21
19
  const _tooltipId = useId('GVBCTooltipId_');
22
20
  const _emptyChartId = useId('_GVBC_empty');
23
21
  const _useRtl = useRtl();
24
22
  let _domainMargin = MIN_DOMAIN_MARGIN;
25
- let _keys = [];
26
23
  let _xAxisLabels = [];
27
24
  let _datasetForBars = [];
28
25
  let _margins = {
@@ -32,13 +29,14 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
32
29
  left: 0
33
30
  };
34
31
  let _groupedVerticalBarGraph = [];
35
- let _refArray = [];
36
32
  let _yMax = 0;
37
33
  let _calloutAnchorPoint = null;
38
34
  let _barWidth = 0;
39
35
  let _groupWidth = 0;
40
36
  let _xAxisInnerPadding = 0;
41
37
  let _xAxisOuterPadding = 0;
38
+ let _legends = [];
39
+ let _legendColorMap = {};
42
40
  const cartesianChartRef = React.useRef(null);
43
41
  const Y_ORIGIN = 0;
44
42
  const _legendsRef = React.useRef(null);
@@ -82,44 +80,53 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
82
80
  _barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
83
81
  // x0_inner_padding = space_between_groups / (space_between_groups + group_width)
84
82
  // space_between_groups = 2 * bar_width
85
- // group_width = keys.length * bar_width + (keys.length - 1) * space_between_bars
86
- _xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 + keys.length + (keys.length - 1) * BAR_GAP_RATE));
83
+ // group_width = _legends.length * bar_width + (_legends.length - 1) * space_between_bars
84
+ _xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, undefined, 2 / (2 + calcTotalBandUnits(_legends.length, X1_INNER_PADDING)));
87
85
  _xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding);
88
86
  };
89
87
  const _createDataset = (points)=>{
90
88
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
89
  const datasetForBars = [];
92
- const dataset = [];
93
90
  points.forEach((point, index)=>{
94
- const singleDatasetPoint = {};
95
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
92
  const singleDatasetPointForBars = {};
97
- const singleDataSeries = [];
98
- point.series.forEach((seriesPoint, seriesIndex)=>{
99
- singleDatasetPoint[seriesPoint.key] = seriesPoint.data;
100
- singleDatasetPointForBars[seriesPoint.key] = {
101
- ...seriesPoint
102
- };
103
- singleDataSeries.push(seriesPoint);
93
+ const legendToBarPoint = {};
94
+ point.series.forEach((seriesPoint)=>{
95
+ if (!singleDatasetPointForBars[seriesPoint.legend]) {
96
+ singleDatasetPointForBars[seriesPoint.legend] = [
97
+ {
98
+ ...seriesPoint
99
+ }
100
+ ];
101
+ legendToBarPoint[seriesPoint.legend] = {
102
+ ...seriesPoint
103
+ };
104
+ } else {
105
+ singleDatasetPointForBars[seriesPoint.legend].push({
106
+ ...seriesPoint
107
+ });
108
+ legendToBarPoint[seriesPoint.legend].data += seriesPoint.data;
109
+ }
104
110
  });
105
111
  singleDatasetPointForBars.xAxisPoint = point.name;
106
112
  singleDatasetPointForBars.indexNum = index;
107
- singleDatasetPointForBars.groupSeries = singleDataSeries;
113
+ singleDatasetPointForBars.groupSeries = Object.values(legendToBarPoint);
108
114
  singleDatasetPointForBars.stackCallOutAccessibilityData = point.stackCallOutAccessibilityData;
109
115
  datasetForBars.push(singleDatasetPointForBars);
110
- dataset.push(singleDatasetPoint);
111
116
  });
112
117
  return datasetForBars;
113
118
  };
114
119
  const _createDataSetOfGVBC = (points)=>{
115
- const keys = [];
116
- const xAxisLabels = points.map((singlePoint)=>singlePoint.name);
117
- points[0].series.forEach((singleKey)=>{
118
- keys.push(singleKey.key);
120
+ const legends = new Set();
121
+ const xAxisLabels = _getOrderedXAxisLabels(points);
122
+ points.forEach((point)=>{
123
+ point.series.forEach((seriesPoint)=>{
124
+ legends.add(seriesPoint.legend);
125
+ });
119
126
  });
120
127
  const datasetForBars = _createDataset(points);
121
128
  return {
122
- keys,
129
+ legends: Array.from(legends),
123
130
  xAxisLabels,
124
131
  datasetForBars
125
132
  };
@@ -135,36 +142,22 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
135
142
  props.legendProps.onChange(selectedLegends, event, currentLegend);
136
143
  }
137
144
  };
145
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
138
146
  const _getLegendData = (points)=>{
139
- const data = points;
140
- const defaultPalette = [
141
- getColorFromToken(DataVizPalette.color1),
142
- getColorFromToken(DataVizPalette.color2),
143
- getColorFromToken(DataVizPalette.color3),
144
- getColorFromToken(DataVizPalette.color4),
145
- getColorFromToken(DataVizPalette.color5)
146
- ];
147
147
  const actions = [];
148
- data.forEach((singleChartData)=>{
149
- singleChartData.series.forEach((point)=>{
150
- let color = point.color ? point.color : defaultPalette[Math.floor(Math.random() * 4 + 1)];
151
- const checkSimilarLegends = actions.filter((leg)=>leg.title === point.legend && leg.color === color);
152
- if (checkSimilarLegends.length > 0) {
153
- return;
148
+ _legends.forEach((legendTitle)=>{
149
+ const legend = {
150
+ title: legendTitle,
151
+ color: _legendColorMap[legendTitle][0],
152
+ hoverAction: ()=>{
153
+ _handleChartMouseLeave();
154
+ _onLegendHover(legendTitle);
155
+ },
156
+ onMouseOutAction: ()=>{
157
+ _onLegendLeave();
154
158
  }
155
- const legend = {
156
- title: point.legend,
157
- color,
158
- hoverAction: ()=>{
159
- _handleChartMouseLeave();
160
- _onLegendHover(point.legend);
161
- },
162
- onMouseOutAction: ()=>{
163
- _onLegendLeave();
164
- }
165
- };
166
- actions.push(legend);
167
- });
159
+ };
160
+ actions.push(legend);
168
161
  });
169
162
  return /*#__PURE__*/ React.createElement(Legends, {
170
163
  legends: actions,
@@ -175,13 +168,60 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
175
168
  legendRef: _legendsRef
176
169
  });
177
170
  };
178
- const points = props.data;
179
- const { keys, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(points);
180
- _keys = keys;
171
+ const _addDefaultColors = (data)=>{
172
+ _legendColorMap = {};
173
+ let colorIndex = 0;
174
+ var _data_map;
175
+ return (_data_map = data === null || data === void 0 ? void 0 : data.map((point)=>{
176
+ var _point_series;
177
+ var _point_series_map;
178
+ return {
179
+ ...point,
180
+ series: (_point_series_map = (_point_series = point.series) === null || _point_series === void 0 ? void 0 : _point_series.map((seriesPoint)=>{
181
+ // TODO: Add support for gradient colors
182
+ let startColor = seriesPoint.color ? seriesPoint.color : getNextColor(colorIndex, 0);
183
+ let endColor = startColor;
184
+ if (!_legendColorMap[seriesPoint.legend]) {
185
+ _legendColorMap[seriesPoint.legend] = [
186
+ startColor,
187
+ endColor
188
+ ];
189
+ }
190
+ colorIndex += 1;
191
+ var _seriesPoint_color;
192
+ return {
193
+ ...seriesPoint,
194
+ color: (_seriesPoint_color = seriesPoint.color) !== null && _seriesPoint_color !== void 0 ? _seriesPoint_color : _legendColorMap[seriesPoint.legend][0]
195
+ };
196
+ })) !== null && _point_series_map !== void 0 ? _point_series_map : []
197
+ };
198
+ })) !== null && _data_map !== void 0 ? _data_map : [];
199
+ };
200
+ const _getOrderedXAxisLabels = (points)=>{
201
+ if (_xAxisType !== XAxisTypes.StringAxis) {
202
+ return [];
203
+ }
204
+ return sortAxisCategories(_mapCategoryToValues(points), props.xAxisCategoryOrder);
205
+ };
206
+ const _mapCategoryToValues = (points)=>{
207
+ const categoryToValues = {};
208
+ points.forEach((point)=>{
209
+ if (!categoryToValues[point.name]) {
210
+ categoryToValues[point.name] = [];
211
+ }
212
+ point.series.forEach((seriesPoint)=>{
213
+ categoryToValues[point.name].push(seriesPoint.data);
214
+ });
215
+ });
216
+ return categoryToValues;
217
+ };
218
+ const points = _addDefaultColors(props.data);
219
+ const _xAxisType = getTypeOfAxis(points[0].name, true);
220
+ const { legends, xAxisLabels, datasetForBars } = _createDataSetOfGVBC(points);
221
+ _legends = legends;
181
222
  _xAxisLabels = xAxisLabels;
182
223
  _datasetForBars = datasetForBars;
183
- const _xAxisType = getTypeOfAxis(points[0].name, true);
184
- const legends = _getLegendData(points);
224
+ const legendBars = _getLegendData(points);
185
225
  _adjustProps();
186
226
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Add commentMore actions
187
227
  function _getMinMaxOfYAxis(datasetForBars, yAxisType, useSecondaryYScale) {
@@ -241,8 +281,8 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
241
281
  const xScale0 = _createX0Scale(containerWidth);
242
282
  // Setting the bar width here is safe because there are no dependencies earlier in the code
243
283
  // that rely on the width of bars in vertical bar charts with string x-axis.
244
- _barWidth = getBarWidth(props.barWidth, props.maxBarWidth, xScale0.bandwidth() / (_keys.length + (_keys.length - 1) * BAR_GAP_RATE));
245
- _groupWidth = (_keys.length + (_keys.length - 1) * BAR_GAP_RATE) * _barWidth;
284
+ _barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calcBandwidth(xScale0.bandwidth(), _legends.length, X1_INNER_PADDING));
285
+ _groupWidth = calcRequiredWidth(_barWidth, _legends.length, X1_INNER_PADDING);
246
286
  const xScale1 = _createX1Scale();
247
287
  const allGroupsBars = [];
248
288
  _datasetForBars.forEach((singleSet)=>{
@@ -253,10 +293,6 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
253
293
  const _getMargins = (margins)=>{
254
294
  _margins = margins;
255
295
  };
256
- const _getOpacity = (legendTitle)=>{
257
- const opacity = _legendHighlighted(legendTitle) || _noLegendHighlighted() ? '' : '0.1';
258
- return opacity;
259
- };
260
296
  function updatePosition(newX, newY) {
261
297
  const threshold = 1; // Set a threshold for movement
262
298
  const { x, y } = clickPosition;
@@ -295,96 +331,102 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
295
331
  setPopoverOpen(false);
296
332
  };
297
333
  const onBarFocus = (event, pointData, // eslint-disable-next-line @typescript-eslint/no-explicit-any
298
- groupData, refArrayIndexNumber)=>{
334
+ groupData)=>{
299
335
  let x = 0;
300
336
  let y = 0;
301
337
  const targetRect = event.target.getBoundingClientRect();
302
338
  x = targetRect.left + targetRect.width / 2;
303
339
  y = targetRect.top + targetRect.height / 2;
304
340
  updatePosition(x, y);
305
- _refArray.forEach((obj, index)=>{
306
- if (obj.index === pointData.legend && refArrayIndexNumber === index) {
307
- setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
308
- setCalloutLegend(pointData.legend);
309
- setDataForHoverCard(pointData.data);
310
- setColor(pointData.color);
311
- setXCalloutValue(pointData.xAxisCalloutData);
312
- setYCalloutValue(pointData.yAxisCalloutData);
313
- setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
314
- setYValueHover(groupData.groupSeries);
315
- setHoverXValue(pointData.xAxisCalloutData);
316
- }
317
- });
318
- };
319
- const _refCallback = (element, legendTitle, refIndexNumber)=>{
320
- _refArray[refIndexNumber] = {
321
- index: legendTitle,
322
- refElement: element
323
- };
341
+ setPopoverOpen(_noLegendHighlighted() || _legendHighlighted(pointData.legend));
342
+ setCalloutLegend(pointData.legend);
343
+ setDataForHoverCard(pointData.data);
344
+ setColor(pointData.color);
345
+ setXCalloutValue(pointData.xAxisCalloutData);
346
+ setYCalloutValue(pointData.yAxisCalloutData);
347
+ setCallOutAccessibilityData(props.isCalloutForStack ? groupData.stackCallOutAccessibilityData : pointData.callOutAccessibilityData);
348
+ setYValueHover(groupData.groupSeries);
349
+ setHoverXValue(pointData.xAxisCalloutData);
324
350
  };
325
351
  const _buildGraph = (// eslint-disable-next-line @typescript-eslint/no-explicit-any
326
352
  singleSet, // eslint-disable-next-line @typescript-eslint/no-explicit-any
327
353
  xScale0, // eslint-disable-next-line @typescript-eslint/no-explicit-any
328
354
  xScale1, yScalePrimary, yScaleSecondary, containerHeight, xElement)=>{
355
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
329
356
  const singleGroup = [];
357
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
330
358
  const barLabelsForGroup = [];
331
- const tempDataSet = Object.keys(datasetForBars[0]).splice(0, keys.length);
332
- tempDataSet.forEach((datasetKey, index)=>{
333
- const refIndexNumber = singleSet.indexNum * tempDataSet.length + index;
334
- const pointData = singleSet[datasetKey];
335
- const yBarScale = pointData.useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
336
- if (pointData) {
337
- // To align the centers of the generated bandwidth and the calculated one when they differ,
338
- // use the following addend.
339
- const xPoint = xScale1(datasetKey) + (xScale1.bandwidth() - _barWidth) / 2;
340
- const startColor = pointData.color ? pointData.color : getNextColor(index, 0);
359
+ // Get the actual legends present at this x-axis point
360
+ const presentLegends = Object.keys(singleSet).filter((key)=>key in _legendColorMap);
361
+ const effectiveGroupWidth = calcRequiredWidth(_barWidth, presentLegends.length, X1_INNER_PADDING);
362
+ // For stacked bars, center the single bar group in the available space
363
+ // Instead of using the global legend position, use the local position within present legends
364
+ const localScale = d3ScaleBand().domain(presentLegends).range(_useRtl ? [
365
+ effectiveGroupWidth,
366
+ 0
367
+ ] : [
368
+ 0,
369
+ effectiveGroupWidth
370
+ ]).paddingInner(X1_INNER_PADDING);
371
+ _legends.forEach((legendTitle, legendIndex)=>{
372
+ const barPoints = singleSet[legendTitle];
373
+ if (barPoints) {
374
+ const yBarScale = barPoints[0].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
375
+ var _localScale;
376
+ const xPoint = ((_localScale = localScale(legendTitle)) !== null && _localScale !== void 0 ? _localScale : 0) + (localScale.bandwidth() - _barWidth) / 2;
377
+ const isLegendActive = _legendHighlighted(legendTitle) || _noLegendHighlighted();
378
+ const barOpacity = isLegendActive ? '' : '0.1';
379
+ let barTotalValue = 0;
341
380
  const yBaseline = yBarScale(Y_ORIGIN);
342
381
  let yPositiveStart = yBaseline;
343
382
  let yNegativeStart = yBaseline;
344
383
  let yPoint = Y_ORIGIN;
345
- const barGap = VERTICAL_BAR_GAP / 2 * (index > 0 ? 2 : 0);
346
- const height = Math.max(yBarScale(Y_ORIGIN) - yBarScale(Math.abs(pointData.data)), MIN_BAR_HEIGHT);
347
- if (pointData.data >= Y_ORIGIN) {
348
- yPositiveStart -= height + barGap;
349
- yPoint = yPositiveStart;
350
- } else {
351
- yPoint = yNegativeStart + barGap;
352
- yNegativeStart = yPoint + height;
353
- }
354
- // Not rendering data with 0.
355
- pointData.data && singleGroup.push(/*#__PURE__*/ React.createElement(React.Fragment, {
356
- key: `${singleSet.indexNum}-${index}`
357
- }, /*#__PURE__*/ React.createElement("rect", {
358
- className: classes.opacityChangeOnHover,
359
- height: height,
360
- width: _barWidth,
361
- x: xPoint,
362
- y: yPoint,
363
- opacity: _getOpacity(pointData.legend),
364
- ref: (e)=>{
365
- _refCallback(e, pointData.legend, refIndexNumber);
366
- },
367
- fill: startColor,
368
- rx: 0,
369
- onMouseOver: (event)=>onBarHover(pointData, singleSet, event),
370
- onMouseMove: (event)=>onBarHover(pointData, singleSet, event),
371
- onMouseOut: _onBarLeave,
372
- onFocus: (event)=>onBarFocus(event, pointData, singleSet, refIndexNumber),
373
- onBlur: _onBarLeave,
374
- onClick: pointData.onClick,
375
- "aria-label": getAriaLabel(pointData, singleSet.xAxisPoint),
376
- tabIndex: _legendHighlighted(pointData.legend) || _noLegendHighlighted() ? 0 : undefined,
377
- role: "img"
378
- })));
379
- if (pointData.data && !props.hideLabels && _barWidth >= 16 && (_legendHighlighted(pointData.legend) || _noLegendHighlighted())) {
384
+ barPoints.forEach((pointData, pointIndex)=>{
385
+ if (!pointData.data) {
386
+ // Not rendering data with 0.
387
+ return;
388
+ }
389
+ const barGap = VERTICAL_BAR_GAP / 2 * (pointIndex > 0 ? 2 : 0);
390
+ const height = Math.max(yBarScale(Y_ORIGIN) - yBarScale(Math.abs(pointData.data)), MIN_BAR_HEIGHT);
391
+ const pointColor = pointData.color; // Use the color of the current point
392
+ if (pointData.data >= Y_ORIGIN) {
393
+ yPositiveStart -= height + barGap;
394
+ yPoint = yPositiveStart;
395
+ } else {
396
+ yPoint = yNegativeStart + barGap;
397
+ yNegativeStart = yPoint + height;
398
+ }
399
+ singleGroup.push(/*#__PURE__*/ React.createElement("rect", {
400
+ key: `${singleSet.indexNum}-${legendIndex}-${pointIndex}`,
401
+ className: classes.opacityChangeOnHover,
402
+ height: height,
403
+ width: _barWidth,
404
+ x: xPoint,
405
+ y: yPoint,
406
+ opacity: barOpacity,
407
+ fill: pointColor,
408
+ rx: 0,
409
+ onMouseOver: (event)=>onBarHover(pointData, singleSet, event),
410
+ onMouseMove: (event)=>onBarHover(pointData, singleSet, event),
411
+ onMouseOut: _onBarLeave,
412
+ onFocus: (event)=>onBarFocus(event, pointData, singleSet),
413
+ onBlur: _onBarLeave,
414
+ onClick: pointData.onClick,
415
+ "aria-label": getAriaLabel(pointData, singleSet.xAxisPoint),
416
+ tabIndex: _legendHighlighted(pointData.legend) || _noLegendHighlighted() ? 0 : undefined,
417
+ role: "img"
418
+ }));
419
+ barTotalValue += pointData.data;
420
+ });
421
+ if (barTotalValue !== null && !props.hideLabels && _barWidth >= 16 && isLegendActive) {
380
422
  barLabelsForGroup.push(/*#__PURE__*/ React.createElement("text", {
381
- key: `${singleSet.indexNum}-${index}`,
423
+ key: `${singleSet.indexNum}-${legendIndex}`,
382
424
  x: xPoint + _barWidth / 2,
383
- y: pointData.data >= Y_ORIGIN ? yPositiveStart - 6 : yNegativeStart + 12,
425
+ y: barTotalValue >= Y_ORIGIN ? yPositiveStart - 6 : yNegativeStart + 12,
384
426
  textAnchor: "middle",
385
427
  className: classes.barLabel,
386
428
  "aria-hidden": true
387
- }, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(pointData.data) : formatScientificLimitWidth(pointData.data)));
429
+ }, typeof props.yAxisTickFormat === 'function' ? props.yAxisTickFormat(barTotalValue) : formatScientificLimitWidth(barTotalValue)));
388
430
  }
389
431
  }
390
432
  });
@@ -404,7 +446,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
404
446
  }
405
447
  return /*#__PURE__*/ React.createElement("g", {
406
448
  key: singleSet.indexNum,
407
- transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() - _groupWidth) / 2}, 0)`
449
+ transform: `translate(${xScale0(singleSet.xAxisPoint) + (xScale0.bandwidth() - effectiveGroupWidth) / 2}, 0)`
408
450
  }, singleGroup, barLabelsForGroup);
409
451
  };
410
452
  // For grouped vertical bar chart, First need to define total scale (from start to end)
@@ -421,7 +463,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
421
463
  };
422
464
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
423
465
  const _createX1Scale = ()=>{
424
- return d3ScaleBand().domain(keys)// When there is only one group, xScale0 adds padding around it,
466
+ return d3ScaleBand().domain(_legends)// When there is only one group, xScale0 adds padding around it,
425
467
  // causing the bandwidth to become smaller than the actual group width.
426
468
  // So to render bars in the group correctly, use groupWidth instead of the generated scale bandwidth.
427
469
  .range(_useRtl ? [
@@ -472,8 +514,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
472
514
  return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
473
515
  };
474
516
  const _getDomainMargins = (containerWidth)=>{
475
- /** Total width available to render the bars */ const totalWidth = containerWidth - (_margins.left + MIN_DOMAIN_MARGIN) - (_margins.right + MIN_DOMAIN_MARGIN);
476
- /** Rate at which the space between the groups changes wrt the group width */ const groupGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
517
+ /** Total width available to render the bars */ const totalWidth = calcTotalWidth(containerWidth, _margins, MIN_DOMAIN_MARGIN);
477
518
  if (_xAxisType === XAxisTypes.StringAxis) {
478
519
  if (isScalePaddingDefined(props.xAxisOuterPadding)) {
479
520
  // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
@@ -483,19 +524,19 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
483
524
  // Update the bar width so that when CartesianChart rerenders,
484
525
  // the following calculations don't use the previous bar width.
485
526
  _barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
486
- const groupWidth = (keys.length + (keys.length - 1) * BAR_GAP_RATE) * _barWidth;
487
- /** Total width required to render the groups. Directly proportional to group width */ const reqWidth = (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate) * groupWidth;
527
+ const groupWidth = calcRequiredWidth(_barWidth, _legends.length, X1_INNER_PADDING);
528
+ /** Total width required to render the groups. Directly proportional to group width */ const reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
488
529
  if (totalWidth >= reqWidth) {
489
530
  // Center align the chart by setting equal left and right margins for domain
490
531
  _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
491
532
  }
492
533
  } else if (props.mode === 'plotly' && xAxisLabels.length > 1) {
493
534
  // Calculate the remaining width after rendering groups at their maximum allowable width
494
- const groupBandwidth = totalWidth / (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate);
495
- const barBandwidth = groupBandwidth / (keys.length + (keys.length - 1) * BAR_GAP_RATE);
535
+ const groupBandwidth = calcBandwidth(totalWidth, _xAxisLabels.length, _xAxisInnerPadding);
536
+ const barBandwidth = calcBandwidth(groupBandwidth, _legends.length, X1_INNER_PADDING);
496
537
  const barWidth = getBarWidth(props.barWidth, props.maxBarWidth, barBandwidth);
497
- const groupWidth = (keys.length + (keys.length - 1) * BAR_GAP_RATE) * barWidth;
498
- let reqWidth = (xAxisLabels.length + (xAxisLabels.length - 1) * groupGapRate) * groupWidth;
538
+ const groupWidth = calcRequiredWidth(barWidth, _legends.length, X1_INNER_PADDING);
539
+ let reqWidth = calcRequiredWidth(groupWidth, _xAxisLabels.length, _xAxisInnerPadding);
499
540
  const margin1 = (totalWidth - reqWidth) / 2;
500
541
  let margin2 = Number.POSITIVE_INFINITY;
501
542
  if (!props.hideTickOverlap) {
@@ -517,7 +558,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
517
558
  return !(props.data && props.data.length > 0 && props.data.filter((item)=>item.series.length).length > 0);
518
559
  };
519
560
  const _getChartTitle = ()=>{
520
- return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${_keys.length} bars each. `;
561
+ return (props.chartTitle ? `${props.chartTitle}. ` : '') + `Vertical bar chart with ${_xAxisLabels.length} groups of ${_legends.length} bars each. `;
521
562
  };
522
563
  return !_isChartEmpty() ? /*#__PURE__*/ React.createElement(CartesianChart, {
523
564
  ...props,
@@ -528,7 +569,7 @@ export const GroupedVerticalBarChart = /*#__PURE__*/ React.forwardRef((props = {
528
569
  getMinMaxOfYAxis: _getMinMaxOfYAxis,
529
570
  createStringYAxis: createStringYAxis,
530
571
  calloutProps: calloutProps,
531
- legendBars: legends,
572
+ legendBars: legendBars,
532
573
  xAxisType: _xAxisType,
533
574
  createYAxis: createNumericYAxis,
534
575
  datasetForXAxisDomain: _xAxisLabels,