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