@fluentui/react-charts 9.0.2 → 9.0.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 +64 -7
- package/dist/index.d.ts +829 -94
- package/lib/AreaChart.js +1 -0
- package/lib/AreaChart.js.map +1 -0
- package/lib/HeatMapChart.js +1 -0
- package/lib/HeatMapChart.js.map +1 -0
- package/lib/HorizontalBarChartWithAxis.js +1 -0
- package/lib/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/SankeyChart.js +1 -0
- package/lib/SankeyChart.js.map +1 -0
- package/lib/VerticalStackedBarChart.js +1 -0
- package/lib/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js +775 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.types.js +4 -0
- package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib/components/AreaChart/index.js +3 -0
- package/lib/components/AreaChart/index.js.map +1 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +55 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +30 -14
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +2 -2
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +7 -123
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +11 -22
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +112 -65
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +570 -159
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +1 -1
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/Pie/usePieStyles.styles.js +2 -6
- package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +4 -1
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +13 -9
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -9
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib/components/HeatMapChart/index.js +3 -0
- package/lib/components/HeatMapChart/index.js.map +1 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +37 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -9
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
- package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +67 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib/components/Legends/Legends.js +38 -37
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.js +2 -3
- package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +43 -35
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +1 -10
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +1023 -0
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib/components/SankeyChart/index.js +3 -0
- package/lib/components/SankeyChart/index.js.map +1 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.js +46 -59
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +1 -10
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +165 -88
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -11
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/index.js +3 -0
- package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +65 -0
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +49 -4
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/colors.js +20 -0
- package/lib/utilities/colors.js.map +1 -1
- package/lib/utilities/string.js +32 -0
- package/lib/utilities/string.js.map +1 -0
- package/lib/utilities/test-data.js +53 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.js +90 -18
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/AreaChart.js +6 -0
- package/lib-commonjs/AreaChart.js.map +1 -0
- package/lib-commonjs/HeatMapChart.js +6 -0
- package/lib-commonjs/HeatMapChart.js.map +1 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
- package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/SankeyChart.js +6 -0
- package/lib-commonjs/SankeyChart.js.map +1 -0
- package/lib-commonjs/VerticalStackedBarChart.js +6 -0
- package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
- package/lib-commonjs/components/AreaChart/index.js +8 -0
- package/lib-commonjs/components/AreaChart/index.js.map +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +95 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +29 -14
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -2
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +8 -198
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +12 -37
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +120 -73
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +592 -178
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +3 -10
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +4 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +14 -8
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +9 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -9
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/index.js +8 -0
- package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +59 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -16
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +107 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Legends/Legends.js +37 -37
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +2 -2
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +41 -33
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +1 -10
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +1039 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/index.js +8 -0
- package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +45 -58
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +1 -10
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +164 -87
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +4 -11
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
- package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +113 -0
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/index.js +5 -0
- package/lib-commonjs/index.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/SVGTooltipText.js +49 -4
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/colors.js +23 -0
- package/lib-commonjs/utilities/colors.js.map +1 -1
- package/lib-commonjs/utilities/string.js +29 -0
- package/lib-commonjs/utilities/string.js.map +1 -0
- package/lib-commonjs/utilities/test-data.js +59 -0
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +94 -17
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -8
- package/lib/components/DeclarativeChart/PlotlySchema.js +0 -7
- package/lib/components/DeclarativeChart/PlotlySchema.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +0 -10
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +0 -1
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "AreaChart", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return AreaChart;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _useAreaChartStylesstyles = require("./useAreaChartStyles.styles");
|
|
14
|
+
const _d3array = require("d3-array");
|
|
15
|
+
const _d3selection = require("d3-selection");
|
|
16
|
+
const _reacttheme = require("@fluentui/react-theme");
|
|
17
|
+
const _d3shape = require("d3-shape");
|
|
18
|
+
const _index = require("../../index");
|
|
19
|
+
const _index1 = require("../../utilities/index");
|
|
20
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
|
21
|
+
const _index2 = require("../Legends/index");
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
const bisect = (0, _d3array.bisector)((d)=>d.x).left;
|
|
24
|
+
var InterceptVisibility;
|
|
25
|
+
(function(InterceptVisibility) {
|
|
26
|
+
InterceptVisibility["show"] = "visibility";
|
|
27
|
+
InterceptVisibility["hide"] = "hidden";
|
|
28
|
+
})(InterceptVisibility || (InterceptVisibility = {}));
|
|
29
|
+
const AreaChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
30
|
+
var _props_legendProps;
|
|
31
|
+
const _uniqueIdForGraph = (0, _reactutilities.useId)('areaChart_');
|
|
32
|
+
const _verticalLineId = (0, _reactutilities.useId)('verticalLine_');
|
|
33
|
+
const _circleId = (0, _reactutilities.useId)('circle');
|
|
34
|
+
const _rectId = (0, _reactutilities.useId)('rectangle');
|
|
35
|
+
const _tooltipId = (0, _reactutilities.useId)('AreaChartTooltipID');
|
|
36
|
+
//enableComputationOptimization is used for optimized code to group data points by x value
|
|
37
|
+
//from O(n^2) to O(n) using a map.
|
|
38
|
+
const _enableComputationOptimization = true;
|
|
39
|
+
const _firstRenderOptimization = true;
|
|
40
|
+
const _emptyChartId = (0, _reactutilities.useId)('_AreaChart_empty');
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
let _calloutPoints;
|
|
43
|
+
let _createSet;
|
|
44
|
+
let _colors;
|
|
45
|
+
let _opacity;
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
let _data;
|
|
48
|
+
let _chart;
|
|
49
|
+
let _margins;
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
let _xAxisRectScale;
|
|
52
|
+
// determines if the given area chart has multiple stacked bar charts
|
|
53
|
+
let _isMultiStackChart;
|
|
54
|
+
const cartesianChartRef = _react.useRef(null);
|
|
55
|
+
const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
|
|
56
|
+
const [activeLegend, setActiveLegend] = _react.useState(undefined);
|
|
57
|
+
const [hoverXValue, setHoverXValue] = _react.useState('');
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
59
|
+
const [YValueHover, setYValueHover] = _react.useState([]);
|
|
60
|
+
const [lineXValue, setLineXValue] = _react.useState(0);
|
|
61
|
+
const [displayOfLine, setDisplayOfLine] = _react.useState("hidden");
|
|
62
|
+
const [isCircleClicked, setIsCircleClicked] = _react.useState(false);
|
|
63
|
+
const [nearestCircleToHighlight, setNearestCircleToHighlight] = _react.useState(null);
|
|
64
|
+
const [activePoint, setActivePoint] = _react.useState('');
|
|
65
|
+
const [dataPointCalloutProps, setDataPointCalloutProps] = _react.useState();
|
|
66
|
+
const [stackCalloutProps, setStackCalloutProps] = _react.useState();
|
|
67
|
+
const [xAxisCalloutAccessibilityData, setXAxisCalloutAccessibilityData] = _react.useState();
|
|
68
|
+
const [clickPosition, setClickPosition] = _react.useState({
|
|
69
|
+
x: 0,
|
|
70
|
+
y: 0
|
|
71
|
+
});
|
|
72
|
+
const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
|
|
73
|
+
const prevPropsRef = _react.useRef(null);
|
|
74
|
+
_react.useEffect(()=>{
|
|
75
|
+
if (prevPropsRef.current) {
|
|
76
|
+
var _prevProps_legendProps, _props_legendProps;
|
|
77
|
+
const prevProps = prevPropsRef.current;
|
|
78
|
+
if (!(0, _index1.areArraysEqual)((_prevProps_legendProps = prevProps.legendProps) === null || _prevProps_legendProps === void 0 ? void 0 : _prevProps_legendProps.selectedLegends, (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends)) {
|
|
79
|
+
var _props_legendProps1;
|
|
80
|
+
setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
prevPropsRef.current = props;
|
|
84
|
+
}, [
|
|
85
|
+
props
|
|
86
|
+
]);
|
|
87
|
+
_react.useImperativeHandle(props.componentRef, ()=>{
|
|
88
|
+
var _cartesianChartRef_current;
|
|
89
|
+
var _cartesianChartRef_current_chartContainer;
|
|
90
|
+
return {
|
|
91
|
+
chartContainer: (_cartesianChartRef_current_chartContainer = (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) !== null && _cartesianChartRef_current_chartContainer !== void 0 ? _cartesianChartRef_current_chartContainer : null
|
|
92
|
+
};
|
|
93
|
+
}, []);
|
|
94
|
+
const classes = (0, _useAreaChartStylesstyles.useAreaChartStyles)(props);
|
|
95
|
+
function _getMargins(margins) {
|
|
96
|
+
_margins = margins;
|
|
97
|
+
}
|
|
98
|
+
function _onRectMouseMove(mouseEvent) {
|
|
99
|
+
mouseEvent.persist();
|
|
100
|
+
const { data } = props;
|
|
101
|
+
const { lineChartData } = data;
|
|
102
|
+
_updatePosition(mouseEvent.clientX, mouseEvent.clientY);
|
|
103
|
+
// This will get the value of the X when mouse is on the chart
|
|
104
|
+
// eslint-disable-next-line @nx/workspace-no-restricted-globals
|
|
105
|
+
const xOffset = _xAxisRectScale.invert((0, _d3selection.pointer)(mouseEvent)[0], document.getElementById(_rectId));
|
|
106
|
+
const i = bisect(lineChartData[0].data, xOffset);
|
|
107
|
+
const d0 = lineChartData[0].data[i - 1];
|
|
108
|
+
const d1 = lineChartData[0].data[i];
|
|
109
|
+
let pointToHighlight = null;
|
|
110
|
+
let index = null;
|
|
111
|
+
const axisType = lineChartData[0].data.length > 0 ? (0, _index1.getTypeOfAxis)(lineChartData[0].data[0].x, true) : null;
|
|
112
|
+
if (d0 === undefined && d1 !== undefined) {
|
|
113
|
+
pointToHighlight = d1.x;
|
|
114
|
+
index = i;
|
|
115
|
+
} else if (d0 !== undefined && d1 === undefined) {
|
|
116
|
+
pointToHighlight = d0.x;
|
|
117
|
+
index = i - 1;
|
|
118
|
+
} else {
|
|
119
|
+
let x0;
|
|
120
|
+
let point0;
|
|
121
|
+
let point1;
|
|
122
|
+
switch(axisType){
|
|
123
|
+
case _index1.XAxisTypes.DateAxis:
|
|
124
|
+
x0 = new Date(xOffset).getTime();
|
|
125
|
+
point0 = d0.x.getTime();
|
|
126
|
+
point1 = d1.x.getTime();
|
|
127
|
+
pointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
|
|
128
|
+
index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
|
|
129
|
+
break;
|
|
130
|
+
case _index1.XAxisTypes.NumericAxis:
|
|
131
|
+
x0 = xOffset;
|
|
132
|
+
point0 = d0.x;
|
|
133
|
+
point1 = d1.x;
|
|
134
|
+
pointToHighlight = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? d1.x : d0.x;
|
|
135
|
+
index = Math.abs(x0 - point0) > Math.abs(x0 - point1) ? i : i - 1;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
142
|
+
const { xAxisCalloutData, xAxisCalloutAccessibilityData } = lineChartData[0].data[index];
|
|
143
|
+
const formattedDate = pointToHighlight instanceof Date ? (0, _index1.formatDate)(pointToHighlight, props.useUTC) : pointToHighlight;
|
|
144
|
+
const modifiedXVal = pointToHighlight instanceof Date ? pointToHighlight.getTime() : pointToHighlight;
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
const found = (0, _index1.find)(_calloutPoints, (element)=>{
|
|
147
|
+
return element.x === modifiedXVal;
|
|
148
|
+
});
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
150
|
+
const _nearestCircleToHighlight = axisType === _index1.XAxisTypes.DateAxis ? pointToHighlight.getTime() : pointToHighlight;
|
|
151
|
+
// if no points need to be called out then don't show vertical line and callout card
|
|
152
|
+
if (found) {
|
|
153
|
+
const filteredValues = _getFilteredLegendValues(found.values);
|
|
154
|
+
setNearestCircleToHighlight(_nearestCircleToHighlight);
|
|
155
|
+
setLineXValue(_xAxisRectScale(pointToHighlight));
|
|
156
|
+
setDisplayOfLine("visibility");
|
|
157
|
+
setIsCircleClicked(false);
|
|
158
|
+
setStackCalloutProps({
|
|
159
|
+
...found,
|
|
160
|
+
values: filteredValues
|
|
161
|
+
});
|
|
162
|
+
setYValueHover(filteredValues);
|
|
163
|
+
setDataPointCalloutProps({
|
|
164
|
+
...found,
|
|
165
|
+
values: filteredValues
|
|
166
|
+
});
|
|
167
|
+
setHoverXValue(xAxisCalloutData ? xAxisCalloutData : formattedDate);
|
|
168
|
+
setXAxisCalloutAccessibilityData(xAxisCalloutAccessibilityData);
|
|
169
|
+
setActivePoint('');
|
|
170
|
+
} else {
|
|
171
|
+
setPopoverOpen(false);
|
|
172
|
+
setNearestCircleToHighlight(nearestCircleToHighlight);
|
|
173
|
+
setDisplayOfLine("hidden");
|
|
174
|
+
setIsCircleClicked(false);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* just cleaning up the state which we have set in the mouse move event
|
|
179
|
+
*/ function _onRectMouseOut() {
|
|
180
|
+
/**/ }
|
|
181
|
+
function _updatePosition(newX, newY) {
|
|
182
|
+
const threshold = 1; // Set a threshold for movement
|
|
183
|
+
const { x, y } = clickPosition;
|
|
184
|
+
// Calculate the distance moved
|
|
185
|
+
const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
|
|
186
|
+
// Update the position only if the distance moved is greater than the threshold
|
|
187
|
+
if (distance > threshold) {
|
|
188
|
+
setClickPosition({
|
|
189
|
+
x: newX,
|
|
190
|
+
y: newY
|
|
191
|
+
});
|
|
192
|
+
setPopoverOpen(true);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function _handleChartMouseLeave() {
|
|
196
|
+
setPopoverOpen(false);
|
|
197
|
+
setNearestCircleToHighlight(null);
|
|
198
|
+
setLineXValue(0);
|
|
199
|
+
setDisplayOfLine("hidden");
|
|
200
|
+
setIsCircleClicked(false);
|
|
201
|
+
setStackCalloutProps(undefined);
|
|
202
|
+
setDataPointCalloutProps(undefined);
|
|
203
|
+
setHoverXValue(undefined);
|
|
204
|
+
setYValueHover([]);
|
|
205
|
+
}
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
+
function _getDataPoints(keys, dataSet) {
|
|
208
|
+
var _props_legendProps;
|
|
209
|
+
const renderPoints = [];
|
|
210
|
+
let maxOfYVal = 0;
|
|
211
|
+
if (props.mode === 'tozeroy') {
|
|
212
|
+
keys.forEach((key, index)=>{
|
|
213
|
+
const currentLayer = [];
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
|
+
dataSet.forEach((d)=>{
|
|
216
|
+
currentLayer.push({
|
|
217
|
+
values: [
|
|
218
|
+
0,
|
|
219
|
+
d[key]
|
|
220
|
+
],
|
|
221
|
+
xVal: d.xVal
|
|
222
|
+
});
|
|
223
|
+
if (d[key] > maxOfYVal) {
|
|
224
|
+
maxOfYVal = d[key];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
renderPoints.push(currentLayer);
|
|
228
|
+
});
|
|
229
|
+
} else {
|
|
230
|
+
const dataValues = (0, _d3shape.stack)().keys(keys)(dataSet);
|
|
231
|
+
maxOfYVal = (0, _d3array.max)(dataValues[dataValues.length - 1], (dp)=>dp[1]);
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
|
+
dataValues.forEach((layer)=>{
|
|
234
|
+
const currentLayer = [];
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
|
+
layer.forEach((d)=>{
|
|
237
|
+
currentLayer.push({
|
|
238
|
+
values: d,
|
|
239
|
+
xVal: d.data.xVal
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
renderPoints.push(currentLayer);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
_isMultiStackChart = !!(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) ? (renderPoints === null || renderPoints === void 0 ? void 0 : renderPoints.length) >= 1 : (renderPoints === null || renderPoints === void 0 ? void 0 : renderPoints.length) > 1);
|
|
246
|
+
return {
|
|
247
|
+
renderData: renderPoints,
|
|
248
|
+
maxOfYVal
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function _createDataSet(points) {
|
|
252
|
+
if (props.enablePerfOptimization && _enableComputationOptimization) {
|
|
253
|
+
const allChartPoints = [];
|
|
254
|
+
const dataSet = [];
|
|
255
|
+
const colors = [];
|
|
256
|
+
const opacity = [];
|
|
257
|
+
const calloutPoints = (0, _index1.calloutData)(points);
|
|
258
|
+
points && points.length && points.forEach((singleChartPoint)=>{
|
|
259
|
+
colors.push(singleChartPoint.color);
|
|
260
|
+
opacity.push(singleChartPoint.opacity || 1);
|
|
261
|
+
allChartPoints.push(...singleChartPoint.data);
|
|
262
|
+
});
|
|
263
|
+
const mapOfXvalToListOfDataPoints = {};
|
|
264
|
+
allChartPoints.forEach((dataPoint)=>{
|
|
265
|
+
const xValue = dataPoint.x instanceof Date ? dataPoint.x.toLocaleString() : dataPoint.x;
|
|
266
|
+
// map of x value to the list of data points which share the same x value .
|
|
267
|
+
if (mapOfXvalToListOfDataPoints[xValue]) {
|
|
268
|
+
mapOfXvalToListOfDataPoints[xValue].push(dataPoint);
|
|
269
|
+
} else {
|
|
270
|
+
mapOfXvalToListOfDataPoints[xValue] = [
|
|
271
|
+
dataPoint
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
Object.keys(mapOfXvalToListOfDataPoints).forEach((key)=>{
|
|
276
|
+
const value = mapOfXvalToListOfDataPoints[key];
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
+
const singleDataset = {};
|
|
279
|
+
value.forEach((singleDataPoint, index)=>{
|
|
280
|
+
singleDataset.xVal = singleDataPoint.x;
|
|
281
|
+
singleDataset[`chart${index}`] = singleDataPoint.y;
|
|
282
|
+
});
|
|
283
|
+
dataSet.push(singleDataset);
|
|
284
|
+
});
|
|
285
|
+
// get keys from dataset, used to render data
|
|
286
|
+
const keysLength = dataSet && Object.keys(dataSet[0]).length;
|
|
287
|
+
const keys = [];
|
|
288
|
+
for(let i = 0; i < keysLength - 1; i++){
|
|
289
|
+
const keyVal = `chart${i}`;
|
|
290
|
+
keys.push(keyVal);
|
|
291
|
+
}
|
|
292
|
+
// Data used to draw graph
|
|
293
|
+
const data = _getDataPoints(keys, dataSet);
|
|
294
|
+
return {
|
|
295
|
+
colors,
|
|
296
|
+
opacity,
|
|
297
|
+
keys,
|
|
298
|
+
data,
|
|
299
|
+
calloutPoints
|
|
300
|
+
};
|
|
301
|
+
} else {
|
|
302
|
+
const allChartPoints = [];
|
|
303
|
+
const dataSet = [];
|
|
304
|
+
const colors = [];
|
|
305
|
+
const opacity = [];
|
|
306
|
+
const calloutPoints = (0, _index1.calloutData)(points);
|
|
307
|
+
points && points.length && points.forEach((singleChartPoint)=>{
|
|
308
|
+
colors.push(singleChartPoint.color);
|
|
309
|
+
opacity.push(singleChartPoint.opacity || 1);
|
|
310
|
+
allChartPoints.push(...singleChartPoint.data);
|
|
311
|
+
});
|
|
312
|
+
let tempArr = allChartPoints;
|
|
313
|
+
while(tempArr.length){
|
|
314
|
+
const valToCheck = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
315
|
+
const filteredChartPoints = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) === valToCheck);
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
|
+
const singleDataset = {};
|
|
318
|
+
filteredChartPoints.forEach((singleDataPoint, index)=>{
|
|
319
|
+
singleDataset.xVal = singleDataPoint.x;
|
|
320
|
+
singleDataset[`chart${index}`] = singleDataPoint.y;
|
|
321
|
+
});
|
|
322
|
+
dataSet.push(singleDataset);
|
|
323
|
+
// removing compared objects from array
|
|
324
|
+
const val = tempArr[0].x instanceof Date ? tempArr[0].x.toLocaleString() : tempArr[0].x;
|
|
325
|
+
tempArr = tempArr.filter((point)=>(point.x instanceof Date ? point.x.toLocaleString() : point.x) !== val);
|
|
326
|
+
}
|
|
327
|
+
// get keys from dataset, used to create stacked data
|
|
328
|
+
const keysLength = dataSet && Object.keys(dataSet[0]).length;
|
|
329
|
+
const keys = [];
|
|
330
|
+
for(let i = 0; i < keysLength - 1; i++){
|
|
331
|
+
const keyVal = `chart${i}`;
|
|
332
|
+
keys.push(keyVal);
|
|
333
|
+
}
|
|
334
|
+
// Data used to draw graph
|
|
335
|
+
const data = _getDataPoints(keys, dataSet);
|
|
336
|
+
return {
|
|
337
|
+
colors,
|
|
338
|
+
opacity,
|
|
339
|
+
keys,
|
|
340
|
+
data,
|
|
341
|
+
calloutPoints
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function _getCustomizedCallout() {
|
|
346
|
+
return props.onRenderCalloutPerStack ? props.onRenderCalloutPerStack(stackCalloutProps) : props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps) : null;
|
|
347
|
+
}
|
|
348
|
+
function _getGraphData(xAxis, yAxis, containerHeight, containerWidth, xElement) {
|
|
349
|
+
_chart = _drawGraph(containerHeight, xAxis, yAxis, xElement);
|
|
350
|
+
}
|
|
351
|
+
function _onLegendHover(legend) {
|
|
352
|
+
setActiveLegend(legend);
|
|
353
|
+
}
|
|
354
|
+
function _onLegendLeave() {
|
|
355
|
+
setActiveLegend(undefined);
|
|
356
|
+
}
|
|
357
|
+
function _getLegendData(points) {
|
|
358
|
+
const data = points;
|
|
359
|
+
const actions = [];
|
|
360
|
+
data.forEach((singleChartData)=>{
|
|
361
|
+
const color = singleChartData.color;
|
|
362
|
+
const checkSimilarLegends = actions.filter((leg)=>leg.title === singleChartData.legend && leg.color === color);
|
|
363
|
+
if (checkSimilarLegends.length > 0) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const legend = {
|
|
367
|
+
title: singleChartData.legend,
|
|
368
|
+
color,
|
|
369
|
+
hoverAction: ()=>{
|
|
370
|
+
_handleChartMouseLeave();
|
|
371
|
+
_onLegendHover(singleChartData.legend);
|
|
372
|
+
},
|
|
373
|
+
onMouseOutAction: ()=>{
|
|
374
|
+
_onLegendLeave();
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
actions.push(legend);
|
|
378
|
+
});
|
|
379
|
+
return /*#__PURE__*/ _react.createElement(_index2.Legends, {
|
|
380
|
+
legends: actions,
|
|
381
|
+
enabledWrapLines: props.enabledLegendsWrapLines,
|
|
382
|
+
...props.legendProps,
|
|
383
|
+
onChange: _onLegendSelectionChange
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function _onLegendSelectionChange(selectedLegends, event, currentLegend) {
|
|
387
|
+
var _props_legendProps, _props_legendProps1;
|
|
388
|
+
if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
|
|
389
|
+
setSelectedLegends(selectedLegends);
|
|
390
|
+
} else {
|
|
391
|
+
setSelectedLegends(selectedLegends.slice(-1));
|
|
392
|
+
}
|
|
393
|
+
if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
|
|
394
|
+
props.legendProps.onChange(selectedLegends, event, currentLegend);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function _onDataPointClick(func) {
|
|
398
|
+
if (func) {
|
|
399
|
+
func();
|
|
400
|
+
}
|
|
401
|
+
setIsCircleClicked(true);
|
|
402
|
+
}
|
|
403
|
+
function _getOpacity(legend) {
|
|
404
|
+
if (!_isMultiStackChart) {
|
|
405
|
+
return 0.7;
|
|
406
|
+
} else {
|
|
407
|
+
const opacity = _legendHighlighted(legend) || _noLegendHighlighted() ? 0.7 : 0.1;
|
|
408
|
+
return opacity;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function _getLineOpacity(legend) {
|
|
412
|
+
if (!_isMultiStackChart) {
|
|
413
|
+
return 1;
|
|
414
|
+
} else {
|
|
415
|
+
let opacity = 0.3;
|
|
416
|
+
if (isPopoverOpen) {
|
|
417
|
+
opacity = 1;
|
|
418
|
+
}
|
|
419
|
+
if (!_noLegendHighlighted()) {
|
|
420
|
+
opacity = _legendHighlighted(legend) ? 0 : 0.1;
|
|
421
|
+
}
|
|
422
|
+
return opacity;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function _updateCircleFillColor(xDataPoint, lineColor, circleId) {
|
|
426
|
+
let fillColor = lineColor;
|
|
427
|
+
if (nearestCircleToHighlight === xDataPoint || activePoint === circleId) {
|
|
428
|
+
if (!isCircleClicked) {
|
|
429
|
+
fillColor = _reacttheme.tokens.colorNeutralBackground1;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return fillColor;
|
|
433
|
+
}
|
|
434
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
435
|
+
function _drawGraph(containerHeight, xScale, yScale, xElement) {
|
|
436
|
+
const points = _addDefaultColors(props.data.lineChartData);
|
|
437
|
+
const { pointOptions, pointLineOptions } = props.data;
|
|
438
|
+
const graph = [];
|
|
439
|
+
let lineColor;
|
|
440
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
+
_data.forEach((singleStackedData, index)=>{
|
|
442
|
+
var _points_index_lineOptions, _points_index_lineOptions1, _points_index_lineOptions2, _points_index_lineOptions3, _points_index_lineOptions4;
|
|
443
|
+
const curveFactory = (0, _index1.getCurveFactory)((_points_index_lineOptions = points[index].lineOptions) === null || _points_index_lineOptions === void 0 ? void 0 : _points_index_lineOptions.curve, _d3shape.curveMonotoneX);
|
|
444
|
+
const area = (0, _d3shape.area)() // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
445
|
+
.x((d)=>xScale(d.xVal)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
446
|
+
.y0((d)=>yScale(d.values[0])) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
447
|
+
.y1((d)=>yScale(d.values[1])).curve(curveFactory);
|
|
448
|
+
const line = (0, _d3shape.line)() // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
|
+
.x((d)=>xScale(d.xVal)) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
450
|
+
.y((d)=>yScale(d.values[1])).curve(curveFactory);
|
|
451
|
+
const layerOpacity = props.mode === 'tozeroy' ? 0.8 : _opacity[index];
|
|
452
|
+
var _points_index_lineOptions_strokeWidth;
|
|
453
|
+
graph.push(/*#__PURE__*/ _react.createElement(_react.Fragment, {
|
|
454
|
+
key: `${index}-graph-${_uniqueIdForGraph}`
|
|
455
|
+
}, props.enableGradient && /*#__PURE__*/ _react.createElement("defs", null, /*#__PURE__*/ _react.createElement("linearGradient", {
|
|
456
|
+
id: `gradient_${index}`,
|
|
457
|
+
x1: "0%",
|
|
458
|
+
x2: "0%",
|
|
459
|
+
y1: "0%",
|
|
460
|
+
y2: "100%"
|
|
461
|
+
}, /*#__PURE__*/ _react.createElement("stop", {
|
|
462
|
+
offset: "0",
|
|
463
|
+
stopColor: _colors[index]
|
|
464
|
+
}), /*#__PURE__*/ _react.createElement("stop", {
|
|
465
|
+
offset: "100%",
|
|
466
|
+
stopColor: "transparent"
|
|
467
|
+
}))), /*#__PURE__*/ _react.createElement("path", {
|
|
468
|
+
id: `${index}-line-${_uniqueIdForGraph}`,
|
|
469
|
+
d: line(singleStackedData),
|
|
470
|
+
fill: 'transparent',
|
|
471
|
+
strokeWidth: (_points_index_lineOptions_strokeWidth = (_points_index_lineOptions1 = points[index].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,
|
|
472
|
+
stroke: _colors[index],
|
|
473
|
+
opacity: _getLineOpacity(points[index].legend),
|
|
474
|
+
onMouseMove: (event)=>_onRectMouseMove(event),
|
|
475
|
+
onMouseOut: _onRectMouseOut,
|
|
476
|
+
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
477
|
+
strokeDasharray: (_points_index_lineOptions2 = points[index].lineOptions) === null || _points_index_lineOptions2 === void 0 ? void 0 : _points_index_lineOptions2.strokeDasharray,
|
|
478
|
+
strokeDashoffset: (_points_index_lineOptions3 = points[index].lineOptions) === null || _points_index_lineOptions3 === void 0 ? void 0 : _points_index_lineOptions3.strokeDashoffset,
|
|
479
|
+
strokeLinecap: (_points_index_lineOptions4 = points[index].lineOptions) === null || _points_index_lineOptions4 === void 0 ? void 0 : _points_index_lineOptions4.strokeLinecap
|
|
480
|
+
}), singleStackedData.length === 1 ? /*#__PURE__*/ _react.createElement("circle", {
|
|
481
|
+
id: `${index}-graph-${_uniqueIdForGraph}`,
|
|
482
|
+
cx: xScale(singleStackedData[0].xVal),
|
|
483
|
+
cy: yScale(singleStackedData[0].values[1]),
|
|
484
|
+
r: 6,
|
|
485
|
+
stroke: _colors[index],
|
|
486
|
+
strokeWidth: 3,
|
|
487
|
+
fill: _colors[index],
|
|
488
|
+
opacity: layerOpacity,
|
|
489
|
+
fillOpacity: _getOpacity(points[index].legend),
|
|
490
|
+
onMouseMove: (event)=>_onRectMouseMove(event),
|
|
491
|
+
onMouseOut: _onRectMouseOut,
|
|
492
|
+
onMouseOver: (event)=>_onRectMouseMove(event)
|
|
493
|
+
}) : /*#__PURE__*/ _react.createElement("path", {
|
|
494
|
+
id: `${index}-graph-${_uniqueIdForGraph}`,
|
|
495
|
+
d: area(singleStackedData),
|
|
496
|
+
fill: props.enableGradient ? `url(#gradient_${index})` : _colors[index],
|
|
497
|
+
opacity: layerOpacity,
|
|
498
|
+
fillOpacity: _getOpacity(points[index].legend),
|
|
499
|
+
onMouseMove: (event)=>_onRectMouseMove(event),
|
|
500
|
+
onMouseOut: _onRectMouseOut,
|
|
501
|
+
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
502
|
+
...props.optimizeLargeData && {
|
|
503
|
+
tabIndex: _legendHighlighted(points[index].legend) || _noLegendHighlighted() ? 0 : undefined,
|
|
504
|
+
role: 'img',
|
|
505
|
+
'aria-label': `${points[index].legend}, series ${index + 1} of ${points.length} with ${points[index].data.length} data points.`
|
|
506
|
+
}
|
|
507
|
+
})));
|
|
508
|
+
});
|
|
509
|
+
const circleRadius = pointOptions && pointOptions.r ? Number(pointOptions.r) : 8;
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
511
|
+
_data.forEach((singleStackedData, index)=>{
|
|
512
|
+
if (points.length === index) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (!props.optimizeLargeData || singleStackedData.length === 1) {
|
|
516
|
+
// Render circles for all data points
|
|
517
|
+
graph.push(/*#__PURE__*/ _react.createElement("g", {
|
|
518
|
+
key: `${index}-dots-${_uniqueIdForGraph}`,
|
|
519
|
+
clipPath: "url(#clip)",
|
|
520
|
+
role: "region",
|
|
521
|
+
"aria-label": `${points[index].legend}, series ${index + 1} of ${points.length} with ${points[index].data.length} data points.`
|
|
522
|
+
}, singleStackedData.map((singlePoint, pointIndex)=>{
|
|
523
|
+
const circleId = `${_circleId}_${index * _data[0].length + pointIndex}`;
|
|
524
|
+
const xDataPoint = singlePoint.xVal instanceof Date ? singlePoint.xVal.getTime() : singlePoint.xVal;
|
|
525
|
+
lineColor = points[index].color;
|
|
526
|
+
const legend = points[index].legend;
|
|
527
|
+
return /*#__PURE__*/ _react.createElement("circle", {
|
|
528
|
+
key: circleId,
|
|
529
|
+
id: circleId,
|
|
530
|
+
tabIndex: _legendHighlighted(points[index].legend) || _noLegendHighlighted() ? 0 : undefined,
|
|
531
|
+
cx: xScale(singlePoint.xVal),
|
|
532
|
+
cy: yScale(singlePoint.values[1]),
|
|
533
|
+
stroke: lineColor,
|
|
534
|
+
strokeWidth: 3,
|
|
535
|
+
fill: _updateCircleFillColor(xDataPoint, lineColor, circleId),
|
|
536
|
+
onMouseOut: _onRectMouseOut,
|
|
537
|
+
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
538
|
+
onClick: ()=>_onDataPointClick(points[index].data[pointIndex].onDataPointClick),
|
|
539
|
+
onFocus: ()=>_handleFocus(index, pointIndex, circleId),
|
|
540
|
+
onBlur: _handleBlur,
|
|
541
|
+
...(0, _index1.getSecureProps)(pointOptions),
|
|
542
|
+
r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend),
|
|
543
|
+
role: "img",
|
|
544
|
+
"aria-label": _getAriaLabel(index, pointIndex)
|
|
545
|
+
});
|
|
546
|
+
})));
|
|
547
|
+
} else {
|
|
548
|
+
// Render circles for data points close to the mouse pointer only
|
|
549
|
+
singleStackedData.forEach((singlePoint, pointIndex)=>{
|
|
550
|
+
const xDataPoint = singlePoint.xVal instanceof Date ? singlePoint.xVal.getTime() : singlePoint.xVal;
|
|
551
|
+
if (nearestCircleToHighlight === xDataPoint) {
|
|
552
|
+
const circleId = `${_circleId}_${index * _data[0].length + pointIndex}`;
|
|
553
|
+
lineColor = points[index].color;
|
|
554
|
+
const legend = points[index].legend;
|
|
555
|
+
graph.push(/*#__PURE__*/ _react.createElement("circle", {
|
|
556
|
+
key: circleId,
|
|
557
|
+
id: circleId,
|
|
558
|
+
cx: xScale(singlePoint.xVal),
|
|
559
|
+
cy: yScale(singlePoint.values[1]),
|
|
560
|
+
stroke: lineColor,
|
|
561
|
+
strokeWidth: 3,
|
|
562
|
+
fill: _updateCircleFillColor(xDataPoint, lineColor, circleId),
|
|
563
|
+
onMouseOut: _onRectMouseOut,
|
|
564
|
+
onMouseOver: (event)=>_onRectMouseMove(event),
|
|
565
|
+
onClick: ()=>_onDataPointClick(points[index].data[pointIndex].onDataPointClick),
|
|
566
|
+
...(0, _index1.getSecureProps)(pointOptions),
|
|
567
|
+
r: _getCircleRadius(xDataPoint, circleRadius, circleId, legend)
|
|
568
|
+
}));
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
graph.push(/*#__PURE__*/ _react.createElement("line", {
|
|
574
|
+
id: _verticalLineId,
|
|
575
|
+
key: _verticalLineId,
|
|
576
|
+
x1: lineXValue,
|
|
577
|
+
y1: 0,
|
|
578
|
+
x2: lineXValue,
|
|
579
|
+
y2: containerHeight,
|
|
580
|
+
strokeWidth: 1,
|
|
581
|
+
strokeDasharray: 5.5,
|
|
582
|
+
stroke: lineColor,
|
|
583
|
+
opacity: 0.5,
|
|
584
|
+
visibility: displayOfLine,
|
|
585
|
+
...(0, _index1.getSecureProps)(pointLineOptions)
|
|
586
|
+
}));
|
|
587
|
+
// Removing un wanted tooltip div from DOM, when prop not provided.
|
|
588
|
+
if (!props.showXAxisLablesTooltip) {
|
|
589
|
+
try {
|
|
590
|
+
// eslint-disable-next-line @nx/workspace-no-restricted-globals
|
|
591
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
592
|
+
// eslint-disable-next-line no-empty
|
|
593
|
+
} catch (e) {}
|
|
594
|
+
}
|
|
595
|
+
// Used to display tooltip at x axis labels.
|
|
596
|
+
if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
|
|
597
|
+
const xAxisElement = (0, _d3selection.select)(xElement).call(xScale);
|
|
598
|
+
try {
|
|
599
|
+
// eslint-disable-next-line @nx/workspace-no-restricted-globals
|
|
600
|
+
document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
|
|
601
|
+
// eslint-disable-next-line no-empty
|
|
602
|
+
} catch (e) {}
|
|
603
|
+
const tooltipProps = {
|
|
604
|
+
tooltipCls: classes.tooltip,
|
|
605
|
+
id: _tooltipId,
|
|
606
|
+
xAxis: xAxisElement
|
|
607
|
+
};
|
|
608
|
+
xAxisElement && (0, _index1.tooltipOfXAxislabels)(tooltipProps);
|
|
609
|
+
}
|
|
610
|
+
return graph;
|
|
611
|
+
}
|
|
612
|
+
function _getCircleRadius(xDataPoint, circleRadius, circleId, legend) {
|
|
613
|
+
// Show the circle if no legends are selected or if the point's legend is in the selected legends
|
|
614
|
+
if (!_noLegendHighlighted() && !_legendHighlighted(legend)) {
|
|
615
|
+
return 0;
|
|
616
|
+
}
|
|
617
|
+
if (isCircleClicked && nearestCircleToHighlight === xDataPoint) {
|
|
618
|
+
return 1;
|
|
619
|
+
} else if (nearestCircleToHighlight === xDataPoint || activePoint === circleId) {
|
|
620
|
+
return circleRadius;
|
|
621
|
+
} else {
|
|
622
|
+
return 0;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* This function checks if the given legend is highlighted or not.
|
|
627
|
+
* A legend can be highlighted in 2 ways:
|
|
628
|
+
* 1. selection: if the user clicks on it
|
|
629
|
+
* 2. hovering: if there is no selected legend and the user hovers over it
|
|
630
|
+
*/ function _legendHighlighted(legend) {
|
|
631
|
+
return _getHighlightedLegend().includes(legend);
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* This function checks if none of the legends is selected or hovered.
|
|
635
|
+
*/ function _noLegendHighlighted() {
|
|
636
|
+
return _getHighlightedLegend().length === 0;
|
|
637
|
+
}
|
|
638
|
+
function _getHighlightedLegend() {
|
|
639
|
+
return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
|
|
640
|
+
activeLegend
|
|
641
|
+
] : [];
|
|
642
|
+
}
|
|
643
|
+
function _addDefaultColors(lineChartData) {
|
|
644
|
+
return lineChartData ? lineChartData.map((item, index)=>{
|
|
645
|
+
let color;
|
|
646
|
+
// isInverted property is applicable to v8 themes only
|
|
647
|
+
if (typeof item.color === 'undefined') {
|
|
648
|
+
color = (0, _index1.getNextColor)(index, 0);
|
|
649
|
+
} else {
|
|
650
|
+
color = (0, _index1.getColorFromToken)(item.color);
|
|
651
|
+
}
|
|
652
|
+
return {
|
|
653
|
+
...item,
|
|
654
|
+
color
|
|
655
|
+
};
|
|
656
|
+
}) : [];
|
|
657
|
+
}
|
|
658
|
+
function _handleFocus(lineIndex, pointIndex, circleId) {
|
|
659
|
+
const { x, y, xAxisCalloutData } = props.data.lineChartData[lineIndex].data[pointIndex];
|
|
660
|
+
const formattedDate = x instanceof Date ? (0, _index1.formatDate)(x, props.useUTC) : x;
|
|
661
|
+
const modifiedXVal = x instanceof Date ? x.getTime() : x;
|
|
662
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
663
|
+
const found = _calloutPoints.find((e)=>e.x === modifiedXVal);
|
|
664
|
+
// Show details in the callout for the focused point only
|
|
665
|
+
found.values = found.values.filter((e)=>e.y === y);
|
|
666
|
+
const filteredValues = _getFilteredLegendValues(found.values);
|
|
667
|
+
setPopoverOpen(true);
|
|
668
|
+
setHoverXValue(xAxisCalloutData ? xAxisCalloutData : formattedDate);
|
|
669
|
+
setYValueHover(filteredValues);
|
|
670
|
+
setStackCalloutProps({
|
|
671
|
+
...found,
|
|
672
|
+
values: filteredValues
|
|
673
|
+
});
|
|
674
|
+
setDataPointCalloutProps({
|
|
675
|
+
...found,
|
|
676
|
+
values: filteredValues
|
|
677
|
+
});
|
|
678
|
+
setActivePoint(circleId);
|
|
679
|
+
}
|
|
680
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
681
|
+
function _getFilteredLegendValues(values) {
|
|
682
|
+
return !_noLegendHighlighted() ? values.filter((value)=>_legendHighlighted(value.legend)) : values;
|
|
683
|
+
}
|
|
684
|
+
function _handleBlur() {
|
|
685
|
+
setPopoverOpen(false);
|
|
686
|
+
setHoverXValue(undefined);
|
|
687
|
+
setYValueHover([]);
|
|
688
|
+
setStackCalloutProps(undefined);
|
|
689
|
+
setDataPointCalloutProps(undefined);
|
|
690
|
+
setActivePoint('');
|
|
691
|
+
}
|
|
692
|
+
function _getAriaLabel(lineIndex, pointIndex) {
|
|
693
|
+
var _point_callOutAccessibilityData;
|
|
694
|
+
const line = props.data.lineChartData[lineIndex];
|
|
695
|
+
const point = line.data[pointIndex];
|
|
696
|
+
const formattedDate = point.x instanceof Date ? (0, _index1.formatDate)(point.x, props.useUTC) : point.x;
|
|
697
|
+
const xValue = point.xAxisCalloutData || formattedDate;
|
|
698
|
+
const legend = line.legend;
|
|
699
|
+
const yValue = point.yAxisCalloutData || point.y;
|
|
700
|
+
return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ${legend}, ${yValue}.`;
|
|
701
|
+
}
|
|
702
|
+
function _isChartEmpty() {
|
|
703
|
+
return !(props.data && props.data.lineChartData && props.data.lineChartData.length > 0 && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
704
|
+
props.data.lineChartData.filter((item)=>item.data.length === 0).length === 0);
|
|
705
|
+
}
|
|
706
|
+
function _getChartTitle() {
|
|
707
|
+
const { chartTitle, lineChartData } = props.data;
|
|
708
|
+
return (chartTitle ? `${chartTitle}. ` : '') + `Area chart with ${(lineChartData === null || lineChartData === void 0 ? void 0 : lineChartData.length) || 0} data series. `;
|
|
709
|
+
}
|
|
710
|
+
if (!_isChartEmpty()) {
|
|
711
|
+
const { lineChartData } = props.data;
|
|
712
|
+
const points = _addDefaultColors(lineChartData);
|
|
713
|
+
_createSet = _createDataSet;
|
|
714
|
+
const { colors, opacity, data, calloutPoints } = _createSet(points);
|
|
715
|
+
_calloutPoints = calloutPoints;
|
|
716
|
+
const isXAxisDateType = (0, _index1.getXAxisType)(points);
|
|
717
|
+
_colors = colors;
|
|
718
|
+
_opacity = opacity;
|
|
719
|
+
_data = data.renderData;
|
|
720
|
+
const legends = _getLegendData(points);
|
|
721
|
+
const tickParams = {
|
|
722
|
+
tickValues: props.tickValues,
|
|
723
|
+
tickFormat: props.tickFormat
|
|
724
|
+
};
|
|
725
|
+
const calloutProps = {
|
|
726
|
+
YValueHover: YValueHover,
|
|
727
|
+
hoverXValue: hoverXValue,
|
|
728
|
+
xAxisCalloutAccessibilityData,
|
|
729
|
+
...props.calloutProps,
|
|
730
|
+
clickPosition,
|
|
731
|
+
isPopoverOpen,
|
|
732
|
+
isCartesian: true,
|
|
733
|
+
customCallout: {
|
|
734
|
+
customizedCallout: _getCustomizedCallout() !== null ? _getCustomizedCallout() : undefined,
|
|
735
|
+
customCalloutProps: props.calloutPropsPerDataPoint ? props.calloutPropsPerDataPoint(dataPointCalloutProps) : undefined
|
|
736
|
+
},
|
|
737
|
+
isCalloutForStack: true
|
|
738
|
+
};
|
|
739
|
+
return /*#__PURE__*/ _react.createElement(_index.CartesianChart, {
|
|
740
|
+
...props,
|
|
741
|
+
chartTitle: _getChartTitle(),
|
|
742
|
+
points: points,
|
|
743
|
+
chartType: _index1.ChartTypes.AreaChart,
|
|
744
|
+
calloutProps: calloutProps,
|
|
745
|
+
legendBars: legends,
|
|
746
|
+
xAxisType: isXAxisDateType ? _index1.XAxisTypes.DateAxis : _index1.XAxisTypes.NumericAxis,
|
|
747
|
+
tickParams: tickParams,
|
|
748
|
+
maxOfYVal: data.maxOfYVal,
|
|
749
|
+
getGraphData: _getGraphData,
|
|
750
|
+
getmargins: _getMargins,
|
|
751
|
+
onChartMouseLeave: _handleChartMouseLeave,
|
|
752
|
+
enableFirstRenderOptimization: props.enablePerfOptimization && _firstRenderOptimization,
|
|
753
|
+
componentRef: cartesianChartRef,
|
|
754
|
+
/* eslint-disable react/jsx-no-bind */ // eslint-disable-next-line react/no-children-prop, @typescript-eslint/no-shadow
|
|
755
|
+
children: (props)=>{
|
|
756
|
+
_xAxisRectScale = props.xScale;
|
|
757
|
+
const ticks = _xAxisRectScale.ticks();
|
|
758
|
+
const width1 = _xAxisRectScale(ticks[ticks.length - 1]);
|
|
759
|
+
const rectHeight = props.containerHeight - _margins.top;
|
|
760
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("g", null, /*#__PURE__*/ _react.createElement("rect", {
|
|
761
|
+
id: _rectId,
|
|
762
|
+
width: width1,
|
|
763
|
+
height: rectHeight,
|
|
764
|
+
fill: 'transparent',
|
|
765
|
+
onMouseMove: (event)=>_onRectMouseMove(event),
|
|
766
|
+
onMouseOut: _onRectMouseOut,
|
|
767
|
+
onMouseOver: (event)=>_onRectMouseMove(event)
|
|
768
|
+
})), /*#__PURE__*/ _react.createElement("g", null, _chart));
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
773
|
+
id: _emptyChartId,
|
|
774
|
+
role: 'alert',
|
|
775
|
+
style: {
|
|
776
|
+
opacity: '0'
|
|
777
|
+
},
|
|
778
|
+
"aria-label": 'Graph has no data to display'
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
AreaChart.displayName = 'AreaChart';
|