@fluentui/react-charting 5.23.81 → 5.23.83
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.json +49 -1
- package/CHANGELOG.md +23 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/AreaChart/AreaChart.base.d.ts +6 -0
- package/lib/components/AreaChart/AreaChart.base.js +192 -34
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.styles.js +7 -1
- package/lib/components/DonutChart/Arc/Arc.styles.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.styles.js +33 -13
- package/lib/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +7 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.styles.js +7 -2
- package/lib/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.styles.js +7 -1
- package/lib/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.styles.js +7 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib/components/TreeChart/TreeChart.styles.js +27 -4
- package/lib/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.styles.js +7 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +7 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.d.ts +6 -0
- package/lib-amd/components/AreaChart/AreaChart.base.js +192 -34
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/DonutChart/Arc/Arc.styles.js +6 -0
- package/lib-amd/components/DonutChart/Arc/Arc.styles.js.map +1 -1
- package/lib-amd/components/GaugeChart/GaugeChart.styles.js +33 -13
- package/lib-amd/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +6 -0
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.styles.js +6 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib-amd/components/Sparkline/Sparkline.styles.js +7 -2
- package/lib-amd/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.styles.js +6 -0
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib-amd/components/TreeChart/TreeChart.styles.js +27 -5
- package/lib-amd/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js +6 -0
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +6 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +6 -0
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +192 -34
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.styles.js +6 -0
- package/lib-commonjs/components/DonutChart/Arc/Arc.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.styles.js +33 -13
- package/lib-commonjs/components/GaugeChart/GaugeChart.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +6 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.styles.js +6 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.styles.js +7 -1
- package/lib-commonjs/components/Sparkline/Sparkline.styles.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.styles.js +6 -0
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/TreeChart/TreeChart.styles.js +27 -4
- package/lib-commonjs/components/TreeChart/TreeChart.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js +6 -0
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +6 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/package.json +4 -4
|
@@ -29,6 +29,8 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
29
29
|
var _a;
|
|
30
30
|
var _this = _super.call(this, props) || this;
|
|
31
31
|
_this._containsSecondaryYAxis = false;
|
|
32
|
+
_this._hasDuplicateXValues = false;
|
|
33
|
+
_this._hasMissingXValues = false;
|
|
32
34
|
_this.toImage = function (opts) {
|
|
33
35
|
var _a, _b;
|
|
34
36
|
return (0, image_export_utils_1.toImage)((_a = _this._cartesianChartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, (_b = _this._legendsRef.current) === null || _b === void 0 ? void 0 : _b.toSVG, (0, Utilities_1.getRTL)(), opts);
|
|
@@ -219,7 +221,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
219
221
|
};
|
|
220
222
|
};
|
|
221
223
|
_this._createDataSet = function (points) {
|
|
222
|
-
if (_this.props.enablePerfOptimization && _this._enableComputationOptimization) {
|
|
224
|
+
if (_this.props.enablePerfOptimization && _this._enableComputationOptimization && !_this._hasDuplicateXValues) {
|
|
223
225
|
var allChartPoints_1 = [];
|
|
224
226
|
var dataSet_1 = [];
|
|
225
227
|
var colors_1 = [];
|
|
@@ -276,40 +278,58 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
276
278
|
var colors_2 = [];
|
|
277
279
|
var opacity_2 = [];
|
|
278
280
|
var calloutPoints = (0, index_2.calloutData)(points);
|
|
281
|
+
var data = {};
|
|
282
|
+
var keys = [];
|
|
283
|
+
var index_4 = 0;
|
|
279
284
|
points &&
|
|
280
285
|
points.length &&
|
|
281
286
|
points.forEach(function (singleChartPoint) {
|
|
287
|
+
// if legend is not populated, then assign a legend
|
|
288
|
+
if (_this._hasDuplicateXValues && !singleChartPoint.legend) {
|
|
289
|
+
singleChartPoint.legend = "chart".concat(index_4);
|
|
290
|
+
++index_4;
|
|
291
|
+
}
|
|
292
|
+
singleChartPoint.data.forEach(function (point) {
|
|
293
|
+
point.legend = singleChartPoint.legend;
|
|
294
|
+
});
|
|
282
295
|
colors_2.push(singleChartPoint.color);
|
|
283
296
|
opacity_2.push(singleChartPoint.opacity || 1);
|
|
284
297
|
allChartPoints_2.push.apply(allChartPoints_2, singleChartPoint.data);
|
|
285
298
|
});
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
singleDataset
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
if (!_this._hasDuplicateXValues) {
|
|
300
|
+
var tempArr = allChartPoints_2;
|
|
301
|
+
var _loop_1 = function () {
|
|
302
|
+
var valToCheck = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
303
|
+
var filteredChartPoints = tempArr.filter(function (point) {
|
|
304
|
+
return (point.x instanceof Date ? point.x.toLocaleString() : point.x) === valToCheck;
|
|
305
|
+
});
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
307
|
+
var singleDataset = {};
|
|
308
|
+
filteredChartPoints.forEach(function (singleDataPoint, id) {
|
|
309
|
+
singleDataset.xVal = singleDataPoint.x;
|
|
310
|
+
singleDataset["chart".concat(id)] = singleDataPoint.y;
|
|
311
|
+
});
|
|
312
|
+
dataSet.push(singleDataset);
|
|
313
|
+
// removing compared objects from array
|
|
314
|
+
var val = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
315
|
+
tempArr = tempArr.filter(function (point) { return (point.x instanceof Date ? point.x.toLocaleString() : point.x) !== val; });
|
|
316
|
+
};
|
|
317
|
+
while (tempArr.length) {
|
|
318
|
+
_loop_1();
|
|
319
|
+
}
|
|
320
|
+
// get keys from dataset, used to create stacked data
|
|
321
|
+
var keysLength = dataSet && Object.keys(dataSet[0]).length;
|
|
322
|
+
for (var i = 0; i < keysLength - 1; i++) {
|
|
323
|
+
var keyVal = "chart".concat(i);
|
|
324
|
+
keys.push(keyVal);
|
|
325
|
+
}
|
|
326
|
+
// Data used to draw graph
|
|
327
|
+
data = _this._getDataPoints(keys, dataSet);
|
|
303
328
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
for (var i = 0; i < keysLength - 1; i++) {
|
|
308
|
-
var keyVal = "chart".concat(i);
|
|
309
|
-
keys.push(keyVal);
|
|
329
|
+
else {
|
|
330
|
+
var datasetForDuplicateValues = _this._createDatasetForXCoordinateWithMultipleYValues(allChartPoints_2);
|
|
331
|
+
data = _this._getDataPoints(datasetForDuplicateValues.keys, datasetForDuplicateValues.filteredDataSet);
|
|
310
332
|
}
|
|
311
|
-
// Data used to draw graph
|
|
312
|
-
var data = _this._getDataPoints(keys, dataSet);
|
|
313
333
|
return {
|
|
314
334
|
colors: colors_2,
|
|
315
335
|
opacity: opacity_2,
|
|
@@ -319,6 +339,54 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
319
339
|
};
|
|
320
340
|
}
|
|
321
341
|
};
|
|
342
|
+
_this._createDatasetForXCoordinateWithMultipleYValues = function (allChartPoints) {
|
|
343
|
+
var dataSet = [];
|
|
344
|
+
// Group data points by x-axis value
|
|
345
|
+
var groupedData = {};
|
|
346
|
+
allChartPoints.forEach(function (dataPoint) {
|
|
347
|
+
var xValue = dataPoint.x instanceof Date ? dataPoint.x.toLocaleString() : dataPoint.x;
|
|
348
|
+
if (!groupedData[xValue]) {
|
|
349
|
+
groupedData[xValue] = [];
|
|
350
|
+
}
|
|
351
|
+
groupedData[xValue].push(dataPoint);
|
|
352
|
+
});
|
|
353
|
+
// Aggregate data points for each x-axis value
|
|
354
|
+
Object.keys(groupedData).forEach(function (xValue) {
|
|
355
|
+
var dataPoints = groupedData[xValue];
|
|
356
|
+
dataPoints.forEach(function (dataPoint, id) {
|
|
357
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
358
|
+
var singleDataset = { xVal: dataPoints[0].x };
|
|
359
|
+
var key = dataPoint.legend ? dataPoint.legend : "chart".concat(id);
|
|
360
|
+
singleDataset[key] = dataPoint.y;
|
|
361
|
+
dataSet.push(singleDataset);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
// get all unique keys from each array within the dataSet
|
|
365
|
+
var allLegends = [];
|
|
366
|
+
dataSet.forEach(function (item) {
|
|
367
|
+
Object.keys(item).forEach(function (key) {
|
|
368
|
+
if (key !== 'xVal' && !allLegends.includes(key)) {
|
|
369
|
+
allLegends.push(key);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
dataSet.forEach(function (item) {
|
|
374
|
+
allLegends.forEach(function (legend) {
|
|
375
|
+
if (!item[legend]) {
|
|
376
|
+
item[legend] = 0; // Fill with 0 if the legend is missing
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
// exclude all items within dataset having all legend values 0
|
|
381
|
+
var filteredDataSet = dataSet.filter(function (item) {
|
|
382
|
+
return allLegends.some(function (legend) { return item[legend] !== 0; });
|
|
383
|
+
});
|
|
384
|
+
var keys = Array.from(new Set(filteredDataSet.flatMap(function (item) { return Object.keys(item).filter(function (key) { return key !== 'xVal'; }); })));
|
|
385
|
+
return {
|
|
386
|
+
keys: keys,
|
|
387
|
+
filteredDataSet: filteredDataSet,
|
|
388
|
+
};
|
|
389
|
+
};
|
|
322
390
|
_this._getCustomizedCallout = function () {
|
|
323
391
|
return _this.props.onRenderCalloutPerStack
|
|
324
392
|
? _this.props.onRenderCalloutPerStack(_this.state.stackCalloutProps)
|
|
@@ -406,9 +474,9 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
406
474
|
var lineColor;
|
|
407
475
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
408
476
|
_this._data.forEach(function (singleStackedData, index) {
|
|
409
|
-
var _a, _b, _c, _d, _e, _f;
|
|
410
|
-
var yScale = points[index].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
411
|
-
var curveFactory = (0, index_2.getCurveFactory)((
|
|
477
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
478
|
+
var yScale = ((_a = points[index]) === null || _a === void 0 ? void 0 : _a.useSecondaryYScale) && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
479
|
+
var curveFactory = (0, index_2.getCurveFactory)((_c = (_b = points[index]) === null || _b === void 0 ? void 0 : _b.lineOptions) === null || _c === void 0 ? void 0 : _c.curve, d3_shape_1.curveMonotoneX);
|
|
412
480
|
var area = (0, d3_shape_1.area)()
|
|
413
481
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
414
482
|
.x(function (d) { return xScale(d.xVal); })
|
|
@@ -429,7 +497,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
429
497
|
React.createElement("linearGradient", { id: "gradient_".concat(index), x1: "0%", x2: "0%", y1: "0%", y2: "100%" },
|
|
430
498
|
React.createElement("stop", { offset: "0", stopColor: _this._colors[index] }),
|
|
431
499
|
React.createElement("stop", { offset: "100%", stopColor: "transparent" })))),
|
|
432
|
-
React.createElement("path", { id: "".concat(index, "-line-").concat(_this._uniqueIdForGraph), d: line(singleStackedData), fill: 'transparent', strokeWidth: (
|
|
500
|
+
React.createElement("path", { id: "".concat(index, "-line-").concat(_this._uniqueIdForGraph), d: line(singleStackedData), fill: 'transparent', strokeWidth: (_f = (_e = (_d = points[index]) === null || _d === void 0 ? void 0 : _d.lineOptions) === null || _e === void 0 ? void 0 : _e.strokeWidth) !== null && _f !== void 0 ? _f : 3, stroke: _this._colors[index], opacity: _this._getLineOpacity(points[index].legend), onMouseMove: _this._onRectMouseMove, onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove, strokeDasharray: (_h = (_g = points[index]) === null || _g === void 0 ? void 0 : _g.lineOptions) === null || _h === void 0 ? void 0 : _h.strokeDasharray, strokeDashoffset: (_k = (_j = points[index]) === null || _j === void 0 ? void 0 : _j.lineOptions) === null || _k === void 0 ? void 0 : _k.strokeDashoffset, strokeLinecap: (_m = (_l = points[index]) === null || _l === void 0 ? void 0 : _l.lineOptions) === null || _m === void 0 ? void 0 : _m.strokeLinecap }),
|
|
433
501
|
singleStackedData.length === 1 ? (React.createElement("circle", { id: "".concat(index, "-graph-").concat(_this._uniqueIdForGraph), cx: xScale(singleStackedData[0].xVal), cy: yScale(singleStackedData[0].values[1]), r: 6, stroke: _this._colors[index], strokeWidth: 3, fill: _this._colors[index], opacity: layerOpacity, fillOpacity: _this._getOpacity(points[index].legend), onMouseMove: _this._onRectMouseMove, onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove })) : (React.createElement("path", tslib_1.__assign({ id: "".concat(index, "-graph-").concat(_this._uniqueIdForGraph), d: area(singleStackedData), fill: _this.props.enableGradient ? "url(#gradient_".concat(index, ")") : _this._colors[index], opacity: layerOpacity, fillOpacity: _this._getOpacity(points[index].legend), onMouseMove: _this._onRectMouseMove, onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove }, (_this.props.optimizeLargeData && {
|
|
434
502
|
'data-is-focusable': _this._legendHighlighted(points[index].legend) || _this._noLegendHighlighted(),
|
|
435
503
|
role: 'img',
|
|
@@ -439,10 +507,11 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
439
507
|
var circleRadius = pointOptions && pointOptions.r ? Number(pointOptions.r) : 8;
|
|
440
508
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
509
|
_this._data.forEach(function (singleStackedData, index) {
|
|
510
|
+
var _a;
|
|
442
511
|
if (points.length === index) {
|
|
443
512
|
return;
|
|
444
513
|
}
|
|
445
|
-
var yScale = points[index].useSecondaryYScale && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
514
|
+
var yScale = ((_a = points[index]) === null || _a === void 0 ? void 0 : _a.useSecondaryYScale) && yScaleSecondary ? yScaleSecondary : yScalePrimary;
|
|
446
515
|
if (!_this.props.optimizeLargeData || singleStackedData.length === 1) {
|
|
447
516
|
// Render circles for all data points
|
|
448
517
|
graph.push(React.createElement("g", { key: "".concat(index, "-dots-").concat(_this._uniqueIdForGraph), clipPath: "url(#clip)", role: "region", "aria-label": "".concat(points[index].legend, ", series ").concat(index + 1, " of ").concat(points.length, " with ").concat(points[index].data.length, " data points.") }, singleStackedData.map(function (singlePoint, pointIndex) {
|
|
@@ -450,7 +519,8 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
450
519
|
var xDataPoint = singlePoint.xVal instanceof Date ? singlePoint.xVal.getTime() : singlePoint.xVal;
|
|
451
520
|
lineColor = points[index].color;
|
|
452
521
|
var legend = points[index].legend;
|
|
453
|
-
return (React.createElement("circle", tslib_1.__assign({ key: circleId, id: circleId, "data-is-focusable": _this._legendHighlighted(points[index].legend) || _this._noLegendHighlighted(), cx: xScale(singlePoint.xVal), cy: yScale(singlePoint.values[1]), stroke: lineColor, strokeWidth: 3, fill: _this._updateCircleFillColor(xDataPoint, lineColor, circleId), onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove,
|
|
522
|
+
return (React.createElement("circle", tslib_1.__assign({ key: circleId, id: circleId, "data-is-focusable": _this._legendHighlighted(points[index].legend) || _this._noLegendHighlighted(), cx: xScale(singlePoint.xVal), cy: yScale(singlePoint.values[1]), stroke: lineColor, strokeWidth: 3, fill: _this._updateCircleFillColor(xDataPoint, lineColor, circleId), onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove }, _this._getOnClickHandler(points, index, pointIndex), { onFocus: function () { return _this._handleFocus(index, pointIndex, circleId); }, onBlur: _this._handleBlur }, (0, index_2.getSecureProps)(pointOptions), { r: _this._getCircleRadius(xDataPoint, circleRadius, circleId, legend), role: "img", "aria-label": (!_this._hasDuplicateXValues && !_this._hasMissingXValues && _this._getAriaLabel(index, pointIndex)) ||
|
|
523
|
+
undefined })));
|
|
454
524
|
})));
|
|
455
525
|
}
|
|
456
526
|
else {
|
|
@@ -461,7 +531,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
461
531
|
var circleId = "".concat(_this._circleId, "_").concat(index * _this._data[0].length + pointIndex);
|
|
462
532
|
lineColor = points[index].color;
|
|
463
533
|
var legend = points[index].legend;
|
|
464
|
-
graph.push(React.createElement("circle", tslib_1.__assign({ key: circleId, id: circleId, cx: xScale(singlePoint.xVal), cy: yScale(singlePoint.values[1]), stroke: lineColor, strokeWidth: 3, fill: _this._updateCircleFillColor(xDataPoint, lineColor, circleId), onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove,
|
|
534
|
+
graph.push(React.createElement("circle", tslib_1.__assign({ key: circleId, id: circleId, cx: xScale(singlePoint.xVal), cy: yScale(singlePoint.values[1]), stroke: lineColor, strokeWidth: 3, fill: _this._updateCircleFillColor(xDataPoint, lineColor, circleId), onMouseOut: _this._onRectMouseOut, onMouseOver: _this._onRectMouseMove }, _this._getOnClickHandler(points, index, pointIndex), (0, index_2.getSecureProps)(pointOptions), { r: _this._getCircleRadius(xDataPoint, circleRadius, circleId, legend) })));
|
|
465
535
|
}
|
|
466
536
|
});
|
|
467
537
|
}
|
|
@@ -495,6 +565,12 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
495
565
|
}
|
|
496
566
|
return graph;
|
|
497
567
|
};
|
|
568
|
+
_this._getOnClickHandler = function (points, index, pointIndex) {
|
|
569
|
+
return (!_this._hasDuplicateXValues &&
|
|
570
|
+
!_this._hasMissingXValues && {
|
|
571
|
+
onClick: _this._onDataPointClick.bind(_this, points[index].data[pointIndex].onDataPointClick),
|
|
572
|
+
});
|
|
573
|
+
};
|
|
498
574
|
_this._getCircleRadius = function (xDataPoint, circleRadius, circleId, legend) {
|
|
499
575
|
var _a = _this.state, isCircleClicked = _a.isCircleClicked, nearestCircleToHighlight = _a.nearestCircleToHighlight, activePoint = _a.activePoint;
|
|
500
576
|
// Show the circle if no legends are selected or if the point's legend is in the selected legends
|
|
@@ -532,6 +608,38 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
532
608
|
return _this._getHighlightedLegend().length === 0;
|
|
533
609
|
};
|
|
534
610
|
_this._addDefaultColors = function (lineChartData) {
|
|
611
|
+
if (_this._hasMissingXValues) {
|
|
612
|
+
// get union of all x values
|
|
613
|
+
var allXValues_1 = new Set();
|
|
614
|
+
lineChartData &&
|
|
615
|
+
lineChartData.forEach(function (line) {
|
|
616
|
+
line.data.forEach(function (point) {
|
|
617
|
+
var xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
618
|
+
allXValues_1.add(xValue);
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
lineChartData &&
|
|
622
|
+
lineChartData.forEach(function (line) {
|
|
623
|
+
allXValues_1.forEach(function (xValue) {
|
|
624
|
+
var point = line.data.find(function (item) {
|
|
625
|
+
return item.x instanceof Date ? item.x.toLocaleString() === xValue : item.x === xValue;
|
|
626
|
+
});
|
|
627
|
+
if (!point) {
|
|
628
|
+
line.data.push({
|
|
629
|
+
x: typeof xValue === 'string' ? new Date(xValue) : xValue,
|
|
630
|
+
y: 0,
|
|
631
|
+
legend: line.legend,
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
// sort the data points by x value
|
|
636
|
+
line.data.sort(function (a, b) {
|
|
637
|
+
var xA = a.x instanceof Date ? a.x.getTime() : a.x;
|
|
638
|
+
var xB = b.x instanceof Date ? b.x.getTime() : b.x;
|
|
639
|
+
return xA < xB ? -1 : xA > xB ? 1 : 0;
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
}
|
|
535
643
|
return lineChartData
|
|
536
644
|
? lineChartData.map(function (item, index) {
|
|
537
645
|
var _a, _b;
|
|
@@ -606,6 +714,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
606
714
|
(0, Utilities_2.warnDeprecations)(COMPONENT_NAME, props, {
|
|
607
715
|
showYAxisGridLines: 'Dont use this property. Lines are drawn by default',
|
|
608
716
|
});
|
|
717
|
+
_this._hasMissingXValues = _this._containsMissingXValues();
|
|
609
718
|
_this._uniqueIdForGraph = (0, Utilities_1.getId)('areaChart_');
|
|
610
719
|
_this._verticalLineId = (0, Utilities_1.getId)('verticalLine_');
|
|
611
720
|
_this._circleId = (0, Utilities_1.getId)('circle');
|
|
@@ -638,6 +747,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
638
747
|
if (!this._isChartEmpty()) {
|
|
639
748
|
var lineChartData = this.props.data.lineChartData;
|
|
640
749
|
var points = this._addDefaultColors(lineChartData);
|
|
750
|
+
this._hasDuplicateXValues = this._xCoordinateContainsMultipleY();
|
|
641
751
|
this._containsSecondaryYAxis =
|
|
642
752
|
!!this.props.secondaryYScaleOptions && points.some(function (point) { return point.useSecondaryYScale; });
|
|
643
753
|
var _a = this._createSet(points), colors = _a.colors, opacity = _a.opacity, data = _a.data, calloutPoints = _a.calloutPoints;
|
|
@@ -651,7 +761,7 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
651
761
|
tickValues: this.props.tickValues,
|
|
652
762
|
tickFormat: this.props.tickFormat,
|
|
653
763
|
};
|
|
654
|
-
var calloutProps = tslib_1.__assign({ target: this.state.refSelected, isCalloutVisible: this.state.isCalloutVisible, directionalHint: Callout_1.DirectionalHint.topAutoEdge, YValueHover: this.state.YValueHover, hoverXValue: this.state.hoverXValue, id: "toolTip".concat(this._uniqueCallOutID), gapSpace: 15, isBeakVisible: false, onDismiss: this._closeCallout, 'data-is-focusable': true, xAxisCalloutAccessibilityData: this.state.xAxisCalloutAccessibilityData }, this.props.calloutProps);
|
|
764
|
+
var calloutProps = tslib_1.__assign({ target: this.state.refSelected, isCalloutVisible: this.state.isCalloutVisible && !this._hasDuplicateXValues && !this._hasMissingXValues, directionalHint: Callout_1.DirectionalHint.topAutoEdge, YValueHover: this.state.YValueHover, hoverXValue: this.state.hoverXValue, id: "toolTip".concat(this._uniqueCallOutID), gapSpace: 15, isBeakVisible: false, onDismiss: this._closeCallout, 'data-is-focusable': true, xAxisCalloutAccessibilityData: this.state.xAxisCalloutAccessibilityData }, this.props.calloutProps);
|
|
655
765
|
return (React.createElement(index_1.CartesianChart, tslib_1.__assign({}, this.props, { chartTitle: this._getChartTitle(), points: points, chartType: index_2.ChartTypes.AreaChart, calloutProps: calloutProps, legendBars: legends, createYAxis: index_2.createNumericYAxis, isCalloutForStack: true, xAxisType: isXAxisDateType ? index_2.XAxisTypes.DateAxis : index_2.XAxisTypes.NumericAxis, tickParams: tickParams, maxOfYVal: data.maxOfYVal, getGraphData: this._getGraphData, getDomainNRangeValues: this._getDomainNRangeValues, createStringYAxis: index_2.createStringYAxis, getmargins: this._getMargins, getMinMaxOfYAxis: index_2.findNumericMinMaxOfY, customizedCallout: this._getCustomizedCallout(), onChartMouseLeave: this._handleChartMouseLeave, enableFirstRenderOptimization: this.props.enablePerfOptimization && this._firstRenderOptimization, ref: this._cartesianChartRef,
|
|
656
766
|
/* eslint-disable react/jsx-no-bind */
|
|
657
767
|
// eslint-disable-next-line react/no-children-prop
|
|
@@ -725,6 +835,54 @@ var AreaChartBase = /** @class */ (function (_super) {
|
|
|
725
835
|
// which means chart is not empty
|
|
726
836
|
);
|
|
727
837
|
};
|
|
838
|
+
AreaChartBase.prototype._xCoordinateContainsMultipleY = function () {
|
|
839
|
+
var lineChartData = this.props.data.lineChartData;
|
|
840
|
+
if (!lineChartData) {
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
for (var _i = 0, lineChartData_1 = lineChartData; _i < lineChartData_1.length; _i++) {
|
|
844
|
+
var item = lineChartData_1[_i];
|
|
845
|
+
var xValueMap = {};
|
|
846
|
+
for (var _a = 0, _b = item.data; _a < _b.length; _a++) {
|
|
847
|
+
var point = _b[_a];
|
|
848
|
+
var xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
849
|
+
if (!xValueMap[xValue]) {
|
|
850
|
+
xValueMap[xValue] = [];
|
|
851
|
+
}
|
|
852
|
+
xValueMap[xValue].push(point.y);
|
|
853
|
+
if (xValueMap[xValue].length > 1) {
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return false;
|
|
859
|
+
};
|
|
860
|
+
AreaChartBase.prototype._containsMissingXValues = function () {
|
|
861
|
+
var lineChartData = this.props.data.lineChartData;
|
|
862
|
+
if (!lineChartData) {
|
|
863
|
+
return false;
|
|
864
|
+
}
|
|
865
|
+
var allXValues = new Set();
|
|
866
|
+
lineChartData.forEach(function (line) {
|
|
867
|
+
line.data.forEach(function (point) {
|
|
868
|
+
var xValue = point.x instanceof Date ? point.x.toLocaleString() : point.x;
|
|
869
|
+
allXValues.add(xValue);
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
// for all x values, check if the x value is present in all series
|
|
873
|
+
var hasMissingValues = false;
|
|
874
|
+
lineChartData.forEach(function (line) {
|
|
875
|
+
allXValues.forEach(function (xValue) {
|
|
876
|
+
var point = line.data.find(function (item) {
|
|
877
|
+
return item.x instanceof Date ? item.x.toLocaleString() === xValue : item.x === xValue;
|
|
878
|
+
});
|
|
879
|
+
if (!point) {
|
|
880
|
+
hasMissingValues = true;
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
return hasMissingValues;
|
|
885
|
+
};
|
|
728
886
|
AreaChartBase.prototype._shouldFillToZeroY = function () {
|
|
729
887
|
return this.props.mode === 'tozeroy' || this._containsSecondaryYAxis;
|
|
730
888
|
};
|