@fluentui/react-charts 0.0.0-nightly-20250826-0412.1 → 0.0.0-nightly-20250826-2140.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 (150) hide show
  1. package/CHANGELOG.md +15 -48
  2. package/dist/index.d.ts +1 -15
  3. package/lib/components/AreaChart/AreaChart.js +1 -4
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -2
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +15 -3
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.js +24 -24
  10. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  11. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +14 -17
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +33 -6
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  15. package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -32
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  17. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
  18. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  19. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +199 -294
  20. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  21. package/lib/components/DonutChart/DonutChart.js +1 -6
  22. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  23. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  24. package/lib/components/DonutChart/useDonutChartStyles.styles.js +4 -21
  25. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  26. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +4 -8
  27. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  28. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +4 -23
  29. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +17 -4
  31. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  32. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +21 -4
  33. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  34. package/lib/components/HeatMapChart/HeatMapChart.js +114 -175
  35. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  36. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +6 -26
  37. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  38. package/lib/components/LineChart/LineChart.js +81 -111
  39. package/lib/components/LineChart/LineChart.js.map +1 -1
  40. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  41. package/lib/components/LineChart/useLineChartStyles.styles.js +10 -23
  42. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  43. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +21 -4
  44. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  45. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +25 -12
  46. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  47. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +12 -2
  48. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  49. package/lib/components/ScatterChart/ScatterChart.js +30 -49
  50. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  51. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  52. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +7 -27
  53. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  54. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +14 -8
  55. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  56. package/lib/components/VerticalBarChart/VerticalBarChart.js +4 -27
  57. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  58. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +6 -8
  59. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +19 -5
  61. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  62. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +44 -61
  63. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  64. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +6 -7
  65. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +19 -4
  67. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  68. package/lib/utilities/SVGTooltipText.js.map +1 -1
  69. package/lib/utilities/index.js +0 -1
  70. package/lib/utilities/index.js.map +1 -1
  71. package/lib/utilities/utilities.js +29 -0
  72. package/lib/utilities/utilities.js.map +1 -1
  73. package/lib-commonjs/components/AreaChart/AreaChart.js +1 -4
  74. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  75. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  76. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +14 -2
  77. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  78. package/lib-commonjs/components/CommonComponents/CartesianChart.js +24 -24
  79. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  80. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -15
  81. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  82. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +32 -4
  83. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  84. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +15 -31
  85. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  86. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
  87. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  88. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +198 -302
  89. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  90. package/lib-commonjs/components/DonutChart/DonutChart.js +1 -6
  91. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  92. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  93. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +4 -32
  94. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  95. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +4 -8
  96. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  97. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +3 -22
  98. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  99. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +19 -2
  100. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  101. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +20 -3
  102. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  103. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +113 -174
  104. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  105. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -25
  106. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  107. package/lib-commonjs/components/LineChart/LineChart.js +81 -111
  108. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  109. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  110. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +9 -30
  111. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  112. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +20 -2
  113. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  114. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +33 -23
  115. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  116. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +12 -1
  117. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  118. package/lib-commonjs/components/ScatterChart/ScatterChart.js +30 -49
  119. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  120. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  121. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +5 -37
  122. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  123. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +13 -7
  124. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  125. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -26
  126. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  127. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -5
  128. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  129. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +17 -3
  130. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  131. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +43 -60
  132. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  133. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +3 -5
  134. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  135. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +18 -3
  136. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  137. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  138. package/lib-commonjs/utilities/index.js +0 -1
  139. package/lib-commonjs/utilities/index.js.map +1 -1
  140. package/lib-commonjs/utilities/utilities.js +32 -0
  141. package/lib-commonjs/utilities/utilities.js.map +1 -1
  142. package/package.json +12 -12
  143. package/lib/utilities/Common.styles.js +0 -47
  144. package/lib/utilities/Common.styles.js.map +0 -1
  145. package/lib/utilities/Common.styles.raw.js +0 -47
  146. package/lib/utilities/Common.styles.raw.js.map +0 -1
  147. package/lib-commonjs/utilities/Common.styles.js +0 -71
  148. package/lib-commonjs/utilities/Common.styles.js.map +0 -1
  149. package/lib-commonjs/utilities/Common.styles.raw.js +0 -71
  150. package/lib-commonjs/utilities/Common.styles.raw.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { ChartTypes, getAccessibleDataObject, getColorContrast, getTypeOfAxis, resolveCSSVariables, XAxisTypes, YAxisType, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, useRtl, sortAxisCategories } from '../../utilities/index';
2
+ import { ChartTypes, getAccessibleDataObject, getColorContrast, getTypeOfAxis, resolveCSSVariables, XAxisTypes, YAxisType, createNumericYAxis, domainRangeOfXStringAxis, createStringYAxis, useRtl } from '../../utilities/index';
3
3
  import { formatToLocaleString } from '@fluentui/chart-utilities';
4
4
  import { CartesianChart } from '../CommonComponents/index';
5
5
  import { useId } from '@fluentui/react-utilities';
@@ -10,13 +10,7 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
10
10
  import { format as d3Format } from 'd3-format';
11
11
  import { timeFormat as d3TimeFormat } from 'd3-time-format';
12
12
  import { toImage } from '../../utilities/image-export-utils';
13
- export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
14
- xAxisCategoryOrder: 'default',
15
- yAxisCategoryOrder: 'default',
16
- data: [],
17
- domainValuesForColorScale: [],
18
- rangeValuesForColorScale: []
19
- }, forwardedRef)=>{
13
+ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
20
14
  const classes = useHeatMapChartStyles(props);
21
15
  const _stringXAxisDataPoints = React.useRef([]);
22
16
  const _stringYAxisDataPoints = React.useRef([]);
@@ -141,16 +135,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
141
135
  return color === tokens.colorNeutralForeground1 ? tokens.colorNeutralBackground1 : tokens.colorNeutralForeground1;
142
136
  };
143
137
  /**
144
- * This is the function which is responsible for
145
- * drawing the rectangle in the graph and also
146
- * attaching dom events to that rectangles
147
- */ const _createRectangles = ()=>{
138
+ * This is the function which is responsible for
139
+ * drawing the rectangle in the graph and also
140
+ * attaching dom events to that rectangles
141
+ */ const _createRectangles = ()=>{
148
142
  const rectangles = [];
149
143
  const yAxisDataPoints = _stringYAxisDataPoints.current.slice().reverse();
150
144
  /**
151
- * yAxisDataPoint is noting but the DataPoint
152
- * which will be rendered on the y-axis
153
- */ yAxisDataPoints.forEach((yAxisDataPoint)=>{
145
+ * yAxisDataPoint is noting but the DataPoint
146
+ * which will be rendered on the y-axis
147
+ */ yAxisDataPoints.forEach((yAxisDataPoint)=>{
154
148
  let index = 0;
155
149
  _stringXAxisDataPoints.current.forEach((xAxisDataPoint)=>{
156
150
  var _dataSet_current_yAxisDataPoint_index, _dataSet_current_yAxisDataPoint_index1;
@@ -159,9 +153,9 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
159
153
  if (((_dataSet_current_yAxisDataPoint_index = _dataSet.current[yAxisDataPoint][index]) === null || _dataSet_current_yAxisDataPoint_index === void 0 ? void 0 : _dataSet_current_yAxisDataPoint_index.x) === xAxisDataPoint && typeof ((_dataSet_current_yAxisDataPoint_index1 = _dataSet.current[yAxisDataPoint][index]) === null || _dataSet_current_yAxisDataPoint_index1 === void 0 ? void 0 : _dataSet_current_yAxisDataPoint_index1.value) === 'number') {
160
154
  var _cartesianChartRef_current;
161
155
  /**
162
- * dataPointObject is an object where it contains information on single
163
- * data point such as x, y , value, rectText property of the rectangle
164
- */ const dataPointObject = _dataSet.current[yAxisDataPoint][index];
156
+ * dataPointObject is an object where it contains information on single
157
+ * data point such as x, y , value, rectText property of the rectangle
158
+ */ const dataPointObject = _dataSet.current[yAxisDataPoint][index];
165
159
  let styleRules = '';
166
160
  let foregroundColor = tokens.colorNeutralForeground1;
167
161
  if ((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) {
@@ -225,30 +219,30 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
225
219
  return rectangles;
226
220
  };
227
221
  /**
228
- * when the legend is hovered we need to highlight
229
- * all the rectangles which fall under that category
230
- * and un-highlight the rest of them
231
- * @param legendTitle
232
- */ const _onLegendHover = (legendTitle)=>{
222
+ * when the legend is hovered we need to highlight
223
+ * all the rectangles which fall under that category
224
+ * and un-highlight the rest of them
225
+ * @param legendTitle
226
+ */ const _onLegendHover = (legendTitle)=>{
233
227
  setActiveLegend(legendTitle);
234
228
  };
235
229
  /**
236
- * when the mouse is out from the legend , we need
237
- * to show the graph in initial mode.
238
- */ const _onLegendLeave = ()=>{
230
+ * when the mouse is out from the legend , we need
231
+ * to show the graph in initial mode.
232
+ */ const _onLegendLeave = ()=>{
239
233
  setActiveLegend('');
240
234
  };
241
235
  /**
242
- * @param legendTitle
243
- * when the legend is clicked we need to highlight
244
- * all the rectangles which fall under that category
245
- * and un highlight the rest of them
246
- */ const _onLegendClick = (legendTitle)=>{
236
+ * @param legendTitle
237
+ * when the legend is clicked we need to highlight
238
+ * all the rectangles which fall under that category
239
+ * and un highlight the rest of them
240
+ */ const _onLegendClick = (legendTitle)=>{
247
241
  /**
248
- * check if the legend is already selceted,
249
- * if yes, un-select the legend, else
250
- * set the selected legend state to legendTitle
251
- */ if (selectedLegend === legendTitle) {
242
+ * check if the legend is already selceted,
243
+ * if yes, un-select the legend, else
244
+ * set the selected legend state to legendTitle
245
+ */ if (selectedLegend === legendTitle) {
252
246
  setSelectedLegend('');
253
247
  } else {
254
248
  setSelectedLegend(legendTitle);
@@ -319,13 +313,19 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
319
313
  yAxisStringFormatter
320
314
  ]);
321
315
  /**
322
- * This function will return the final sorted and formatted x-axis points
323
- * which will be rendered on the x-axis
324
- * @param points
325
- * @returns x-axis points
326
- */ const _getXAxisDataPoints = React.useCallback((points)=>{
316
+ * This function will return the final sorted and formatted x-axis points
317
+ * which will be rendered on the x-axis
318
+ * @param points
319
+ * @returns x-axis points
320
+ */ const _getXAxisDataPoints = React.useCallback((points)=>{
327
321
  let xAxisPoints = [];
328
- const unFormattedXAxisDataPoints = _getOrderedXAxisLabels(points);
322
+ const unFormattedXAxisDataPoints = Object.keys(points).sort((a, b)=>{
323
+ if (_xAxisType.current === XAxisTypes.DateAxis || _xAxisType.current === XAxisTypes.NumericAxis) {
324
+ return +a - +b;
325
+ } else {
326
+ return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
327
+ }
328
+ });
329
329
  xAxisPoints = unFormattedXAxisDataPoints.map((xPoint)=>{
330
330
  if (_xAxisType.current === XAxisTypes.DateAxis) {
331
331
  return _getStringFormattedDate(xPoint, props.xAxisDateFormatString);
@@ -343,13 +343,19 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
343
343
  props.xAxisNumberFormatString
344
344
  ]);
345
345
  /**
346
- * This function will return the final sorted and formatted y-axis points
347
- * which will be rendered on the y-axis
348
- * @param points
349
- * @returns yaxis points
350
- */ const _getYAxisDataPoints = React.useCallback((points)=>{
346
+ * This function will return the final sorted and formatted y-axis points
347
+ * which will be rendered on the y-axis
348
+ * @param points
349
+ * @returns yaxis points
350
+ */ const _getYAxisDataPoints = React.useCallback((points)=>{
351
351
  let yAxisPoints = [];
352
- const unFormattedYAxisDataPoints = _getOrderedYAxisLabels(points);
352
+ const unFormattedYAxisDataPoints = Object.keys(points).sort((a, b)=>{
353
+ if (_yAxisType.current === YAxisType.DateAxis || _yAxisType.current === YAxisType.NumericAxis) {
354
+ return +a - +b;
355
+ } else {
356
+ return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
357
+ }
358
+ });
353
359
  yAxisPoints = unFormattedYAxisDataPoints.map((yPoint)=>{
354
360
  if (_yAxisType.current === YAxisType.DateAxis) {
355
361
  return _getStringFormattedDate(yPoint, props.yAxisDateFormatString);
@@ -367,24 +373,24 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
367
373
  props.yAxisNumberFormatString
368
374
  ]);
369
375
  /**
370
- * This will create a new data set based on the prop
371
- * @data
372
- * We will be using This data set to contsruct our rectangles
373
- * in the chart, we use this data set becuase, when we loop in this
374
- * data and build the heat map, it will support accessibility as
375
- * specified in the figma
376
- */ const _createNewDataSet = React.useCallback((data, xAxisDateFormatString, xAxisNumberFormatString, yAxisDateFormatString, yAxisNumberFormatString)=>{
376
+ * This will create a new data set based on the prop
377
+ * @data
378
+ * We will be using This data set to contsruct our rectangles
379
+ * in the chart, we use this data set becuase, when we loop in this
380
+ * data and build the heat map, it will support accessibility as
381
+ * specified in the figma
382
+ */ const _createNewDataSet = React.useCallback((data, xAxisDateFormatString, xAxisNumberFormatString, yAxisDateFormatString, yAxisNumberFormatString)=>{
377
383
  /**
378
- * please do not destructure any of the props here,
379
- * instead send them as parameter to this functions so that
380
- * this functions get called whenever the prop changes
381
- */ const flattenData = [];
384
+ * please do not destructure any of the props here,
385
+ * instead send them as parameter to this functions so that
386
+ * this functions get called whenever the prop changes
387
+ */ const flattenData = [];
382
388
  /**
383
- * below for each loop will store all the datapoints in the one array.
384
- * basically it will flatten the nestesd array (data prop) into single array
385
- * of object. where each object contains x, y, rectText , value and legend propety of single
386
- * data point.
387
- */ data.forEach((item)=>{
389
+ * below for each loop will store all the datapoints in the one array.
390
+ * basically it will flatten the nestesd array (data prop) into single array
391
+ * of object. where each object contains x, y, rectText , value and legend propety of single
392
+ * data point.
393
+ */ data.forEach((item)=>{
388
394
  item.data.forEach((point)=>{
389
395
  flattenData.push({
390
396
  ...point,
@@ -401,13 +407,13 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
401
407
  uniqueXPoints[posX] = '1';
402
408
  uniqueYPoints[posY] = '1';
403
409
  /** we will check if the property(posY) is already there in object, if Yes,
404
- * then we will append the item in the Array related to the pos, if not
405
- * then we will simply append the item in the new Array and
406
- * assign that array to the property (posY) in the Object
407
- * and finally we will get the array of Objects associated to each
408
- * property (which is nothing but y data point) and object in the
409
- * array are noting but x data points associated to the property y
410
- */ if (yPoints[posY]) {
410
+ * then we will append the item in the Array related to the pos, if not
411
+ * then we will simply append the item in the new Array and
412
+ * assign that array to the property (posY) in the Object
413
+ * and finally we will get the array of Objects associated to each
414
+ * property (which is nothing but y data point) and object in the
415
+ * array are noting but x data points associated to the property y
416
+ */ if (yPoints[posY]) {
411
417
  yPoints[posY] = [
412
418
  ...yPoints[posY],
413
419
  item
@@ -419,12 +425,21 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
419
425
  }
420
426
  });
421
427
  /**
422
- * we will now sort(ascending) the array's of y data point based on the x value
423
- * sorting is important to achive the accessibility order of the
424
- * rectangles and then format the x and y datapoints respectively
425
- */ Object.keys(yPoints).forEach((item)=>{
426
- yPoints[item] = _getOrderedXPoints(yPoints[item]);
427
- yPoints[item].forEach((datapoint)=>{
428
+ * we will now sort(ascending) the array's of y data point based on the x value
429
+ * sorting is important to achive the accessibility order of the
430
+ * rectangles and then format the x and y datapoints respectively
431
+ */ Object.keys(yPoints).forEach((item)=>{
432
+ yPoints[item].sort((a, b)=>{
433
+ if (_xAxisType.current === XAxisTypes.StringAxis) {
434
+ return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
435
+ } else if (_xAxisType.current === XAxisTypes.DateAxis) {
436
+ return a.x.getTime() - b.x.getTime();
437
+ } else if (_xAxisType.current === XAxisTypes.NumericAxis) {
438
+ return +a.x > +b.x ? 1 : -1;
439
+ } else {
440
+ return a.x > b.x ? 1 : -1;
441
+ }
442
+ }).forEach((datapoint)=>{
428
443
  if (_xAxisType.current === XAxisTypes.DateAxis) {
429
444
  datapoint.x = _getStringFormattedDate(datapoint.x, xAxisDateFormatString);
430
445
  }
@@ -446,14 +461,14 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
446
461
  });
447
462
  });
448
463
  /**
449
- * if y-axis data points are of type date or number or if we have string formatter,
450
- * then we need to change data points to their respective string
451
- * format, becuase in the private variable _stringYAxisDatapoints, points will be stored in
452
- * string format. and in here `yPoint` are not so we need to change, so that
453
- * function `_createRectangles` should work perfetcly while looping, and if we don't change
454
- * then `_createRectangles` will fail while looping, causing the error
455
- * Cannot read property 'forEach' of undefined
456
- */ Object.keys(yPoints).forEach((yPoint)=>{
464
+ * if y-axis data points are of type date or number or if we have string formatter,
465
+ * then we need to change data points to their respective string
466
+ * format, becuase in the private variable this._stringYAxisDatapoints, points will be stored in
467
+ * string format. and in here `yPoint` are not so we need to change, so that
468
+ * function `this._createRectangles` should work perfetcly while looping, and if we don't change
469
+ * then `this._createRectangles` will fail while looping, causing the error
470
+ * Cannot read property 'forEach' of undefined
471
+ */ Object.keys(yPoints).forEach((yPoint)=>{
457
472
  if (_yAxisType.current === YAxisType.DateAxis) {
458
473
  yPoints[_getStringFormattedDate(yPoint, yAxisDateFormatString)] = yPoints[yPoint];
459
474
  } else if (_yAxisType.current === YAxisType.NumericAxis) {
@@ -463,16 +478,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
463
478
  }
464
479
  });
465
480
  /**
466
- * assigning new data set
467
- */ const dataSet = yPoints;
481
+ * assigning new data set
482
+ */ const dataSet = yPoints;
468
483
  /**
469
- * These are the Y axis data points which will get rendered in the
470
- * Y axis in graph
471
- */ const yAxisPoints = _getYAxisDataPoints(uniqueYPoints);
484
+ * These are the Y axis data points which will get rendered in the
485
+ * Y axis in graph
486
+ */ const yAxisPoints = _getYAxisDataPoints(uniqueYPoints);
472
487
  /**
473
- * These are the x axis data points which will get rendered in the
474
- * x axis in the graph
475
- */ const xAxisPoints = _getXAxisDataPoints(uniqueXPoints);
488
+ * These are the x axis data points which will get rendered in the
489
+ * x axis in the graph
490
+ */ const xAxisPoints = _getXAxisDataPoints(uniqueXPoints);
476
491
  return {
477
492
  dataSet,
478
493
  yAxisPoints,
@@ -494,16 +509,16 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
494
509
  return d3Format(formatString || '.2~s')(+point);
495
510
  };
496
511
  /**
497
- * This function checks if the given legend is highlighted or not.
498
- * A legend can be highlighted in 2 ways:
499
- * 1. selection: if the user clicks on it
500
- * 2. hovering: if there is no selected legend and the user hovers over it
501
- */ const _legendHighlighted = (legendTitle)=>{
512
+ * This function checks if the given legend is highlighted or not.
513
+ * A legend can be highlighted in 2 ways:
514
+ * 1. selection: if the user clicks on it
515
+ * 2. hovering: if there is no selected legend and the user hovers over it
516
+ */ const _legendHighlighted = (legendTitle)=>{
502
517
  return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
503
518
  };
504
519
  /**
505
- * This function checks if none of the legends is selected or hovered.
506
- */ const _noLegendHighlighted = ()=>{
520
+ * This function checks if none of the legends is selected or hovered.
521
+ */ const _noLegendHighlighted = ()=>{
507
522
  return selectedLegend === '' && activeLegend === '';
508
523
  };
509
524
  const _getAriaLabel = (point)=>{
@@ -523,82 +538,6 @@ export const HeatMapChart = /*#__PURE__*/ React.forwardRef((props = {
523
538
  const numDataPoints = props.data.reduce((acc, curr)=>acc + curr.data.length, 0);
524
539
  return (chartTitle ? `${chartTitle}. ` : '') + `Heat map chart with ${numDataPoints} data points. `;
525
540
  };
526
- const _getOrderedXAxisLabels = (points)=>{
527
- if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
528
- // Keep the original ordering logic as the default behavior to ensure backward compatibility
529
- return Object.keys(points).sort((a, b)=>{
530
- if (_xAxisType.current === XAxisTypes.DateAxis || _xAxisType.current === XAxisTypes.NumericAxis) {
531
- return +a - +b;
532
- } else {
533
- return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
534
- }
535
- });
536
- }
537
- return sortAxisCategories(_mapCategoryToValues(), props.xAxisCategoryOrder);
538
- };
539
- const _getOrderedYAxisLabels = (points)=>{
540
- if (!_shouldOrderYAxisLabelsByCategoryOrder()) {
541
- // Keep the original ordering logic as the default behavior to ensure backward compatibility
542
- return Object.keys(points).sort((a, b)=>{
543
- if (_yAxisType.current === YAxisType.DateAxis || _yAxisType.current === YAxisType.NumericAxis) {
544
- return +a - +b;
545
- } else {
546
- return props.sortOrder === 'none' ? 0 : a.toLowerCase() > b.toLowerCase() ? 1 : -1;
547
- }
548
- });
549
- }
550
- return sortAxisCategories(_mapCategoryToValues(true), props.yAxisCategoryOrder);
551
- };
552
- const _getOrderedXPoints = (xPoints)=>{
553
- if (!_shouldOrderXAxisLabelsByCategoryOrder()) {
554
- return xPoints.sort((a, b)=>{
555
- if (_xAxisType.current === XAxisTypes.StringAxis) {
556
- return props.sortOrder === 'none' ? 0 : a.x.toLowerCase() > b.x.toLowerCase() ? 1 : -1;
557
- } else if (_xAxisType.current === XAxisTypes.DateAxis) {
558
- return a.x.getTime() - b.x.getTime();
559
- } else if (_xAxisType.current === XAxisTypes.NumericAxis) {
560
- return +a.x > +b.x ? 1 : -1;
561
- } else {
562
- return a.x > b.x ? 1 : -1;
563
- }
564
- });
565
- }
566
- const result = [];
567
- const xValueToPoints = {};
568
- xPoints.forEach((point)=>{
569
- const xValue = point.x;
570
- if (!xValueToPoints[xValue]) {
571
- xValueToPoints[xValue] = [];
572
- }
573
- xValueToPoints[xValue].push(point);
574
- });
575
- const xAxisLabels = _getOrderedXAxisLabels({});
576
- xAxisLabels.forEach((xValue)=>{
577
- if (xValueToPoints[xValue]) {
578
- result.push(...xValueToPoints[xValue]);
579
- }
580
- });
581
- return result;
582
- };
583
- const _shouldOrderXAxisLabelsByCategoryOrder = ()=>{
584
- return _xAxisType.current === XAxisTypes.StringAxis && props.xAxisCategoryOrder !== 'default';
585
- };
586
- const _shouldOrderYAxisLabelsByCategoryOrder = ()=>{
587
- return _yAxisType.current === YAxisType.StringAxis && props.yAxisCategoryOrder !== 'default';
588
- };
589
- const _mapCategoryToValues = (isYAxis = false)=>{
590
- const categoryToValues = {};
591
- props.data.forEach((item)=>{
592
- item.data.forEach((point)=>{
593
- const category = isYAxis ? point.y : point.x;
594
- if (!categoryToValues[category]) {
595
- categoryToValues[category] = [];
596
- }
597
- categoryToValues[category].push(point.value);
598
- });
599
- });
600
- return categoryToValues;
601
- };
602
541
  const updatePosition = (newX, newY)=>{
603
542
  const threshold = 1; // Set a threshold for movement
604
543
  const { x, y } = clickPosition;