@fluentui/react-charts 0.0.0-nightly-20250825-0406.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.
- package/CHANGELOG.md +15 -48
- package/dist/index.d.ts +1 -9
- package/lib/components/AreaChart/AreaChart.js +1 -4
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +9 -13
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -32
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +199 -293
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +1 -6
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +4 -21
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +3 -16
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +4 -23
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +114 -175
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +6 -26
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +30 -49
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +3 -19
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +2 -14
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +4 -27
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +44 -61
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/utilities/utilities.js +29 -0
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +1 -4
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +9 -13
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +15 -31
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +198 -301
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -6
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +4 -32
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +3 -16
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +3 -22
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +113 -174
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -25
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +30 -49
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +2 -28
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +1 -13
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -26
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +43 -60
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +32 -0
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -21,13 +21,7 @@ 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
|
|
25
|
-
xAxisCategoryOrder: 'default',
|
|
26
|
-
yAxisCategoryOrder: 'default',
|
|
27
|
-
data: [],
|
|
28
|
-
domainValuesForColorScale: [],
|
|
29
|
-
rangeValuesForColorScale: []
|
|
30
|
-
}, forwardedRef)=>{
|
|
24
|
+
const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
31
25
|
const classes = (0, _useHeatMapChartStylesstyles.useHeatMapChartStyles)(props);
|
|
32
26
|
const _stringXAxisDataPoints = _react.useRef([]);
|
|
33
27
|
const _stringYAxisDataPoints = _react.useRef([]);
|
|
@@ -152,16 +146,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
152
146
|
return color === _reacttheme.tokens.colorNeutralForeground1 ? _reacttheme.tokens.colorNeutralBackground1 : _reacttheme.tokens.colorNeutralForeground1;
|
|
153
147
|
};
|
|
154
148
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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 = ()=>{
|
|
159
153
|
const rectangles = [];
|
|
160
154
|
const yAxisDataPoints = _stringYAxisDataPoints.current.slice().reverse();
|
|
161
155
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
* yAxisDataPoint is noting but the DataPoint
|
|
157
|
+
* which will be rendered on the y-axis
|
|
158
|
+
*/ yAxisDataPoints.forEach((yAxisDataPoint)=>{
|
|
165
159
|
let index = 0;
|
|
166
160
|
_stringXAxisDataPoints.current.forEach((xAxisDataPoint)=>{
|
|
167
161
|
var _dataSet_current_yAxisDataPoint_index, _dataSet_current_yAxisDataPoint_index1;
|
|
@@ -170,9 +164,9 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
170
164
|
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') {
|
|
171
165
|
var _cartesianChartRef_current;
|
|
172
166
|
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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];
|
|
176
170
|
let styleRules = '';
|
|
177
171
|
let foregroundColor = _reacttheme.tokens.colorNeutralForeground1;
|
|
178
172
|
if ((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) {
|
|
@@ -236,30 +230,30 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
236
230
|
return rectangles;
|
|
237
231
|
};
|
|
238
232
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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)=>{
|
|
244
238
|
setActiveLegend(legendTitle);
|
|
245
239
|
};
|
|
246
240
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
241
|
+
* when the mouse is out from the legend , we need
|
|
242
|
+
* to show the graph in initial mode.
|
|
243
|
+
*/ const _onLegendLeave = ()=>{
|
|
250
244
|
setActiveLegend('');
|
|
251
245
|
};
|
|
252
246
|
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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)=>{
|
|
258
252
|
/**
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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) {
|
|
263
257
|
setSelectedLegend('');
|
|
264
258
|
} else {
|
|
265
259
|
setSelectedLegend(legendTitle);
|
|
@@ -330,13 +324,19 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
330
324
|
yAxisStringFormatter
|
|
331
325
|
]);
|
|
332
326
|
/**
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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)=>{
|
|
338
332
|
let xAxisPoints = [];
|
|
339
|
-
const unFormattedXAxisDataPoints =
|
|
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
|
+
});
|
|
340
340
|
xAxisPoints = unFormattedXAxisDataPoints.map((xPoint)=>{
|
|
341
341
|
if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
342
342
|
return _getStringFormattedDate(xPoint, props.xAxisDateFormatString);
|
|
@@ -354,13 +354,19 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
354
354
|
props.xAxisNumberFormatString
|
|
355
355
|
]);
|
|
356
356
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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 =
|
|
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
|
+
});
|
|
364
370
|
yAxisPoints = unFormattedYAxisDataPoints.map((yPoint)=>{
|
|
365
371
|
if (_yAxisType.current === _index.YAxisType.DateAxis) {
|
|
366
372
|
return _getStringFormattedDate(yPoint, props.yAxisDateFormatString);
|
|
@@ -378,24 +384,24 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
378
384
|
props.yAxisNumberFormatString
|
|
379
385
|
]);
|
|
380
386
|
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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)=>{
|
|
388
394
|
/**
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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 = [];
|
|
393
399
|
/**
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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)=>{
|
|
399
405
|
item.data.forEach((point)=>{
|
|
400
406
|
flattenData.push({
|
|
401
407
|
...point,
|
|
@@ -412,13 +418,13 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
412
418
|
uniqueXPoints[posX] = '1';
|
|
413
419
|
uniqueYPoints[posY] = '1';
|
|
414
420
|
/** we will check if the property(posY) is already there in object, if Yes,
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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]) {
|
|
422
428
|
yPoints[posY] = [
|
|
423
429
|
...yPoints[posY],
|
|
424
430
|
item
|
|
@@ -430,12 +436,21 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
430
436
|
}
|
|
431
437
|
});
|
|
432
438
|
/**
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
yPoints[item]
|
|
438
|
-
|
|
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)=>{
|
|
439
454
|
if (_xAxisType.current === _index.XAxisTypes.DateAxis) {
|
|
440
455
|
datapoint.x = _getStringFormattedDate(datapoint.x, xAxisDateFormatString);
|
|
441
456
|
}
|
|
@@ -457,14 +472,14 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
457
472
|
});
|
|
458
473
|
});
|
|
459
474
|
/**
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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)=>{
|
|
468
483
|
if (_yAxisType.current === _index.YAxisType.DateAxis) {
|
|
469
484
|
yPoints[_getStringFormattedDate(yPoint, yAxisDateFormatString)] = yPoints[yPoint];
|
|
470
485
|
} else if (_yAxisType.current === _index.YAxisType.NumericAxis) {
|
|
@@ -474,16 +489,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
474
489
|
}
|
|
475
490
|
});
|
|
476
491
|
/**
|
|
477
|
-
|
|
478
|
-
|
|
492
|
+
* assigning new data set
|
|
493
|
+
*/ const dataSet = yPoints;
|
|
479
494
|
/**
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
495
|
+
* These are the Y axis data points which will get rendered in the
|
|
496
|
+
* Y axis in graph
|
|
497
|
+
*/ const yAxisPoints = _getYAxisDataPoints(uniqueYPoints);
|
|
483
498
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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);
|
|
487
502
|
return {
|
|
488
503
|
dataSet,
|
|
489
504
|
yAxisPoints,
|
|
@@ -505,16 +520,16 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
505
520
|
return (0, _d3format.format)(formatString || '.2~s')(+point);
|
|
506
521
|
};
|
|
507
522
|
/**
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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)=>{
|
|
513
528
|
return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
|
|
514
529
|
};
|
|
515
530
|
/**
|
|
516
|
-
|
|
517
|
-
|
|
531
|
+
* This function checks if none of the legends is selected or hovered.
|
|
532
|
+
*/ const _noLegendHighlighted = ()=>{
|
|
518
533
|
return selectedLegend === '' && activeLegend === '';
|
|
519
534
|
};
|
|
520
535
|
const _getAriaLabel = (point)=>{
|
|
@@ -534,82 +549,6 @@ const HeatMapChart = /*#__PURE__*/ _react.forwardRef((props = {
|
|
|
534
549
|
const numDataPoints = props.data.reduce((acc, curr)=>acc + curr.data.length, 0);
|
|
535
550
|
return (chartTitle ? `${chartTitle}. ` : '') + `Heat map chart with ${numDataPoints} data points. `;
|
|
536
551
|
};
|
|
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
|
-
};
|
|
613
552
|
const updatePosition = (newX, newY)=>{
|
|
614
553
|
const threshold = 1; // Set a threshold for movement
|
|
615
554
|
const { x, y } = clickPosition;
|