@fluentui/react-charts 9.3.2 → 9.3.4
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 +47 -2
- package/dist/index.d.ts +151 -1
- package/lib/components/AreaChart/AreaChart.js +208 -60
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +14 -12
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +5 -6
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +2 -1
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +63 -18
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +471 -207
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +8 -7
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +16 -32
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +4 -4
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +3 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +23 -45
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +3 -2
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +21 -46
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +3 -2
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +3 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +145 -97
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +3 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +7 -11
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +77 -26
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +207 -59
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +13 -12
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +5 -6
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +65 -18
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +470 -206
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -7
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +16 -32
- 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/Pie/Pie.js +4 -4
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +7 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +23 -45
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +7 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +21 -46
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +7 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +144 -96
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +7 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -10
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +80 -26
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -7,7 +7,7 @@ import { select as d3Select } from 'd3-selection';
|
|
|
7
7
|
import { tokens } from '@fluentui/react-theme';
|
|
8
8
|
import { area as d3Area, stack as d3Stack, curveMonotoneX as d3CurveBasis, line as d3Line } from 'd3-shape';
|
|
9
9
|
import { CartesianChart } from '../../index';
|
|
10
|
-
import { calloutData, getXAxisType, ChartTypes, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, getNextColor, getColorFromToken, getSecureProps, areArraysEqual, getCurveFactory,
|
|
10
|
+
import { calloutData, getXAxisType, ChartTypes, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, getNextColor, getColorFromToken, getSecureProps, areArraysEqual, getCurveFactory, findNumericMinMaxOfY, createNumericYAxis, domainRangeOfNumericForAreaLineScatterCharts, domainRangeOfDateForAreaLineScatterVerticalBarCharts, createStringYAxis, useRtl, findCalloutPoints } from '../../utilities/index';
|
|
11
11
|
import { useId } from '@fluentui/react-utilities';
|
|
12
12
|
import { Legends } from '../Legends/index';
|
|
13
13
|
import { toImage } from '../../utilities/image-export-utils';
|
|
@@ -33,6 +33,8 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
33
33
|
const _firstRenderOptimization = true;
|
|
34
34
|
const _emptyChartId = useId('_AreaChart_empty');
|
|
35
35
|
let _containsSecondaryYAxis = false;
|
|
36
|
+
let _hasMissingXValues = _containsMissingXValues();
|
|
37
|
+
let _hasDuplicateXValues = _xCoordinateContainsMultipleY();
|
|
36
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
39
|
let _calloutPoints;
|
|
38
40
|
let _createSet;
|
|
@@ -161,11 +163,7 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
161
163
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
162
164
|
const { xAxisCalloutData, xAxisCalloutAccessibilityData } = lineChartData[0].data[index];
|
|
163
165
|
const formattedDate = pointToHighlight instanceof Date ? formatDateToLocaleString(pointToHighlight, props.culture, props.useUTC) : pointToHighlight;
|
|
164
|
-
const
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
-
const found = find(_calloutPoints, (element)=>{
|
|
167
|
-
return element.x === modifiedXVal;
|
|
168
|
-
});
|
|
166
|
+
const found = findCalloutPoints(_calloutPoints, pointToHighlight);
|
|
169
167
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
170
168
|
const _nearestCircleToHighlight = axisType === XAxisTypes.DateAxis ? pointToHighlight.getTime() : pointToHighlight;
|
|
171
169
|
// if no points need to be called out then don't show vertical line and callout card
|
|
@@ -272,7 +270,7 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
272
270
|
};
|
|
273
271
|
}
|
|
274
272
|
function _createDataSet(points) {
|
|
275
|
-
if (props.enablePerfOptimization && _enableComputationOptimization) {
|
|
273
|
+
if (props.enablePerfOptimization && _enableComputationOptimization && !_hasDuplicateXValues) {
|
|
276
274
|
const allChartPoints = [];
|
|
277
275
|
const dataSet = [];
|
|
278
276
|
const colors = [];
|
|
@@ -327,35 +325,50 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
327
325
|
const colors = [];
|
|
328
326
|
const opacity = [];
|
|
329
327
|
const calloutPoints = calloutData(points);
|
|
328
|
+
let data = {};
|
|
329
|
+
const keys = [];
|
|
330
|
+
let index = 0;
|
|
330
331
|
points && points.length && points.forEach((singleChartPoint)=>{
|
|
332
|
+
// if legend is not populated, then assign a legend
|
|
333
|
+
if (_hasDuplicateXValues && !singleChartPoint.legend) {
|
|
334
|
+
singleChartPoint.legend = `chart${index}`;
|
|
335
|
+
++index;
|
|
336
|
+
}
|
|
337
|
+
singleChartPoint.data.forEach((point)=>{
|
|
338
|
+
point.legend = singleChartPoint.legend;
|
|
339
|
+
});
|
|
331
340
|
colors.push(singleChartPoint.color);
|
|
332
341
|
opacity.push(singleChartPoint.opacity || 1);
|
|
333
342
|
allChartPoints.push(...singleChartPoint.data);
|
|
334
343
|
});
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
344
|
+
if (!_hasDuplicateXValues) {
|
|
345
|
+
let tempArr = allChartPoints;
|
|
346
|
+
while(tempArr.length){
|
|
347
|
+
const valToCheck = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
348
|
+
const filteredChartPoints = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) === valToCheck);
|
|
349
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
350
|
+
const singleDataset = {};
|
|
351
|
+
filteredChartPoints.forEach((singleDataPoint, id)=>{
|
|
352
|
+
singleDataset.xVal = singleDataPoint.x;
|
|
353
|
+
singleDataset[`chart${id}`] = singleDataPoint.y;
|
|
354
|
+
});
|
|
355
|
+
dataSet.push(singleDataset);
|
|
356
|
+
// removing compared objects from array
|
|
357
|
+
const val = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
358
|
+
tempArr = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) !== val);
|
|
359
|
+
}
|
|
360
|
+
// get keys from dataset, used to create stacked data
|
|
361
|
+
const keysLength = dataSet && Object.keys(dataSet[0]).length;
|
|
362
|
+
for(let i = 0; i < keysLength - 1; i++){
|
|
363
|
+
const keyVal = `chart${i}`;
|
|
364
|
+
keys.push(keyVal);
|
|
365
|
+
}
|
|
366
|
+
// Data used to draw graph
|
|
367
|
+
data = _getDataPoints(keys, dataSet);
|
|
368
|
+
} else {
|
|
369
|
+
const datasetForDuplicateValues = _createDatasetForXCoordinateWithMultipleYValues(allChartPoints);
|
|
370
|
+
data = _getDataPoints(datasetForDuplicateValues.keys, datasetForDuplicateValues.filteredDataSet);
|
|
356
371
|
}
|
|
357
|
-
// Data used to draw graph
|
|
358
|
-
const data = _getDataPoints(keys, dataSet);
|
|
359
372
|
return {
|
|
360
373
|
colors,
|
|
361
374
|
opacity,
|
|
@@ -365,6 +378,56 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
365
378
|
};
|
|
366
379
|
}
|
|
367
380
|
}
|
|
381
|
+
function _createDatasetForXCoordinateWithMultipleYValues(allChartPoints) {
|
|
382
|
+
const dataSet = [];
|
|
383
|
+
// Group data points by x-axis value
|
|
384
|
+
const groupedData = {};
|
|
385
|
+
allChartPoints.forEach((dataPoint)=>{
|
|
386
|
+
const xValue = dataPoint.x instanceof Date ? dataPoint.x.toLocaleString() : dataPoint.x;
|
|
387
|
+
if (!groupedData[xValue]) {
|
|
388
|
+
groupedData[xValue] = [];
|
|
389
|
+
}
|
|
390
|
+
groupedData[xValue].push(dataPoint);
|
|
391
|
+
});
|
|
392
|
+
// Aggregate data points for each x-axis value
|
|
393
|
+
Object.keys(groupedData).forEach((xValue)=>{
|
|
394
|
+
const dataPoints = groupedData[xValue];
|
|
395
|
+
dataPoints.forEach((dataPoint, id)=>{
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
397
|
+
const singleDataset = {
|
|
398
|
+
xVal: dataPoints[0].x
|
|
399
|
+
};
|
|
400
|
+
const key = dataPoint.legend ? dataPoint.legend : `chart${id}`;
|
|
401
|
+
singleDataset[key] = dataPoint.y;
|
|
402
|
+
dataSet.push(singleDataset);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
// get all unique keys from each array within the dataSet
|
|
406
|
+
const allLegends = [];
|
|
407
|
+
dataSet.forEach((item)=>{
|
|
408
|
+
Object.keys(item).forEach((key)=>{
|
|
409
|
+
if (key !== 'xVal' && !allLegends.includes(key)) {
|
|
410
|
+
allLegends.push(key);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
dataSet.forEach((item)=>{
|
|
415
|
+
allLegends.forEach((legend)=>{
|
|
416
|
+
if (!item[legend]) {
|
|
417
|
+
item[legend] = 0; // Fill with 0 if the legend is missing
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
// exclude all items within dataset having all legend values 0
|
|
422
|
+
const filteredDataSet = dataSet.filter((item)=>{
|
|
423
|
+
return allLegends.some((legend)=>item[legend] !== 0);
|
|
424
|
+
});
|
|
425
|
+
const keys = Array.from(new Set(filteredDataSet.flatMap((item)=>Object.keys(item).filter((key)=>key !== 'xVal'))));
|
|
426
|
+
return {
|
|
427
|
+
keys,
|
|
428
|
+
filteredDataSet
|
|
429
|
+
};
|
|
430
|
+
}
|
|
368
431
|
function _getCustomizedCallout() {
|
|
369
432
|
return props.onRenderCalloutPerStack ? props.onRenderCalloutPerStack(stackCalloutProps) : props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps) : null;
|
|
370
433
|
}
|
|
@@ -466,9 +529,9 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
466
529
|
let lineColor;
|
|
467
530
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
468
531
|
_data.forEach((singleStackedData, index)=>{
|
|
469
|
-
var _points_index_lineOptions, _points_index_lineOptions1, _points_index_lineOptions2, _points_index_lineOptions3, _points_index_lineOptions4;
|
|
470
|
-
const yScale = points[index].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
471
|
-
const curveFactory = getCurveFactory((
|
|
532
|
+
var _points_index, _points_index_lineOptions, _points_index1, _points_index_lineOptions1, _points_index2, _points_index_lineOptions2, _points_index3, _points_index_lineOptions3, _points_index4, _points_index_lineOptions4, _points_index5;
|
|
533
|
+
const yScale = ((_points_index = points[index]) === null || _points_index === void 0 ? void 0 : _points_index.useSecondaryYScale) && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
534
|
+
const curveFactory = getCurveFactory((_points_index1 = points[index]) === null || _points_index1 === void 0 ? void 0 : (_points_index_lineOptions = _points_index1.lineOptions) === null || _points_index_lineOptions === void 0 ? void 0 : _points_index_lineOptions.curve, d3CurveBasis);
|
|
472
535
|
const area = d3Area()// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
473
536
|
.x((d)=>xScale(d.xVal))// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
474
537
|
.y0((d)=>yScale(d.values[0]))// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -496,15 +559,15 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
496
559
|
id: `${index}-line-${_uniqueIdForGraph}`,
|
|
497
560
|
d: line(singleStackedData),
|
|
498
561
|
fill: 'transparent',
|
|
499
|
-
strokeWidth: (_points_index_lineOptions_strokeWidth = (
|
|
562
|
+
strokeWidth: (_points_index_lineOptions_strokeWidth = (_points_index2 = points[index]) === null || _points_index2 === void 0 ? void 0 : (_points_index_lineOptions1 = _points_index2.lineOptions) === null || _points_index_lineOptions1 === void 0 ? void 0 : _points_index_lineOptions1.strokeWidth) !== null && _points_index_lineOptions_strokeWidth !== void 0 ? _points_index_lineOptions_strokeWidth : 3,
|
|
500
563
|
stroke: _colors[index],
|
|
501
564
|
opacity: _getLineOpacity(points[index].legend),
|
|
502
565
|
onMouseMove: (event)=>_onRectMouseMove(event),
|
|
503
566
|
onMouseOut: _onRectMouseOut,
|
|
504
567
|
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
505
|
-
strokeDasharray: (
|
|
506
|
-
strokeDashoffset: (
|
|
507
|
-
strokeLinecap: (
|
|
568
|
+
strokeDasharray: (_points_index3 = points[index]) === null || _points_index3 === void 0 ? void 0 : (_points_index_lineOptions2 = _points_index3.lineOptions) === null || _points_index_lineOptions2 === void 0 ? void 0 : _points_index_lineOptions2.strokeDasharray,
|
|
569
|
+
strokeDashoffset: (_points_index4 = points[index]) === null || _points_index4 === void 0 ? void 0 : (_points_index_lineOptions3 = _points_index4.lineOptions) === null || _points_index_lineOptions3 === void 0 ? void 0 : _points_index_lineOptions3.strokeDashoffset,
|
|
570
|
+
strokeLinecap: (_points_index5 = points[index]) === null || _points_index5 === void 0 ? void 0 : (_points_index_lineOptions4 = _points_index5.lineOptions) === null || _points_index_lineOptions4 === void 0 ? void 0 : _points_index_lineOptions4.strokeLinecap
|
|
508
571
|
}), singleStackedData.length === 1 ? /*#__PURE__*/ React.createElement("circle", {
|
|
509
572
|
id: `${index}-graph-${_uniqueIdForGraph}`,
|
|
510
573
|
cx: xScale(singleStackedData[0].xVal),
|
|
@@ -538,10 +601,11 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
538
601
|
const circleRadius = pointOptions && pointOptions.r ? Number(pointOptions.r) : 8;
|
|
539
602
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
540
603
|
_data.forEach((singleStackedData, index)=>{
|
|
604
|
+
var _points_index;
|
|
541
605
|
if (points.length === index) {
|
|
542
606
|
return;
|
|
543
607
|
}
|
|
544
|
-
const yScale = points[index].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
608
|
+
const yScale = ((_points_index = points[index]) === null || _points_index === void 0 ? void 0 : _points_index.useSecondaryYScale) && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
545
609
|
if (!props.optimizeLargeData || singleStackedData.length === 1) {
|
|
546
610
|
// Render circles for all data points
|
|
547
611
|
graph.push(/*#__PURE__*/ React.createElement("g", {
|
|
@@ -565,13 +629,13 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
565
629
|
fill: _updateCircleFillColor(xDataPoint, lineColor, circleId),
|
|
566
630
|
onMouseOut: _onRectMouseOut,
|
|
567
631
|
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
568
|
-
|
|
632
|
+
..._getOnClickHandler(points, index, pointIndex),
|
|
569
633
|
onFocus: (event)=>_handleFocus(event, index, pointIndex, circleId),
|
|
570
634
|
onBlur: _handleBlur,
|
|
571
635
|
...getSecureProps(pointOptions),
|
|
572
636
|
r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend),
|
|
573
637
|
role: "img",
|
|
574
|
-
"aria-label": _getAriaLabel(index, pointIndex)
|
|
638
|
+
"aria-label": !_hasDuplicateXValues && !_hasMissingXValues && _getAriaLabel(index, pointIndex) || undefined
|
|
575
639
|
});
|
|
576
640
|
})));
|
|
577
641
|
} else {
|
|
@@ -593,7 +657,7 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
593
657
|
onMouseOut: _onRectMouseOut,
|
|
594
658
|
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
595
659
|
onFocus: (event)=>_handleFocus(event, index, pointIndex, circleId),
|
|
596
|
-
|
|
660
|
+
..._getOnClickHandler(points, index, pointIndex),
|
|
597
661
|
...getSecureProps(pointOptions),
|
|
598
662
|
r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend)
|
|
599
663
|
}));
|
|
@@ -640,6 +704,14 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
640
704
|
}
|
|
641
705
|
return graph;
|
|
642
706
|
}
|
|
707
|
+
function _getOnClickHandler(points, index, pointIndex) {
|
|
708
|
+
if (!_hasDuplicateXValues && !_hasMissingXValues) {
|
|
709
|
+
return {
|
|
710
|
+
onClick: ()=>_onDataPointClick(points[index].data[pointIndex].onDataPointClick)
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
return {};
|
|
714
|
+
}
|
|
643
715
|
function _getCircleRadius(xDataPoint, circleRadius, circleId, legend) {
|
|
644
716
|
// Show the circle if no legends are selected or if the point's legend is in the selected legends
|
|
645
717
|
if (!_noLegendHighlighted() && !_legendHighlighted(legend)) {
|
|
@@ -672,6 +744,36 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
672
744
|
] : [];
|
|
673
745
|
}
|
|
674
746
|
function _addDefaultColors(lineChartData) {
|
|
747
|
+
if (_hasMissingXValues) {
|
|
748
|
+
// get union of all x values
|
|
749
|
+
const allXValues = new Set();
|
|
750
|
+
lineChartData && lineChartData.forEach((line)=>{
|
|
751
|
+
line.data.forEach((point)=>{
|
|
752
|
+
const xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
753
|
+
allXValues.add(xValue);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
lineChartData && lineChartData.forEach((line)=>{
|
|
757
|
+
allXValues.forEach((xValue)=>{
|
|
758
|
+
const point = line.data.find((item)=>{
|
|
759
|
+
return item.x instanceof Date ? item.x.toLocaleString() === xValue : item.x === xValue;
|
|
760
|
+
});
|
|
761
|
+
if (!point) {
|
|
762
|
+
line.data.push({
|
|
763
|
+
x: typeof xValue === 'string' ? new Date(xValue) : xValue,
|
|
764
|
+
y: 0,
|
|
765
|
+
legend: line.legend
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
// sort the data points by x value
|
|
770
|
+
line.data.sort((a, b)=>{
|
|
771
|
+
const xA = a.x instanceof Date ? a.x.getTime() : a.x;
|
|
772
|
+
const xB = b.x instanceof Date ? b.x.getTime() : b.x;
|
|
773
|
+
return xA < xB ? -1 : xA > xB ? 1 : 0;
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
}
|
|
675
777
|
return lineChartData ? lineChartData.map((item, index)=>{
|
|
676
778
|
let color;
|
|
677
779
|
// isInverted property is applicable to v8 themes only
|
|
@@ -695,24 +797,24 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
695
797
|
_updatePosition(cx, cy);
|
|
696
798
|
const { x, y, xAxisCalloutData } = props.data.lineChartData[lineIndex].data[pointIndex];
|
|
697
799
|
const formattedDate = x instanceof Date ? formatDateToLocaleString(x, props.culture, props.useUTC) : x;
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
800
|
+
const found = findCalloutPoints(_calloutPoints, x);
|
|
801
|
+
if (found) {
|
|
802
|
+
// Show details in the callout for the focused point only
|
|
803
|
+
found.values = found.values.filter((e)=>e.y === y);
|
|
804
|
+
const filteredValues = _getFilteredLegendValues(found.values);
|
|
805
|
+
setPopoverOpen(true);
|
|
806
|
+
setHoverXValue(xAxisCalloutData ? xAxisCalloutData : formattedDate);
|
|
807
|
+
setYValueHover(filteredValues);
|
|
808
|
+
setStackCalloutProps({
|
|
809
|
+
...found,
|
|
810
|
+
values: filteredValues
|
|
811
|
+
});
|
|
812
|
+
setDataPointCalloutProps({
|
|
813
|
+
...found,
|
|
814
|
+
values: filteredValues
|
|
815
|
+
});
|
|
816
|
+
setActivePoint(circleId);
|
|
817
|
+
}
|
|
716
818
|
}
|
|
717
819
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
718
820
|
function _getFilteredLegendValues(values) {
|
|
@@ -744,6 +846,52 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
744
846
|
const { chartTitle, lineChartData } = props.data;
|
|
745
847
|
return (chartTitle ? `${chartTitle}. ` : '') + `Area chart with ${(lineChartData === null || lineChartData === void 0 ? void 0 : lineChartData.length) || 0} data series. `;
|
|
746
848
|
}
|
|
849
|
+
function _xCoordinateContainsMultipleY() {
|
|
850
|
+
const { lineChartData } = props.data;
|
|
851
|
+
if (!lineChartData) {
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
for (const item of lineChartData){
|
|
855
|
+
const xValueMap = {};
|
|
856
|
+
for (const point of item.data){
|
|
857
|
+
const xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
858
|
+
if (!xValueMap[xValue]) {
|
|
859
|
+
xValueMap[xValue] = [];
|
|
860
|
+
}
|
|
861
|
+
xValueMap[xValue].push(point.y);
|
|
862
|
+
if (xValueMap[xValue].length > 1) {
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
function _containsMissingXValues() {
|
|
870
|
+
const { lineChartData } = props.data;
|
|
871
|
+
if (!lineChartData) {
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
const allXValues = new Set();
|
|
875
|
+
lineChartData.forEach((line)=>{
|
|
876
|
+
line.data.forEach((point)=>{
|
|
877
|
+
const xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
878
|
+
allXValues.add(xValue);
|
|
879
|
+
});
|
|
880
|
+
});
|
|
881
|
+
// for all x values, check if the x value is present in all series
|
|
882
|
+
let hasMissingValues = false;
|
|
883
|
+
lineChartData.forEach((line)=>{
|
|
884
|
+
allXValues.forEach((xValue)=>{
|
|
885
|
+
const point = line.data.find((item)=>{
|
|
886
|
+
return item.x instanceof Date ? item.x.toLocaleString() === xValue : item.x === xValue;
|
|
887
|
+
});
|
|
888
|
+
if (!point) {
|
|
889
|
+
hasMissingValues = true;
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
});
|
|
893
|
+
return hasMissingValues;
|
|
894
|
+
}
|
|
747
895
|
function _shouldFillToZeroY() {
|
|
748
896
|
return props.mode === 'tozeroy' || _containsSecondaryYAxis;
|
|
749
897
|
}
|
|
@@ -769,7 +917,7 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
|
|
|
769
917
|
xAxisCalloutAccessibilityData,
|
|
770
918
|
...props.calloutProps,
|
|
771
919
|
clickPosition,
|
|
772
|
-
isPopoverOpen,
|
|
920
|
+
isPopoverOpen: isPopoverOpen && !_hasDuplicateXValues && !_hasMissingXValues,
|
|
773
921
|
isCartesian: true,
|
|
774
922
|
customCallout: {
|
|
775
923
|
customizedCallout: _getCustomizedCallout() !== null ? _getCustomizedCallout() : undefined,
|