@neo4j-ndl/react-charts 2.1.21 → 2.2.0
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/lib/LICENSES.txt +0 -295
- package/lib/NOTICE.txt +1383 -1392
- package/lib/{esm/charts/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.js} +13 -5
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js +46 -0
- package/lib/{esm/charts/tests/ChartWrapperWithTooltipFormatter.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.js} +12 -13
- package/lib/{esm/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.js} +13 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.js +35 -0
- package/lib/{esm/charts/utils/chart-types.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.js} +10 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.js +37 -0
- package/lib/cjs/_virtual/_rolldown/runtime.js +44 -0
- package/lib/cjs/charts/Chart.js +121 -111
- package/lib/cjs/charts/Chart.js.map +1 -1
- package/lib/cjs/charts/ChartContainer.js +67 -62
- package/lib/cjs/charts/ChartContainer.js.map +1 -1
- package/lib/cjs/charts/ChartEmpty.js +45 -30
- package/lib/cjs/charts/ChartEmpty.js.map +1 -1
- package/lib/cjs/charts/ChartRender.js +112 -87
- package/lib/cjs/charts/ChartRender.js.map +1 -1
- package/lib/cjs/charts/ChartTooltip.js +111 -65
- package/lib/cjs/charts/ChartTooltip.js.map +1 -1
- package/lib/cjs/charts/Legend.js +81 -69
- package/lib/cjs/charts/Legend.js.map +1 -1
- package/lib/cjs/charts/LegendItem.js +83 -62
- package/lib/cjs/charts/LegendItem.js.map +1 -1
- package/lib/cjs/charts/LegendLayout.js +330 -348
- package/lib/cjs/charts/LegendLayout.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-instance.js +115 -122
- package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-option.js +79 -80
- package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-refs.js +47 -44
- package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-zoom.js +102 -127
- package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-interactions.js +127 -132
- package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-series.js +143 -174
- package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-visibility.js +66 -85
- package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -1
- package/lib/cjs/charts/index.js +31 -40
- package/lib/cjs/charts/index.js.map +1 -1
- package/lib/cjs/charts/themes/ndl-echarts-theme.js +136 -168
- package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
- package/lib/cjs/charts/utils/aria-description.js +150 -214
- package/lib/cjs/charts/utils/aria-description.js.map +1 -1
- package/lib/cjs/charts/utils/build-chart-option.js +166 -174
- package/lib/cjs/charts/utils/build-chart-option.js.map +1 -1
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js +156 -172
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -1
- package/lib/cjs/charts/utils/chart-types.js +25 -20
- package/lib/cjs/charts/utils/chart-types.js.map +1 -1
- package/lib/cjs/charts/utils/defaults.js +69 -67
- package/lib/cjs/charts/utils/defaults.js.map +1 -1
- package/lib/cjs/charts/utils/format-utils.js +55 -66
- package/lib/cjs/charts/utils/format-utils.js.map +1 -1
- package/lib/cjs/charts/utils/legend-layout.js +54 -53
- package/lib/cjs/charts/utils/legend-layout.js.map +1 -1
- package/lib/cjs/charts/utils/legend-utils.js +82 -121
- package/lib/cjs/charts/utils/legend-utils.js.map +1 -1
- package/lib/cjs/charts/utils/scatter-tooltip-points.js +191 -266
- package/lib/cjs/charts/utils/scatter-tooltip-points.js.map +1 -1
- package/lib/cjs/charts/utils/threshold.js +89 -102
- package/lib/cjs/charts/utils/threshold.js.map +1 -1
- package/lib/cjs/charts/utils/user-option-utils.js +419 -347
- package/lib/cjs/charts/utils/user-option-utils.js.map +1 -1
- package/lib/cjs/index.js +31 -35
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs +24 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs +12 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.mjs +13 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.mjs +10 -0
- package/lib/esm/charts/Chart.mjs +123 -0
- package/lib/esm/charts/Chart.mjs.map +1 -0
- package/lib/esm/charts/ChartContainer.mjs +71 -0
- package/lib/esm/charts/ChartContainer.mjs.map +1 -0
- package/lib/esm/charts/ChartEmpty.mjs +46 -0
- package/lib/esm/charts/ChartEmpty.mjs.map +1 -0
- package/lib/esm/charts/ChartRender.mjs +113 -0
- package/lib/esm/charts/ChartRender.mjs.map +1 -0
- package/lib/esm/charts/ChartTooltip.mjs +109 -0
- package/lib/esm/charts/ChartTooltip.mjs.map +1 -0
- package/lib/esm/charts/Legend.mjs +82 -0
- package/lib/esm/charts/Legend.mjs.map +1 -0
- package/lib/esm/charts/LegendItem.mjs +82 -0
- package/lib/esm/charts/LegendItem.mjs.map +1 -0
- package/lib/esm/charts/LegendLayout.mjs +337 -0
- package/lib/esm/charts/LegendLayout.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs +119 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs +79 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs +49 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs +102 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs +138 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs +151 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs +67 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs.map +1 -0
- package/lib/esm/charts/index.mjs +27 -0
- package/lib/esm/charts/index.mjs.map +1 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs +139 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs.map +1 -0
- package/lib/esm/charts/utils/aria-description.mjs +162 -0
- package/lib/esm/charts/utils/aria-description.mjs.map +1 -0
- package/lib/esm/charts/utils/build-chart-option.mjs +184 -0
- package/lib/esm/charts/utils/build-chart-option.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs +159 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-types.mjs +24 -0
- package/lib/esm/charts/utils/chart-types.mjs.map +1 -0
- package/lib/esm/charts/utils/defaults.mjs +73 -0
- package/lib/esm/charts/utils/defaults.mjs.map +1 -0
- package/lib/esm/charts/utils/format-utils.mjs +61 -0
- package/lib/esm/charts/utils/format-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-layout.mjs +57 -0
- package/lib/esm/charts/utils/legend-layout.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-utils.mjs +90 -0
- package/lib/esm/charts/utils/legend-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs +215 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs.map +1 -0
- package/lib/esm/charts/utils/threshold.mjs +92 -0
- package/lib/esm/charts/utils/threshold.mjs.map +1 -0
- package/lib/esm/charts/utils/user-option-utils.mjs +445 -0
- package/lib/esm/charts/utils/user-option-utils.mjs.map +1 -0
- package/lib/esm/index.mjs +27 -0
- package/lib/esm/index.mjs.map +1 -0
- package/package.json +12 -16
- package/skills/ndl-react-charts/SKILL.md +2 -2
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js +0 -38
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/cjs/charts/tests/ChartZoomHarness.js +0 -113
- package/lib/cjs/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js +0 -78
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/cjs/charts/tests/PieChartWithRerender.js +0 -46
- package/lib/cjs/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/cjs/charts/tests/chart-test-utils.js +0 -527
- package/lib/cjs/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/Chart.js +0 -114
- package/lib/esm/charts/Chart.js.map +0 -1
- package/lib/esm/charts/ChartContainer.js +0 -67
- package/lib/esm/charts/ChartContainer.js.map +0 -1
- package/lib/esm/charts/ChartEmpty.js +0 -33
- package/lib/esm/charts/ChartEmpty.js.map +0 -1
- package/lib/esm/charts/ChartRender.js +0 -89
- package/lib/esm/charts/ChartRender.js.map +0 -1
- package/lib/esm/charts/ChartTooltip.js +0 -64
- package/lib/esm/charts/ChartTooltip.js.map +0 -1
- package/lib/esm/charts/Legend.js +0 -71
- package/lib/esm/charts/Legend.js.map +0 -1
- package/lib/esm/charts/LegendItem.js +0 -61
- package/lib/esm/charts/LegendItem.js.map +0 -1
- package/lib/esm/charts/LegendLayout.js +0 -323
- package/lib/esm/charts/LegendLayout.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-instance.js +0 -128
- package/lib/esm/charts/hooks/use-chart-instance.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-option.js +0 -82
- package/lib/esm/charts/hooks/use-chart-option.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-refs.js +0 -48
- package/lib/esm/charts/hooks/use-chart-refs.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-zoom.js +0 -129
- package/lib/esm/charts/hooks/use-chart-zoom.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-interactions.js +0 -145
- package/lib/esm/charts/hooks/use-legend-interactions.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-series.js +0 -184
- package/lib/esm/charts/hooks/use-legend-series.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-visibility.js +0 -87
- package/lib/esm/charts/hooks/use-legend-visibility.js.map +0 -1
- package/lib/esm/charts/index.js.map +0 -1
- package/lib/esm/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/esm/charts/tests/ChartZoomHarness.js +0 -109
- package/lib/esm/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js +0 -74
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/esm/charts/tests/PieChartWithRerender.js +0 -43
- package/lib/esm/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/esm/charts/tests/chart-test-utils.js +0 -500
- package/lib/esm/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/themes/ndl-echarts-theme.js +0 -172
- package/lib/esm/charts/themes/ndl-echarts-theme.js.map +0 -1
- package/lib/esm/charts/utils/aria-description.js +0 -228
- package/lib/esm/charts/utils/aria-description.js.map +0 -1
- package/lib/esm/charts/utils/build-chart-option.js +0 -193
- package/lib/esm/charts/utils/build-chart-option.js.map +0 -1
- package/lib/esm/charts/utils/chart-tooltip-formatter.js +0 -177
- package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +0 -1
- package/lib/esm/charts/utils/chart-types.js.map +0 -1
- package/lib/esm/charts/utils/defaults.js +0 -73
- package/lib/esm/charts/utils/defaults.js.map +0 -1
- package/lib/esm/charts/utils/format-utils.js +0 -74
- package/lib/esm/charts/utils/format-utils.js.map +0 -1
- package/lib/esm/charts/utils/legend-layout.js +0 -59
- package/lib/esm/charts/utils/legend-layout.js.map +0 -1
- package/lib/esm/charts/utils/legend-utils.js +0 -131
- package/lib/esm/charts/utils/legend-utils.js.map +0 -1
- package/lib/esm/charts/utils/scatter-tooltip-points.js +0 -291
- package/lib/esm/charts/utils/scatter-tooltip-points.js.map +0 -1
- package/lib/esm/charts/utils/threshold.js +0 -106
- package/lib/esm/charts/utils/threshold.js.map +0 -1
- package/lib/esm/charts/utils/user-option-utils.js +0 -374
- package/lib/esm/charts/utils/user-option-utils.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
|
@@ -1,182 +1,166 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
*
|
|
3
|
-
* Copyright (c) "Neo4j"
|
|
4
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
-
*
|
|
6
|
-
* This file is part of Neo4j.
|
|
7
|
-
*
|
|
8
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
1
|
"use strict";
|
|
23
|
-
Object.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
const require_charts_ChartTooltip = require("../ChartTooltip.js");
|
|
7
|
+
const require_charts_utils_format_utils = require("./format-utils.js");
|
|
8
|
+
const require_charts_utils_scatter_tooltip_points = require("./scatter-tooltip-points.js");
|
|
9
|
+
const require_charts_utils_threshold = require("./threshold.js");
|
|
10
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let react_dom_server = require("react-dom/server");
|
|
13
|
+
// src/charts/utils/chart-tooltip-formatter.tsx
|
|
14
|
+
/*!
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) "Neo4j"
|
|
17
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
18
|
+
*
|
|
19
|
+
* This file is part of Neo4j.
|
|
20
|
+
*
|
|
21
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
22
|
+
* it under the terms of the GNU General Public License as published by
|
|
23
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
24
|
+
* (at your option) any later version.
|
|
25
|
+
*
|
|
26
|
+
* This program is distributed in the hope that it will be useful,
|
|
27
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29
|
+
* GNU General Public License for more details.
|
|
30
|
+
*
|
|
31
|
+
* You should have received a copy of the GNU General Public License
|
|
32
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
+
*/
|
|
34
34
|
function getTooltipValueFormatter(userOption) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'valueFormatter' in userOption.tooltip) {
|
|
38
|
-
return userOption.tooltip.valueFormatter;
|
|
39
|
-
}
|
|
40
|
-
return format_utils_1.formatTooltipValue;
|
|
35
|
+
if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === "object" && userOption.tooltip !== null && "valueFormatter" in userOption.tooltip) return userOption.tooltip.valueFormatter;
|
|
36
|
+
return require_charts_utils_format_utils.formatTooltipValue;
|
|
41
37
|
}
|
|
42
38
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
* Upper bound on the points one tooltip lists, so a dense cluster cannot grow
|
|
40
|
+
* a tooltip that covers the chart.
|
|
41
|
+
*/
|
|
46
42
|
const MAX_TOOLTIP_POINTS = 5;
|
|
47
43
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function createAxisTooltipFormatter({ thresholdLines, userOption
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
? `${(0, format_utils_1.capitalizeFirstLetter)((0, threshold_2.getThresholdLineDisplayName)(series.seriesName))} threshold`
|
|
89
|
-
: series.seriesName, trailingElement: valueFormatter(value), indentSquareColor: series.color, notifications: notifications }, series.seriesName));
|
|
90
|
-
})] }))}`;
|
|
91
|
-
};
|
|
44
|
+
* Builds the ECharts axis-tooltip formatter used by line-like charts.
|
|
45
|
+
* It renders Needle tooltip markup and augments non-threshold series with
|
|
46
|
+
* threshold notifications when their current value crosses a threshold line.
|
|
47
|
+
*/
|
|
48
|
+
function createAxisTooltipFormatter({ thresholdLines, userOption }) {
|
|
49
|
+
const valueFormatter = getTooltipValueFormatter(userOption);
|
|
50
|
+
return function axisTooltipFormatter(params) {
|
|
51
|
+
var _firstParam$axisValue;
|
|
52
|
+
const paramsArray = Array.isArray(params) ? params : [params];
|
|
53
|
+
const firstParam = paramsArray[0];
|
|
54
|
+
return `${(0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
55
|
+
className: "ndl-charts-chart-tooltip",
|
|
56
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Title, { children: (_firstParam$axisValue = firstParam === null || firstParam === void 0 ? void 0 : firstParam.axisValueLabel) !== null && _firstParam$axisValue !== void 0 ? _firstParam$axisValue : "" }), paramsArray.map((series) => {
|
|
57
|
+
const value = require_charts_utils_format_utils.extractValueFromTooltipSeries(series.value, series.encode, series.axisDim);
|
|
58
|
+
const seriesValue = typeof value === "number" ? value : Number(value);
|
|
59
|
+
const isSeriesThresholdLine = require_charts_utils_threshold.isThresholdLine(series.seriesName);
|
|
60
|
+
const notifications = thresholdLines.flatMap((threshold) => {
|
|
61
|
+
if (isSeriesThresholdLine || Number.isNaN(seriesValue)) return [];
|
|
62
|
+
const { notificationType, value: thresholdValue, condition, customConditionText, customCondition } = threshold;
|
|
63
|
+
const conditionEvaluation = customCondition ? {
|
|
64
|
+
conditionText: customConditionText,
|
|
65
|
+
isConditionMet: customCondition(seriesValue, thresholdValue)
|
|
66
|
+
} : require_charts_utils_threshold.evaluateThresholdCondition(seriesValue, condition, thresholdValue);
|
|
67
|
+
if (!conditionEvaluation.isConditionMet) return [];
|
|
68
|
+
return [{
|
|
69
|
+
id: `threshold-${notificationType}`,
|
|
70
|
+
leadingElement: customCondition ? conditionEvaluation.conditionText : `${conditionEvaluation.conditionText} threshold`,
|
|
71
|
+
notificationType,
|
|
72
|
+
trailingElement: valueFormatter(thresholdValue)
|
|
73
|
+
}];
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Content, {
|
|
76
|
+
leadingElement: isSeriesThresholdLine ? `${require_charts_utils_format_utils.capitalizeFirstLetter(require_charts_utils_threshold.getThresholdLineDisplayName(series.seriesName))} threshold` : series.seriesName,
|
|
77
|
+
trailingElement: valueFormatter(value),
|
|
78
|
+
indentSquareColor: series.color,
|
|
79
|
+
notifications
|
|
80
|
+
}, series.seriesName);
|
|
81
|
+
})]
|
|
82
|
+
}))}`;
|
|
83
|
+
};
|
|
92
84
|
}
|
|
93
85
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
function createScatterTooltipFormatter({ dataset, getChartInstance, getLegendSelected, series, seriesAxisNames, userOption
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
radius,
|
|
170
|
-
series,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (_a) {
|
|
174
|
-
points = [hovered];
|
|
175
|
-
}
|
|
176
|
-
return `${(0, server_1.renderToString)((0, jsx_runtime_1.jsx)("span", { className: "ndl-charts-chart-tooltip", children: points.map((point, index) => {
|
|
177
|
-
var _a;
|
|
178
|
-
return renderPoint(point, `${point.seriesIndex}-${(_a = point.dataIndex) !== null && _a !== void 0 ? _a : index}`);
|
|
179
|
-
}) }))}`;
|
|
180
|
-
};
|
|
86
|
+
* Builds the ECharts item-tooltip formatter used by scatter charts.
|
|
87
|
+
*
|
|
88
|
+
* The title comes from ECharts `encode.tooltip`, then `encode.itemName`, then
|
|
89
|
+
* an extra data dimension, and otherwise the series name. x and y are listed
|
|
90
|
+
* underneath. See https://echarts.apache.org/en/option.html#series-scatter.encode
|
|
91
|
+
*
|
|
92
|
+
* `tooltip.valueFormatter` runs on the x and y values only. Those calls pass
|
|
93
|
+
* `{ axis: 'x' | 'y' }` (`TooltipValueContext`) as the third argument. The
|
|
94
|
+
* title is shown unchanged.
|
|
95
|
+
*
|
|
96
|
+
* Points whose symbols overlap the hovered one are listed in the same tooltip,
|
|
97
|
+
* closest first, so a cluster is readable without zooming in. Each point gets
|
|
98
|
+
* its own block: the series color sits once on the block title, and the rows
|
|
99
|
+
* are labelled with the axis `name` when the consumer set one, falling back to
|
|
100
|
+
* the dataset dimension name.
|
|
101
|
+
*/
|
|
102
|
+
function createScatterTooltipFormatter({ dataset, getChartInstance, getLegendSelected, series, seriesAxisNames, userOption }) {
|
|
103
|
+
const valueFormatter = getTooltipValueFormatter(userOption);
|
|
104
|
+
const radius = require_charts_utils_scatter_tooltip_points.getScatterSymbolSize(series);
|
|
105
|
+
const seriesList = Array.isArray(series) ? series : [series];
|
|
106
|
+
const renderPoint = (point, key) => {
|
|
107
|
+
var _point$seriesIndex, _point$seriesIndex2, _axisNames$x, _axisNames$y;
|
|
108
|
+
const seriesOption = seriesList[(_point$seriesIndex = point.seriesIndex) !== null && _point$seriesIndex !== void 0 ? _point$seriesIndex : 0];
|
|
109
|
+
const swatchColor = typeof (seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.color) === "string" ? seriesOption.color : point.color;
|
|
110
|
+
const seriesEncode = seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.encode;
|
|
111
|
+
const titleRef = require_charts_utils_scatter_tooltip_points.extraTooltipRefs(require_objectSpread2.default(require_objectSpread2.default({}, point), {}, { encode: require_objectSpread2.default(require_objectSpread2.default(require_objectSpread2.default({}, point.encode), (seriesEncode === null || seriesEncode === void 0 ? void 0 : seriesEncode.tooltip) !== void 0 && { tooltip: seriesEncode.tooltip }), (seriesEncode === null || seriesEncode === void 0 ? void 0 : seriesEncode.itemName) !== void 0 && { itemName: seriesEncode.itemName }) }))[0];
|
|
112
|
+
const pointName = point.name !== void 0 && point.name !== "" ? point.name : point.seriesName;
|
|
113
|
+
const titleValue = titleRef !== void 0 ? require_charts_utils_scatter_tooltip_points.readEncodedValue(point.value, titleRef, point.dimensionNames) : pointName;
|
|
114
|
+
const titleText = titleValue instanceof Date ? require_charts_utils_format_utils.formatTimeAxisDate(titleValue) : typeof titleValue === "string" || typeof titleValue === "number" ? titleValue : void 0;
|
|
115
|
+
const refs = require_charts_utils_scatter_tooltip_points.getEncodedAxisRefs(point.encode);
|
|
116
|
+
const xValue = require_charts_utils_scatter_tooltip_points.readEncodedValue(point.value, refs.x, point.dimensionNames);
|
|
117
|
+
const yValue = require_charts_utils_scatter_tooltip_points.readEncodedValue(point.value, refs.y, point.dimensionNames);
|
|
118
|
+
const axisNames = seriesAxisNames === null || seriesAxisNames === void 0 ? void 0 : seriesAxisNames[(_point$seriesIndex2 = point.seriesIndex) !== null && _point$seriesIndex2 !== void 0 ? _point$seriesIndex2 : 0];
|
|
119
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
120
|
+
className: "ndl-charts-chart-tooltip-point",
|
|
121
|
+
children: [
|
|
122
|
+
titleText !== void 0 && titleText !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Title, {
|
|
123
|
+
indentSquareColor: swatchColor,
|
|
124
|
+
children: titleText
|
|
125
|
+
}),
|
|
126
|
+
xValue !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Content, {
|
|
127
|
+
leadingElement: (_axisNames$x = axisNames === null || axisNames === void 0 ? void 0 : axisNames.x) !== null && _axisNames$x !== void 0 ? _axisNames$x : require_charts_utils_scatter_tooltip_points.encodedDimensionLabel(refs.x, point.dimensionNames, "x"),
|
|
128
|
+
trailingElement: valueFormatter(xValue, point.dataIndex, { axis: "x" })
|
|
129
|
+
}),
|
|
130
|
+
yValue !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Content, {
|
|
131
|
+
leadingElement: (_axisNames$y = axisNames === null || axisNames === void 0 ? void 0 : axisNames.y) !== null && _axisNames$y !== void 0 ? _axisNames$y : require_charts_utils_scatter_tooltip_points.encodedDimensionLabel(refs.y, point.dimensionNames, "y"),
|
|
132
|
+
trailingElement: valueFormatter(yValue, point.dataIndex, { axis: "y" })
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
}, key);
|
|
136
|
+
};
|
|
137
|
+
return function scatterTooltipFormatter(params) {
|
|
138
|
+
const hovered = Array.isArray(params) ? params[0] : params;
|
|
139
|
+
let points = [hovered];
|
|
140
|
+
try {
|
|
141
|
+
points = require_charts_utils_scatter_tooltip_points.findNearbyScatterPoints({
|
|
142
|
+
chart: getChartInstance === null || getChartInstance === void 0 ? void 0 : getChartInstance(),
|
|
143
|
+
dataset,
|
|
144
|
+
hovered,
|
|
145
|
+
legendSelected: getLegendSelected === null || getLegendSelected === void 0 ? void 0 : getLegendSelected(),
|
|
146
|
+
maxPoints: MAX_TOOLTIP_POINTS,
|
|
147
|
+
radius,
|
|
148
|
+
series
|
|
149
|
+
});
|
|
150
|
+
} catch (_unused) {
|
|
151
|
+
points = [hovered];
|
|
152
|
+
}
|
|
153
|
+
return `${(0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
154
|
+
className: "ndl-charts-chart-tooltip",
|
|
155
|
+
children: points.map((point, index) => {
|
|
156
|
+
var _point$dataIndex;
|
|
157
|
+
return renderPoint(point, `${point.seriesIndex}-${(_point$dataIndex = point.dataIndex) !== null && _point$dataIndex !== void 0 ? _point$dataIndex : index}`);
|
|
158
|
+
})
|
|
159
|
+
}))}`;
|
|
160
|
+
};
|
|
181
161
|
}
|
|
162
|
+
exports.createAxisTooltipFormatter = createAxisTooltipFormatter;
|
|
163
|
+
exports.createScatterTooltipFormatter = createScatterTooltipFormatter;
|
|
164
|
+
exports.getTooltipValueFormatter = getTooltipValueFormatter;
|
|
165
|
+
|
|
182
166
|
//# sourceMappingURL=chart-tooltip-formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-tooltip-formatter.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-tooltip-formatter.tsx"],"names":[],"mappings":";;AAgEA,4DAYC;AAsCD,gEAoFC;AAmBD,sEAiIC;;AApUD,6CAAkD;AAElD,kDAA+C;AAE/C,iDAKwB;AACxB,qEASkC;AAClC,2CAAyD;AACzD,2CAIqB;AAiBrB,SAAgB,wBAAwB,CACtC,UAAgC;IAEhC,IACE,OAAO,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,CAAA,KAAK,QAAQ;QACvC,UAAU,CAAC,OAAO,KAAK,IAAI;QAC3B,gBAAgB,IAAI,UAAU,CAAC,OAAO,EACtC,CAAC;QACD,OAAO,UAAU,CAAC,OAAO,CAAC,cAAuC,CAAC;IACpE,CAAC;IAED,OAAO,iCAA2C,CAAC;AACrD,CAAC;AA2BD;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;GAIG;AACH,SAAgB,0BAA0B,CAAC,EACzC,cAAc,EACd,UAAU,GACuB;IACjC,MAAM,cAAc,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAE5D,OAAO,SAAS,oBAAoB,CAAC,MAAe;;QAClD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAElC,OAAO,GAAG,IAAA,uBAAc,EACtB,kCAAM,SAAS,EAAC,0BAA0B,aACxC,uBAAC,2BAAY,CAAC,KAAK,cAChB,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,cAAc,mCAAI,EAAE,GACd,EACpB,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC1B,MAAM,KAAK,GAAG,IAAA,4CAA6B,EACzC,MAAM,CAAC,KAA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AC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CACpB,CAAC;QAEzB,IAAI,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;QAEvB,0EAA0E;QAC1E,0DAA0D;QAC1D,IAAI,CAAC;YACH,MAAM,GAAG,IAAA,gDAAuB,EAAC;gBAC/B,KAAK,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,EAAI;gBAC3B,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,EAAI;gBACrC,SAAS,EAAE,kBAAkB;gBAC7B,MAAM;gBACN,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAAC,WAAM,CAAC;YACP,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,GAAG,IAAA,uBAAc,EACtB,iCAAM,SAAS,EAAC,0BAA0B,YACvC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;gBAC3B,OAAA,WAAW,CACT,KAAK,EACL,GAAG,KAAK,CAAC,WAAW,IAAI,MAAA,KAAK,CAAC,SAAS,mCAAI,KAAK,EAAE,CACnD,CAAA;aAAA,CACF,GACI,CACR,EAAE,CAAC;IACN,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type React from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip } from '../ChartTooltip';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatTimeAxisDate,\n formatTooltipValue,\n} from './format-utils';\nimport {\n encodedDimensionLabel,\n extraTooltipRefs,\n findNearbyScatterPoints,\n getEncodedAxisRefs,\n getScatterSymbolSize,\n readEncodedValue,\n type ScatterTooltipChart,\n type ScatterTooltipPoint,\n} from './scatter-tooltip-points';\nimport { evaluateThresholdCondition } from './threshold';\nimport {\n getThresholdLineDisplayName,\n isThresholdLine,\n type NormalizedThresholdLine,\n} from './threshold';\n\n/**\n * Where a scatter tooltip value comes from. Passed to `tooltip.valueFormatter`\n * as its third argument for the x and y rows, so one formatter can give them\n * different units. The title is not passed to the formatter.\n */\nexport type TooltipValueContext = {\n axis: 'x' | 'y';\n};\n\ntype TooltipValueFormatter = (\n value: unknown,\n dataIndex?: number,\n context?: TooltipValueContext,\n) => React.ReactNode;\n\nexport function getTooltipValueFormatter(\n userOption: ChartProps['option'],\n): TooltipValueFormatter {\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n return userOption.tooltip.valueFormatter as TooltipValueFormatter;\n }\n\n return formatTooltipValue as TooltipValueFormatter;\n}\n\n/**\n * `name` of the x and y axes one series is bound to. `seriesAxisNames` holds\n * one entry per series, indexed by series index.\n */\nexport type SeriesAxisNames = {\n // oxlint-disable-next-line id-length\n x?: string;\n // oxlint-disable-next-line id-length\n y?: string;\n};\n\ntype CreateAxisTooltipFormatterParams = {\n thresholdLines: NormalizedThresholdLine[];\n userOption: ChartProps['option'];\n};\n\ntype CreateScatterTooltipFormatterParams = {\n dataset: ChartProps['dataset'];\n getChartInstance?: () => ScatterTooltipChart | undefined;\n getLegendSelected?: () => Record<string, boolean> | undefined;\n series: EchartsSeries;\n seriesAxisNames?: Array<SeriesAxisNames | undefined>;\n userOption: ChartProps['option'];\n};\n\n/**\n * Upper bound on the points one tooltip lists, so a dense cluster cannot grow\n * a tooltip that covers the chart.\n */\nconst MAX_TOOLTIP_POINTS = 5;\n\n/**\n * Builds the ECharts axis-tooltip formatter used by line-like charts.\n * It renders Needle tooltip markup and augments non-threshold series with\n * threshold notifications when their current value crosses a threshold line.\n */\nexport function createAxisTooltipFormatter({\n thresholdLines,\n userOption,\n}: CreateAxisTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n\n return function axisTooltipFormatter(params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>\n {firstParam?.axisValueLabel ?? ''}\n </ChartTooltip.Title>\n {paramsArray.map((series) => {\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n const seriesValue = typeof value === 'number' ? value : Number(value);\n\n const isSeriesThresholdLine = isThresholdLine(series.seriesName);\n\n const notifications = thresholdLines.flatMap((threshold) => {\n if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {\n return [];\n }\n\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n const conditionEvaluation = customCondition\n ? {\n conditionText: customConditionText,\n isConditionMet: customCondition(seriesValue, thresholdValue),\n }\n : evaluateThresholdCondition(\n seriesValue,\n condition,\n thresholdValue,\n );\n\n if (!conditionEvaluation.isConditionMet) {\n return [];\n }\n\n return [\n {\n id: `threshold-${notificationType}`,\n leadingElement: customCondition\n ? conditionEvaluation.conditionText\n : `${conditionEvaluation.conditionText} threshold`,\n notificationType,\n trailingElement: valueFormatter(thresholdValue),\n },\n ];\n });\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isSeriesThresholdLine\n ? `${capitalizeFirstLetter(\n getThresholdLineDisplayName(series.seriesName),\n )} threshold`\n : series.seriesName\n }\n trailingElement={valueFormatter(value)}\n indentSquareColor={series.color}\n notifications={notifications}\n />\n );\n })}\n </span>,\n )}`;\n };\n}\n\n/**\n * Builds the ECharts item-tooltip formatter used by scatter charts.\n *\n * The title comes from ECharts `encode.tooltip`, then `encode.itemName`, then\n * an extra data dimension, and otherwise the series name. x and y are listed\n * underneath. See https://echarts.apache.org/en/option.html#series-scatter.encode\n *\n * `tooltip.valueFormatter` runs on the x and y values only. Those calls pass\n * `{ axis: 'x' | 'y' }` (`TooltipValueContext`) as the third argument. The\n * title is shown unchanged.\n *\n * Points whose symbols overlap the hovered one are listed in the same tooltip,\n * closest first, so a cluster is readable without zooming in. Each point gets\n * its own block: the series color sits once on the block title, and the rows\n * are labelled with the axis `name` when the consumer set one, falling back to\n * the dataset dimension name.\n */\nexport function createScatterTooltipFormatter({\n dataset,\n getChartInstance,\n getLegendSelected,\n series,\n seriesAxisNames,\n userOption,\n}: CreateScatterTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n const radius = getScatterSymbolSize(series);\n const seriesList = Array.isArray(series) ? series : [series];\n\n const renderPoint = (point: ScatterTooltipPoint, key: string) => {\n // ECharts only copies x/y into the hovered point's `encode`. The dimension\n // the consumer set on `encode.tooltip` (or `itemName`) still lives on the\n // series option, which is what the nearby points are already read from.\n const seriesOption = seriesList[point.seriesIndex ?? 0] as\n | { color?: unknown; encode?: Record<string, unknown> }\n | undefined;\n // The hovered point's own color is its theme-colored interior. The swatch\n // uses the series color, which is the ring.\n const swatchColor =\n typeof seriesOption?.color === 'string'\n ? seriesOption.color\n : point.color;\n const seriesEncode = seriesOption?.encode;\n const titleRef = extraTooltipRefs({\n ...point,\n encode: {\n ...point.encode,\n ...(seriesEncode?.tooltip !== undefined && {\n tooltip: seriesEncode.tooltip,\n }),\n ...(seriesEncode?.itemName !== undefined && {\n itemName: seriesEncode.itemName,\n }),\n },\n })[0];\n // ECharts reports `name` as '' when a point has no name dimension, which\n // would hide the title and the color swatch. The series name fills that in.\n const pointName =\n point.name !== undefined && point.name !== ''\n ? point.name\n : point.seriesName;\n const titleValue =\n titleRef !== undefined\n ? readEncodedValue(point.value, titleRef, point.dimensionNames)\n : pointName;\n // The title identifies the point, so it is not run through\n // `valueFormatter`. Only string and number titles are renderable children,\n // so dates are formatted like the time axis.\n const titleText =\n titleValue instanceof Date\n ? formatTimeAxisDate(titleValue)\n : typeof titleValue === 'string' || typeof titleValue === 'number'\n ? titleValue\n : undefined;\n const refs = getEncodedAxisRefs(point.encode);\n const xValue = readEncodedValue(point.value, refs.x, point.dimensionNames);\n const yValue = readEncodedValue(point.value, refs.y, point.dimensionNames);\n const axisNames = seriesAxisNames?.[point.seriesIndex ?? 0];\n\n return (\n <div className=\"ndl-charts-chart-tooltip-point\" key={key}>\n {titleText !== undefined && titleText !== '' && (\n <ChartTooltip.Title indentSquareColor={swatchColor}>\n {titleText}\n </ChartTooltip.Title>\n )}\n {xValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.x ??\n encodedDimensionLabel(refs.x, point.dimensionNames, 'x')\n }\n trailingElement={valueFormatter(xValue, point.dataIndex, {\n axis: 'x',\n })}\n />\n )}\n {yValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.y ??\n encodedDimensionLabel(refs.y, point.dimensionNames, 'y')\n }\n trailingElement={valueFormatter(yValue, point.dataIndex, {\n axis: 'y',\n })}\n />\n )}\n </div>\n );\n };\n\n return function scatterTooltipFormatter(params: unknown) {\n const hovered = (\n Array.isArray(params) ? params[0] : params\n ) as ScatterTooltipPoint;\n\n let points = [hovered];\n\n // A tooltip that throws leaves the chart without any tooltip at all, so a\n // failed neighbor lookup falls back to the hovered point.\n try {\n points = findNearbyScatterPoints({\n chart: getChartInstance?.(),\n dataset,\n hovered,\n legendSelected: getLegendSelected?.(),\n maxPoints: MAX_TOOLTIP_POINTS,\n radius,\n series,\n });\n } catch {\n points = [hovered];\n }\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n {points.map((point, index) =>\n renderPoint(\n point,\n `${point.seriesIndex}-${point.dataIndex ?? index}`,\n ),\n )}\n </span>,\n )}`;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-tooltip-formatter.js","names":["formatTooltipValue","renderToString","ChartTooltip","extractValueFromTooltipSeries","isThresholdLine","evaluateThresholdCondition","capitalizeFirstLetter","getThresholdLineDisplayName","getScatterSymbolSize","extraTooltipRefs","readEncodedValue","formatTimeAxisDate","getEncodedAxisRefs","encodedDimensionLabel","findNearbyScatterPoints"],"sources":["../../../../src/charts/utils/chart-tooltip-formatter.tsx"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type React from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip } from '../ChartTooltip';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatTimeAxisDate,\n formatTooltipValue,\n} from './format-utils';\nimport {\n encodedDimensionLabel,\n extraTooltipRefs,\n findNearbyScatterPoints,\n getEncodedAxisRefs,\n getScatterSymbolSize,\n readEncodedValue,\n type ScatterTooltipChart,\n type ScatterTooltipPoint,\n} from './scatter-tooltip-points';\nimport { evaluateThresholdCondition } from './threshold';\nimport {\n getThresholdLineDisplayName,\n isThresholdLine,\n type NormalizedThresholdLine,\n} from './threshold';\n\n/**\n * Where a scatter tooltip value comes from. Passed to `tooltip.valueFormatter`\n * as its third argument for the x and y rows, so one formatter can give them\n * different units. The title is not passed to the formatter.\n */\nexport type TooltipValueContext = {\n axis: 'x' | 'y';\n};\n\ntype TooltipValueFormatter = (\n value: unknown,\n dataIndex?: number,\n context?: TooltipValueContext,\n) => React.ReactNode;\n\nexport function getTooltipValueFormatter(\n userOption: ChartProps['option'],\n): TooltipValueFormatter {\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n return userOption.tooltip.valueFormatter as TooltipValueFormatter;\n }\n\n return formatTooltipValue as TooltipValueFormatter;\n}\n\n/**\n * `name` of the x and y axes one series is bound to. `seriesAxisNames` holds\n * one entry per series, indexed by series index.\n */\nexport type SeriesAxisNames = {\n // oxlint-disable-next-line id-length\n x?: string;\n // oxlint-disable-next-line id-length\n y?: string;\n};\n\ntype CreateAxisTooltipFormatterParams = {\n thresholdLines: NormalizedThresholdLine[];\n userOption: ChartProps['option'];\n};\n\ntype CreateScatterTooltipFormatterParams = {\n dataset: ChartProps['dataset'];\n getChartInstance?: () => ScatterTooltipChart | undefined;\n getLegendSelected?: () => Record<string, boolean> | undefined;\n series: EchartsSeries;\n seriesAxisNames?: Array<SeriesAxisNames | undefined>;\n userOption: ChartProps['option'];\n};\n\n/**\n * Upper bound on the points one tooltip lists, so a dense cluster cannot grow\n * a tooltip that covers the chart.\n */\nconst MAX_TOOLTIP_POINTS = 5;\n\n/**\n * Builds the ECharts axis-tooltip formatter used by line-like charts.\n * It renders Needle tooltip markup and augments non-threshold series with\n * threshold notifications when their current value crosses a threshold line.\n */\nexport function createAxisTooltipFormatter({\n thresholdLines,\n userOption,\n}: CreateAxisTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n\n return function axisTooltipFormatter(params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>\n {firstParam?.axisValueLabel ?? ''}\n </ChartTooltip.Title>\n {paramsArray.map((series) => {\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n const seriesValue = typeof value === 'number' ? value : Number(value);\n\n const isSeriesThresholdLine = isThresholdLine(series.seriesName);\n\n const notifications = thresholdLines.flatMap((threshold) => {\n if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {\n return [];\n }\n\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n const conditionEvaluation = customCondition\n ? {\n conditionText: customConditionText,\n isConditionMet: customCondition(seriesValue, thresholdValue),\n }\n : evaluateThresholdCondition(\n seriesValue,\n condition,\n thresholdValue,\n );\n\n if (!conditionEvaluation.isConditionMet) {\n return [];\n }\n\n return [\n {\n id: `threshold-${notificationType}`,\n leadingElement: customCondition\n ? conditionEvaluation.conditionText\n : `${conditionEvaluation.conditionText} threshold`,\n notificationType,\n trailingElement: valueFormatter(thresholdValue),\n },\n ];\n });\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isSeriesThresholdLine\n ? `${capitalizeFirstLetter(\n getThresholdLineDisplayName(series.seriesName),\n )} threshold`\n : series.seriesName\n }\n trailingElement={valueFormatter(value)}\n indentSquareColor={series.color}\n notifications={notifications}\n />\n );\n })}\n </span>,\n )}`;\n };\n}\n\n/**\n * Builds the ECharts item-tooltip formatter used by scatter charts.\n *\n * The title comes from ECharts `encode.tooltip`, then `encode.itemName`, then\n * an extra data dimension, and otherwise the series name. x and y are listed\n * underneath. See https://echarts.apache.org/en/option.html#series-scatter.encode\n *\n * `tooltip.valueFormatter` runs on the x and y values only. Those calls pass\n * `{ axis: 'x' | 'y' }` (`TooltipValueContext`) as the third argument. The\n * title is shown unchanged.\n *\n * Points whose symbols overlap the hovered one are listed in the same tooltip,\n * closest first, so a cluster is readable without zooming in. Each point gets\n * its own block: the series color sits once on the block title, and the rows\n * are labelled with the axis `name` when the consumer set one, falling back to\n * the dataset dimension name.\n */\nexport function createScatterTooltipFormatter({\n dataset,\n getChartInstance,\n getLegendSelected,\n series,\n seriesAxisNames,\n userOption,\n}: CreateScatterTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n const radius = getScatterSymbolSize(series);\n const seriesList = Array.isArray(series) ? series : [series];\n\n const renderPoint = (point: ScatterTooltipPoint, key: string) => {\n // ECharts only copies x/y into the hovered point's `encode`. The dimension\n // the consumer set on `encode.tooltip` (or `itemName`) still lives on the\n // series option, which is what the nearby points are already read from.\n const seriesOption = seriesList[point.seriesIndex ?? 0] as\n | { color?: unknown; encode?: Record<string, unknown> }\n | undefined;\n // The hovered point's own color is its theme-colored interior. The swatch\n // uses the series color, which is the ring.\n const swatchColor =\n typeof seriesOption?.color === 'string'\n ? seriesOption.color\n : point.color;\n const seriesEncode = seriesOption?.encode;\n const titleRef = extraTooltipRefs({\n ...point,\n encode: {\n ...point.encode,\n ...(seriesEncode?.tooltip !== undefined && {\n tooltip: seriesEncode.tooltip,\n }),\n ...(seriesEncode?.itemName !== undefined && {\n itemName: seriesEncode.itemName,\n }),\n },\n })[0];\n // ECharts reports `name` as '' when a point has no name dimension, which\n // would hide the title and the color swatch. The series name fills that in.\n const pointName =\n point.name !== undefined && point.name !== ''\n ? point.name\n : point.seriesName;\n const titleValue =\n titleRef !== undefined\n ? readEncodedValue(point.value, titleRef, point.dimensionNames)\n : pointName;\n // The title identifies the point, so it is not run through\n // `valueFormatter`. Only string and number titles are renderable children,\n // so dates are formatted like the time axis.\n const titleText =\n titleValue instanceof Date\n ? formatTimeAxisDate(titleValue)\n : typeof titleValue === 'string' || typeof titleValue === 'number'\n ? titleValue\n : undefined;\n const refs = getEncodedAxisRefs(point.encode);\n const xValue = readEncodedValue(point.value, refs.x, point.dimensionNames);\n const yValue = readEncodedValue(point.value, refs.y, point.dimensionNames);\n const axisNames = seriesAxisNames?.[point.seriesIndex ?? 0];\n\n return (\n <div className=\"ndl-charts-chart-tooltip-point\" key={key}>\n {titleText !== undefined && titleText !== '' && (\n <ChartTooltip.Title indentSquareColor={swatchColor}>\n {titleText}\n </ChartTooltip.Title>\n )}\n {xValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.x ??\n encodedDimensionLabel(refs.x, point.dimensionNames, 'x')\n }\n trailingElement={valueFormatter(xValue, point.dataIndex, {\n axis: 'x',\n })}\n />\n )}\n {yValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.y ??\n encodedDimensionLabel(refs.y, point.dimensionNames, 'y')\n }\n trailingElement={valueFormatter(yValue, point.dataIndex, {\n axis: 'y',\n })}\n />\n )}\n </div>\n );\n };\n\n return function scatterTooltipFormatter(params: unknown) {\n const hovered = (\n Array.isArray(params) ? params[0] : params\n ) as ScatterTooltipPoint;\n\n let points = [hovered];\n\n // A tooltip that throws leaves the chart without any tooltip at all, so a\n // failed neighbor lookup falls back to the hovered point.\n try {\n points = findNearbyScatterPoints({\n chart: getChartInstance?.(),\n dataset,\n hovered,\n legendSelected: getLegendSelected?.(),\n maxPoints: MAX_TOOLTIP_POINTS,\n radius,\n series,\n });\n } catch {\n points = [hovered];\n }\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n {points.map((point, index) =>\n renderPoint(\n point,\n `${point.seriesIndex}-${point.dataIndex ?? index}`,\n ),\n )}\n </span>,\n )}`;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,yBACd,YACuB;CACvB,IACE,QAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAO,WAAY,aAAY,YAC/B,WAAW,YAAY,QACvB,oBAAoB,WAAW,SAE/B,OAAO,WAAW,QAAQ;CAG5B,OAAOA,kCAAAA;AACT;;;;;AA+BA,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,2BAA2B,EACzC,gBACA,cACmC;CACnC,MAAM,iBAAiB,yBAAyB,UAAU;CAE1D,OAAO,SAAS,qBAAq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B,QAAiB;EACvD,MAAM,UACJ,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK;EAGtC,IAAI,SAAS,CAAC,OAAO;EAIrB,IAAI;GACF,SAASC,4CAAAA,wBAAwB;IAC/B,OAAA,qBAAA,QAAA,qBAAA,KAAA,IAAA,KAAA,IAAO,iBAAmB;IAC1B;IACA;IACA,gBAAA,sBAAA,QAAA,sBAAA,KAAA,IAAA,KAAA,IAAgB,kBAAoB;IACpC,WAAW;IACX;IACA;GACF,CAAC;EACH,SAAA,SAAQ;GACN,SAAS,CAAC,OAAO;EACnB;EAEA,OAAO,IAAA,GAAGb,iBAAAA,eAAAA,CACR,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;GAAM,WAAU;GACb,UAAA,OAAO,KAAK,OAAO,UAClB;;IACE,OAAA,YAAA,OACA,GAAG,MAAM,YAAY,IAAA,mBAAG,MAAM,eAAA,QAAA,qBAAA,KAAA,IAAA,mBAAa,OAC7C;GACF,CAAA;EACI,CAAA,CACR;CACF;AACF"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// src/charts/utils/chart-types.ts
|
|
2
7
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) "Neo4j"
|
|
10
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
11
|
+
*
|
|
12
|
+
* This file is part of Neo4j.
|
|
13
|
+
*
|
|
14
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
15
|
+
* it under the terms of the GNU General Public License as published by
|
|
16
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
17
|
+
* (at your option) any later version.
|
|
18
|
+
*
|
|
19
|
+
* This program is distributed in the hope that it will be useful,
|
|
20
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
+
* GNU General Public License for more details.
|
|
23
|
+
*
|
|
24
|
+
* You should have received a copy of the GNU General Public License
|
|
25
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
26
|
+
*/
|
|
27
|
+
|
|
23
28
|
//# sourceMappingURL=chart-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-types.js","
|
|
1
|
+
{"version":3,"file":"chart-types.js","names":[],"sources":["../../../../src/charts/utils/chart-types.ts"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n type EChartsOption,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n type SetOptionOpts,\n} from 'echarts';\n\nexport type HexColor = `#${string}`;\n\nexport type Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\nexport interface ThresholdLineSeriesOption<\n T extends NotificationType,\n> extends Omit<LineSeriesOption, 'type'> {\n type: 'thresholdLine';\n yAxis: number;\n xAxis: [number, number];\n notificationType: T;\n color?: string;\n condition?: Condition;\n customConditionText?: string;\n customCondition?: CustomCondition;\n}\n\n// Only one threshold line of each type is allowed.\nexport type NeedleSeries =\n | [\n ThresholdLineSeriesOption<'warning'>,\n ThresholdLineSeriesOption<'danger'>,\n ...SeriesOption[],\n ]\n | [ThresholdLineSeriesOption<'danger'>, ...SeriesOption[]]\n | [ThresholdLineSeriesOption<'warning'>, ...SeriesOption[]]\n | SeriesOption[];\n\n/** The zoom window of one configured `dataZoom` component, as reported by `onZoom`. */\nexport type ChartZoomEntry = {\n id?: string | number;\n xAxisIndex?: number | number[] | false;\n yAxisIndex?: number | number[] | false;\n /** Percent, 0–100. */\n startPercent: number;\n /** Percent, 0–100. */\n endPercent: number;\n /** Data value; the category index on a category axis. */\n startValue?: number;\n /** Data value; the category index on a category axis. */\n endValue?: number;\n};\n\nexport interface ChartProps {\n /** The dataset configuration for the chart. Can be a single dataset or an array of datasets. */\n dataset: EChartsOption['dataset'];\n /** The series configuration for the chart. Defines what data to display and how to display it. */\n series: NeedleSeries;\n /** X-axis configuration for the chart. */\n xAxis?: EChartsOption['xAxis'];\n /** Y-axis configuration for the chart. */\n yAxis?: EChartsOption['yAxis'];\n /** Legend configuration for the chart. */\n legend?: {\n /** Whether the legend is visible. */\n isVisible?: boolean;\n };\n /** Additional ECharts options to merge with the chart configuration. */\n option?: Omit<\n EChartsOption,\n 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'\n >;\n /** Custom CSS styles to apply to the chart container. */\n style?: React.CSSProperties;\n /**\n * Settings for how ECharts should update the chart. Defaults to replacing the\n * components the chart owns (`series`, `dataset`, axes, and similar) while\n * merging the rest, which drops data that disappeared without discarding the\n * ECharts components behind zoom interactions. Passing `notMerge: true`\n * re-creates those components on every update and breaks drag-to-zoom.\n */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n /**\n * Called after every zoom change: slider or inside drag, drag-to-zoom and\n * the double-click reset. Only fires when `dataZoom` is configured; to\n * track drag-to-zoom on its own, add `dataZoom: [{ type: 'inside' }]`.\n *\n * `dataZoom` holds one entry per `dataZoom` component you configured, in\n * config order, so the values can be passed back as\n * `startValue`/`endValue` to restore the zoom. `id` and the axis indices\n * are copied from the config, so they are `undefined` when not set there.\n */\n onZoom?: (params: {\n // TODO v6: remove startValue and endValue\n /** @deprecated Only reflects the first `dataZoom` entry, use `dataZoom[0].startValue` instead. */\n startValue: number;\n /** @deprecated Only reflects the first `dataZoom` entry, use `dataZoom[0].endValue` instead. */\n endValue: number;\n dataZoom: ChartZoomEntry[];\n }) => void;\n };\n /** Data zoom configuration for the chart. */\n dataZoom?: EChartsOption['dataZoom'];\n /** Whether the zoom in the chart is disabled */\n isChartZoomDisabled?: boolean;\n /** Custom color palette that overrides the default categorical colors. */\n palette?: HexColor[];\n}\n\nexport interface ChartEmptyProps {\n /** A text displayed to the user when the chart is empty. */\n message?: React.ReactNode;\n /** The type of chart. This is used to render the appropriate icon. */\n type?: 'line' | 'pie' | 'bar';\n /** Optional element (preferably a TextButton) that should provide the user with an action. */\n action?: React.ReactNode;\n}\n\n/**\n * Chart tooltip\n */\n\n/**\n * Client coordinates used to anchor a floating element at a fixed point (e.g.\n * the cursor position), instead of at an anchor element.\n */\ntype AnchorPosition = {\n // oxlint-disable-next-line id-length\n x: number;\n // oxlint-disable-next-line id-length\n y: number;\n};\n\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: AnchorPosition;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport type NotificationType = 'warning' | 'danger';\n\nexport type Notification = {\n leadingElement: React.ReactNode;\n trailingElement: React.ReactNode;\n notificationType: NotificationType;\n id: string;\n};\n\nexport type ChartTooltipContentProps = {\n leadingElement?: React.ReactNode;\n trailingElement?: React.ReactNode;\n indentSquareColor?: string;\n notifications?: Notification[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\n/**\n * Legend\n */\nexport interface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n isSelected?: boolean;\n isDeselected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nexport type LegendProps = {\n series: {\n name: string;\n color: string;\n }[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n"],"mappings":""}
|