@neo4j-ndl/react-charts 2.1.22 → 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,114 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
const require_charts_utils_defaults = require("./defaults.js");
|
|
7
|
+
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js");
|
|
8
|
+
// src/charts/utils/threshold.ts
|
|
2
9
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
exports.normalizeThresholdLines = normalizeThresholdLines;
|
|
25
|
-
exports.evaluateThresholdCondition = evaluateThresholdCondition;
|
|
26
|
-
exports.thresholdConditionToText = thresholdConditionToText;
|
|
27
|
-
const defaults_1 = require("./defaults");
|
|
28
|
-
const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
|
|
29
|
-
exports.isThresholdLine = isThresholdLine;
|
|
30
|
-
const getThresholdLineDisplayName = (name) => name.replace('thresholdLine-', '');
|
|
31
|
-
exports.getThresholdLineDisplayName = getThresholdLineDisplayName;
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) "Neo4j"
|
|
12
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
13
|
+
*
|
|
14
|
+
* This file is part of Neo4j.
|
|
15
|
+
*
|
|
16
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
17
|
+
* it under the terms of the GNU General Public License as published by
|
|
18
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
19
|
+
* (at your option) any later version.
|
|
20
|
+
*
|
|
21
|
+
* This program is distributed in the hope that it will be useful,
|
|
22
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
+
* GNU General Public License for more details.
|
|
25
|
+
*
|
|
26
|
+
* You should have received a copy of the GNU General Public License
|
|
27
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
28
|
+
*/
|
|
29
|
+
const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith("thresholdLine");
|
|
30
|
+
const getThresholdLineDisplayName = (name) => name.replace("thresholdLine-", "");
|
|
32
31
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
* Extracts threshold-line series and resolves defaults needed by tooltips.
|
|
33
|
+
*/
|
|
35
34
|
function normalizeThresholdLines(propsSeries) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
return (Array.isArray(propsSeries) ? propsSeries : [propsSeries]).filter((currentSeries) => {
|
|
36
|
+
return currentSeries.type === "thresholdLine";
|
|
37
|
+
}).map((currentThresholdLineSeriesOption) => {
|
|
38
|
+
var _currentThresholdLine;
|
|
39
|
+
return require_objectSpread2.default(require_objectSpread2.default({}, currentThresholdLineSeriesOption), {}, {
|
|
40
|
+
condition: (_currentThresholdLine = currentThresholdLineSeriesOption.condition) !== null && _currentThresholdLine !== void 0 ? _currentThresholdLine : require_charts_utils_defaults.defaultThresholdLineSeriesOption.condition,
|
|
41
|
+
value: currentThresholdLineSeriesOption.yAxis
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
* Evaluates a threshold condition and returns the short label used by
|
|
47
|
+
* chart tooltip notifications.
|
|
48
|
+
*/
|
|
49
49
|
function evaluateThresholdCondition(value, condition, threshold) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
return {
|
|
81
|
-
conditionText: 'Equal',
|
|
82
|
-
isConditionMet: value === threshold,
|
|
83
|
-
};
|
|
84
|
-
case 'notEqual':
|
|
85
|
-
return {
|
|
86
|
-
conditionText: 'Not equal',
|
|
87
|
-
isConditionMet: value !== threshold,
|
|
88
|
-
};
|
|
89
|
-
default:
|
|
90
|
-
return { conditionText: undefined, isConditionMet: false };
|
|
91
|
-
}
|
|
50
|
+
switch (condition) {
|
|
51
|
+
case "greater": return {
|
|
52
|
+
conditionText: "Above",
|
|
53
|
+
isConditionMet: value > threshold
|
|
54
|
+
};
|
|
55
|
+
case "greaterOrEqual": return {
|
|
56
|
+
conditionText: value > threshold ? "Above" : value === threshold ? "Equal" : void 0,
|
|
57
|
+
isConditionMet: value >= threshold
|
|
58
|
+
};
|
|
59
|
+
case "less": return {
|
|
60
|
+
conditionText: "Below",
|
|
61
|
+
isConditionMet: value < threshold
|
|
62
|
+
};
|
|
63
|
+
case "lessOrEqual": return {
|
|
64
|
+
conditionText: value < threshold ? "Below" : value === threshold ? "Equal" : void 0,
|
|
65
|
+
isConditionMet: value <= threshold
|
|
66
|
+
};
|
|
67
|
+
case "equal": return {
|
|
68
|
+
conditionText: "Equal",
|
|
69
|
+
isConditionMet: value === threshold
|
|
70
|
+
};
|
|
71
|
+
case "notEqual": return {
|
|
72
|
+
conditionText: "Not equal",
|
|
73
|
+
isConditionMet: value !== threshold
|
|
74
|
+
};
|
|
75
|
+
default: return {
|
|
76
|
+
conditionText: void 0,
|
|
77
|
+
isConditionMet: false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
92
80
|
}
|
|
93
81
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
* Returns the longer condition phrase used in chart aria descriptions.
|
|
83
|
+
*/
|
|
96
84
|
function thresholdConditionToText(condition) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 'equal':
|
|
107
|
-
return 'equal to';
|
|
108
|
-
case 'notEqual':
|
|
109
|
-
return 'not equal to';
|
|
110
|
-
default:
|
|
111
|
-
return 'compared to';
|
|
112
|
-
}
|
|
85
|
+
switch (condition) {
|
|
86
|
+
case "greater": return "greater than";
|
|
87
|
+
case "greaterOrEqual": return "greater than or equal to";
|
|
88
|
+
case "less": return "less than";
|
|
89
|
+
case "lessOrEqual": return "less than or equal to";
|
|
90
|
+
case "equal": return "equal to";
|
|
91
|
+
case "notEqual": return "not equal to";
|
|
92
|
+
default: return "compared to";
|
|
93
|
+
}
|
|
113
94
|
}
|
|
95
|
+
exports.evaluateThresholdCondition = evaluateThresholdCondition;
|
|
96
|
+
exports.getThresholdLineDisplayName = getThresholdLineDisplayName;
|
|
97
|
+
exports.isThresholdLine = isThresholdLine;
|
|
98
|
+
exports.normalizeThresholdLines = normalizeThresholdLines;
|
|
99
|
+
exports.thresholdConditionToText = thresholdConditionToText;
|
|
100
|
+
|
|
114
101
|
//# sourceMappingURL=threshold.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threshold.js","
|
|
1
|
+
{"version":3,"file":"threshold.js","names":["defaultThresholdLineSeriesOption"],"sources":["../../../../src/charts/utils/threshold.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 type {\n Condition,\n NeedleSeries,\n NotificationType,\n ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\n\nexport type NormalizedThresholdLine =\n ThresholdLineSeriesOption<NotificationType> & {\n condition: NonNullable<\n ThresholdLineSeriesOption<NotificationType>['condition']\n >;\n value: number;\n };\n\nexport type ThresholdConditionEvaluation = {\n isConditionMet: boolean;\n conditionText: string | undefined;\n};\n\nexport const isThresholdLine = (name?: string) =>\n name?.startsWith('thresholdLine');\n\nexport const getThresholdLineDisplayName = (name: string) =>\n name.replace('thresholdLine-', '');\n\n/**\n * Extracts threshold-line series and resolves defaults needed by tooltips.\n */\nexport function normalizeThresholdLines(\n propsSeries: NeedleSeries,\n): NormalizedThresholdLine[] {\n const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];\n\n const thresholdLineSeries = seriesArray.filter((currentSeries) => {\n return currentSeries.type === 'thresholdLine';\n }) as ThresholdLineSeriesOption<NotificationType>[];\n\n return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {\n return {\n ...currentThresholdLineSeriesOption,\n condition:\n currentThresholdLineSeriesOption.condition ??\n defaultThresholdLineSeriesOption.condition,\n value: currentThresholdLineSeriesOption.yAxis,\n };\n });\n}\n\n/**\n * Evaluates a threshold condition and returns the short label used by\n * chart tooltip notifications.\n */\nexport function evaluateThresholdCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): ThresholdConditionEvaluation {\n switch (condition) {\n case 'greater':\n return {\n conditionText: 'Above',\n isConditionMet: value > threshold,\n };\n case 'greaterOrEqual':\n return {\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value >= threshold,\n };\n case 'less':\n return {\n conditionText: 'Below',\n isConditionMet: value < threshold,\n };\n case 'lessOrEqual':\n return {\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value <= threshold,\n };\n case 'equal':\n return {\n conditionText: 'Equal',\n isConditionMet: value === threshold,\n };\n case 'notEqual':\n return {\n conditionText: 'Not equal',\n isConditionMet: value !== threshold,\n };\n default:\n return { conditionText: undefined, isConditionMet: false };\n }\n}\n\n/**\n * Returns the longer condition phrase used in chart aria descriptions.\n */\nexport function thresholdConditionToText(condition: Condition): string {\n switch (condition) {\n case 'greater':\n return 'greater than';\n case 'greaterOrEqual':\n return 'greater than or equal to';\n case 'less':\n return 'less than';\n case 'lessOrEqual':\n return 'less than or equal to';\n case 'equal':\n return 'equal to';\n case 'notEqual':\n return 'not equal to';\n default:\n return 'compared to';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,mBAAmB,SAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAC9B,KAAM,WAAW,eAAe;AAElC,MAAa,+BAA+B,SAC1C,KAAK,QAAQ,kBAAkB,EAAE;;;;AAKnC,SAAgB,wBACd,aAC2B;CAO3B,QANoB,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,EAAA,CAEnC,QAAQ,kBAAkB;EAChE,OAAO,cAAc,SAAS;CAChC,CAEyB,CAAC,CAAC,KAAK,qCAAqC;;EACnE,OAAA,sBAAA,QAAA,sBAAA,QAAA,CAAA,GACK,gCAAA,GAAA,CAAA,GAAA;GACH,YAAA,wBACE,iCAAiC,eAAA,QAAA,0BAAA,KAAA,IAAA,wBACjCA,8BAAAA,iCAAiC;GACnC,OAAO,iCAAiC;EAC1C,CAAA;CACF,CAAC;AACH;;;;;AAMA,SAAgB,2BACd,OACA,WACA,WAC8B;CAC9B,QAAQ,WAAR;EACE,KAAK,WACH,OAAO;GACL,eAAe;GACf,gBAAgB,QAAQ;EAC1B;EACF,KAAK,kBACH,OAAO;GACL,eACE,QAAQ,YACJ,UACA,UAAU,YACR,UACA,KAAA;GACR,gBAAgB,SAAS;EAC3B;EACF,KAAK,QACH,OAAO;GACL,eAAe;GACf,gBAAgB,QAAQ;EAC1B;EACF,KAAK,eACH,OAAO;GACL,eACE,QAAQ,YACJ,UACA,UAAU,YACR,UACA,KAAA;GACR,gBAAgB,SAAS;EAC3B;EACF,KAAK,SACH,OAAO;GACL,eAAe;GACf,gBAAgB,UAAU;EAC5B;EACF,KAAK,YACH,OAAO;GACL,eAAe;GACf,gBAAgB,UAAU;EAC5B;EACF,SACE,OAAO;GAAE,eAAe,KAAA;GAAW,gBAAgB;EAAM;CAC7D;AACF;;;;AAKA,SAAgB,yBAAyB,WAA8B;CACrE,QAAQ,WAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,eACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
|