@neo4j-ndl/react-charts 1.1.1 → 1.1.3
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/cjs/charts/Chart.js +56 -462
- package/lib/cjs/charts/Chart.js.map +1 -1
- package/lib/cjs/charts/ChartContainer.js +71 -0
- package/lib/cjs/charts/ChartContainer.js.map +1 -0
- package/lib/cjs/charts/ChartEmpty.js.map +1 -1
- package/lib/cjs/charts/ChartRender.js +97 -0
- package/lib/cjs/charts/ChartRender.js.map +1 -0
- package/lib/cjs/charts/ChartTooltip.js.map +1 -1
- package/lib/cjs/charts/Legend.js +32 -246
- package/lib/cjs/charts/Legend.js.map +1 -1
- package/lib/cjs/charts/LegendItem.js +68 -0
- package/lib/cjs/charts/LegendItem.js.map +1 -0
- package/lib/cjs/charts/LegendLayout.js +363 -0
- package/lib/cjs/charts/LegendLayout.js.map +1 -0
- package/lib/cjs/charts/hooks/use-chart-instance.js +133 -0
- package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -0
- package/lib/cjs/charts/hooks/use-chart-option.js +79 -0
- package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -0
- package/lib/cjs/charts/hooks/use-chart-refs.js +52 -0
- package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -0
- package/lib/cjs/charts/hooks/use-chart-zoom.js +117 -0
- package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -0
- package/lib/cjs/charts/hooks/use-legend-interactions.js +149 -0
- package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -0
- package/lib/cjs/charts/hooks/use-legend-series.js +181 -0
- package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -0
- package/lib/cjs/charts/hooks/use-legend-visibility.js +91 -0
- package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -0
- package/lib/cjs/charts/index.js +1 -1
- package/lib/cjs/charts/index.js.map +1 -1
- package/lib/cjs/charts/tests/chart-test-utils.js +56 -9
- package/lib/cjs/charts/tests/chart-test-utils.js.map +1 -1
- package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
- package/lib/cjs/charts/{aria-description.js → utils/aria-description.js} +4 -45
- package/lib/cjs/charts/utils/aria-description.js.map +1 -0
- package/lib/cjs/charts/utils/build-chart-option.js +74 -0
- package/lib/cjs/charts/utils/build-chart-option.js.map +1 -0
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js +86 -0
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -0
- package/lib/cjs/charts/utils/chart-types.js.map +1 -0
- package/lib/cjs/charts/utils/defaults.js.map +1 -0
- package/lib/cjs/charts/{utils.js → utils/format-utils.js} +3 -19
- package/lib/cjs/charts/utils/format-utils.js.map +1 -0
- package/lib/cjs/charts/utils/legend-layout.js +65 -0
- package/lib/cjs/charts/utils/legend-layout.js.map +1 -0
- package/lib/cjs/charts/{legend-utils.js → utils/legend-utils.js} +1 -78
- package/lib/cjs/charts/utils/legend-utils.js.map +1 -0
- package/lib/cjs/charts/utils/threshold.js +114 -0
- package/lib/cjs/charts/utils/threshold.js.map +1 -0
- package/lib/cjs/charts/{user-option-utils.js → utils/user-option-utils.js} +7 -16
- package/lib/cjs/charts/utils/user-option-utils.js.map +1 -0
- package/lib/esm/charts/Chart.js +50 -457
- package/lib/esm/charts/Chart.js.map +1 -1
- package/lib/esm/charts/ChartContainer.js +67 -0
- package/lib/esm/charts/ChartContainer.js.map +1 -0
- package/lib/esm/charts/ChartEmpty.js.map +1 -1
- package/lib/esm/charts/ChartRender.js +93 -0
- package/lib/esm/charts/ChartRender.js.map +1 -0
- package/lib/esm/charts/ChartTooltip.js.map +1 -1
- package/lib/esm/charts/Legend.js +32 -243
- package/lib/esm/charts/Legend.js.map +1 -1
- package/lib/esm/charts/LegendItem.js +61 -0
- package/lib/esm/charts/LegendItem.js.map +1 -0
- package/lib/esm/charts/LegendLayout.js +323 -0
- package/lib/esm/charts/LegendLayout.js.map +1 -0
- package/lib/esm/charts/hooks/use-chart-instance.js +128 -0
- package/lib/esm/charts/hooks/use-chart-instance.js.map +1 -0
- package/lib/esm/charts/hooks/use-chart-option.js +76 -0
- package/lib/esm/charts/hooks/use-chart-option.js.map +1 -0
- package/lib/esm/charts/hooks/use-chart-refs.js +48 -0
- package/lib/esm/charts/hooks/use-chart-refs.js.map +1 -0
- package/lib/esm/charts/hooks/use-chart-zoom.js +114 -0
- package/lib/esm/charts/hooks/use-chart-zoom.js.map +1 -0
- package/lib/esm/charts/hooks/use-legend-interactions.js +145 -0
- package/lib/esm/charts/hooks/use-legend-interactions.js.map +1 -0
- package/lib/esm/charts/hooks/use-legend-series.js +178 -0
- package/lib/esm/charts/hooks/use-legend-series.js.map +1 -0
- package/lib/esm/charts/hooks/use-legend-visibility.js +87 -0
- package/lib/esm/charts/hooks/use-legend-visibility.js.map +1 -0
- package/lib/esm/charts/index.js +1 -1
- package/lib/esm/charts/index.js.map +1 -1
- package/lib/esm/charts/tests/chart-test-utils.js +53 -8
- package/lib/esm/charts/tests/chart-test-utils.js.map +1 -1
- package/lib/esm/charts/themes/ndl-echarts-theme.js.map +1 -1
- package/lib/esm/charts/{aria-description.js → utils/aria-description.js} +4 -45
- package/lib/esm/charts/utils/aria-description.js.map +1 -0
- package/lib/esm/charts/utils/build-chart-option.js +69 -0
- package/lib/esm/charts/utils/build-chart-option.js.map +1 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.js +82 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +1 -0
- package/lib/esm/charts/utils/chart-types.js.map +1 -0
- package/lib/esm/charts/utils/defaults.js.map +1 -0
- package/lib/esm/charts/{utils.js → utils/format-utils.js} +2 -17
- package/lib/esm/charts/utils/format-utils.js.map +1 -0
- package/lib/esm/charts/utils/legend-layout.js +59 -0
- package/lib/esm/charts/utils/legend-layout.js.map +1 -0
- package/lib/esm/charts/{legend-utils.js → utils/legend-utils.js} +1 -75
- package/lib/esm/charts/utils/legend-utils.js.map +1 -0
- package/lib/esm/charts/utils/threshold.js +106 -0
- package/lib/esm/charts/utils/threshold.js.map +1 -0
- package/lib/esm/charts/{user-option-utils.js → utils/user-option-utils.js} +5 -14
- package/lib/esm/charts/utils/user-option-utils.js.map +1 -0
- package/lib/types/charts/Chart.d.ts +2 -2
- package/lib/types/charts/Chart.d.ts.map +1 -1
- package/lib/{esm/charts/types.js → types/charts/ChartContainer.d.ts} +14 -1
- package/lib/types/charts/ChartContainer.d.ts.map +1 -0
- package/lib/types/charts/ChartEmpty.d.ts +1 -1
- package/lib/types/charts/ChartEmpty.d.ts.map +1 -1
- package/lib/types/charts/ChartRender.d.ts +36 -0
- package/lib/types/charts/ChartRender.d.ts.map +1 -0
- package/lib/types/charts/ChartTooltip.d.ts +1 -1
- package/lib/types/charts/ChartTooltip.d.ts.map +1 -1
- package/lib/types/charts/Legend.d.ts +15 -3
- package/lib/types/charts/Legend.d.ts.map +1 -1
- package/lib/{cjs/charts/types.js → types/charts/LegendItem.d.ts} +10 -3
- package/lib/types/charts/LegendItem.d.ts.map +1 -0
- package/lib/types/charts/LegendLayout.d.ts +38 -0
- package/lib/types/charts/LegendLayout.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-chart-instance.d.ts +62 -0
- package/lib/types/charts/hooks/use-chart-instance.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-chart-option.d.ts +48 -0
- package/lib/types/charts/hooks/use-chart-option.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-chart-refs.d.ts +38 -0
- package/lib/types/charts/hooks/use-chart-refs.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-chart-zoom.d.ts +36 -0
- package/lib/types/charts/hooks/use-chart-zoom.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-legend-interactions.d.ts +56 -0
- package/lib/types/charts/hooks/use-legend-interactions.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-legend-series.d.ts +42 -0
- package/lib/types/charts/hooks/use-legend-series.d.ts.map +1 -0
- package/lib/types/charts/hooks/use-legend-visibility.d.ts +24 -0
- package/lib/types/charts/hooks/use-legend-visibility.d.ts.map +1 -0
- package/lib/types/charts/index.d.ts +2 -2
- package/lib/types/charts/index.d.ts.map +1 -1
- package/lib/types/charts/tests/chart-test-utils.d.ts +7 -1
- package/lib/types/charts/tests/chart-test-utils.d.ts.map +1 -1
- package/lib/types/charts/themes/ndl-echarts-theme.d.ts +1 -1
- package/lib/types/charts/themes/ndl-echarts-theme.d.ts.map +1 -1
- package/lib/types/charts/utils/aria-description.d.ts.map +1 -0
- package/lib/types/charts/utils/build-chart-option.d.ts +52 -0
- package/lib/types/charts/utils/build-chart-option.d.ts.map +1 -0
- package/lib/types/charts/utils/chart-tooltip-formatter.d.ts +37 -0
- package/lib/types/charts/utils/chart-tooltip-formatter.d.ts.map +1 -0
- package/lib/types/charts/{chart-types.d.ts → utils/chart-types.d.ts} +23 -22
- package/lib/types/charts/utils/chart-types.d.ts.map +1 -0
- package/lib/types/charts/utils/defaults.d.ts.map +1 -0
- package/lib/types/charts/{utils.d.ts → utils/format-utils.d.ts} +2 -4
- package/lib/types/charts/utils/format-utils.d.ts.map +1 -0
- package/lib/types/charts/utils/legend-layout.d.ts +37 -0
- package/lib/types/charts/utils/legend-layout.d.ts.map +1 -0
- package/lib/types/charts/{legend-utils.d.ts → utils/legend-utils.d.ts} +1 -11
- package/lib/types/charts/utils/legend-utils.d.ts.map +1 -0
- package/lib/types/charts/utils/threshold.d.ts +45 -0
- package/lib/types/charts/utils/threshold.d.ts.map +1 -0
- package/lib/types/charts/utils/user-option-utils.d.ts.map +1 -0
- package/package.json +3 -3
- package/lib/cjs/charts/aria-description.js.map +0 -1
- package/lib/cjs/charts/chart-types.js.map +0 -1
- package/lib/cjs/charts/defaults.js.map +0 -1
- package/lib/cjs/charts/legend-utils.js.map +0 -1
- package/lib/cjs/charts/types.js.map +0 -1
- package/lib/cjs/charts/user-option-utils.js.map +0 -1
- package/lib/cjs/charts/utils.js.map +0 -1
- package/lib/esm/charts/aria-description.js.map +0 -1
- package/lib/esm/charts/chart-types.js.map +0 -1
- package/lib/esm/charts/defaults.js.map +0 -1
- package/lib/esm/charts/legend-utils.js.map +0 -1
- package/lib/esm/charts/types.js.map +0 -1
- package/lib/esm/charts/user-option-utils.js.map +0 -1
- package/lib/esm/charts/utils.js.map +0 -1
- package/lib/types/charts/aria-description.d.ts.map +0 -1
- package/lib/types/charts/chart-types.d.ts.map +0 -1
- package/lib/types/charts/defaults.d.ts.map +0 -1
- package/lib/types/charts/legend-utils.d.ts.map +0 -1
- package/lib/types/charts/types.d.ts +0 -44
- package/lib/types/charts/types.d.ts.map +0 -1
- package/lib/types/charts/user-option-utils.d.ts.map +0 -1
- package/lib/types/charts/utils.d.ts.map +0 -1
- /package/lib/cjs/charts/{chart-types.js → utils/chart-types.js} +0 -0
- /package/lib/cjs/charts/{defaults.js → utils/defaults.js} +0 -0
- /package/lib/esm/charts/{chart-types.js → utils/chart-types.js} +0 -0
- /package/lib/esm/charts/{defaults.js → utils/defaults.js} +0 -0
- /package/lib/types/charts/{aria-description.d.ts → utils/aria-description.d.ts} +0 -0
- /package/lib/types/charts/{defaults.d.ts → utils/defaults.d.ts} +0 -0
- /package/lib/types/charts/{user-option-utils.d.ts → utils/user-option-utils.d.ts} +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
import { renderToString } from 'react-dom/server';
|
|
24
|
+
import { ChartTooltip } from '../ChartTooltip';
|
|
25
|
+
import { capitalizeFirstLetter, extractValueFromTooltipSeries, formatNumberEnUS, } from './format-utils';
|
|
26
|
+
import { evaluateThresholdCondition } from './threshold';
|
|
27
|
+
import { getThresholdLineDisplayName, isThresholdLine, } from './threshold';
|
|
28
|
+
export function getTooltipValueFormatter(userOption) {
|
|
29
|
+
if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
|
|
30
|
+
userOption.tooltip !== null &&
|
|
31
|
+
'valueFormatter' in userOption.tooltip) {
|
|
32
|
+
return userOption.tooltip.valueFormatter;
|
|
33
|
+
}
|
|
34
|
+
return formatNumberEnUS;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Builds the ECharts axis-tooltip formatter used by line-like charts.
|
|
38
|
+
* It renders Needle tooltip markup and augments non-threshold series with
|
|
39
|
+
* threshold notifications when their current value crosses a threshold line.
|
|
40
|
+
*/
|
|
41
|
+
export function createAxisTooltipFormatter({ thresholdLines, userOption, }) {
|
|
42
|
+
const valueFormatter = getTooltipValueFormatter(userOption);
|
|
43
|
+
return function axisTooltipFormatter(params) {
|
|
44
|
+
var _a;
|
|
45
|
+
const paramsArray = Array.isArray(params) ? params : [params];
|
|
46
|
+
const firstParam = paramsArray[0];
|
|
47
|
+
return `${renderToString(_jsxs("span", { className: "ndl-charts-chart-tooltip", children: [_jsx(ChartTooltip.Title, { children: (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.axisValueLabel) !== null && _a !== void 0 ? _a : '' }), paramsArray.map((series) => {
|
|
48
|
+
const value = extractValueFromTooltipSeries(series.value, series.encode, series.axisDim);
|
|
49
|
+
const seriesValue = typeof value === 'number' ? value : Number(value);
|
|
50
|
+
const isSeriesThresholdLine = isThresholdLine(series.seriesName);
|
|
51
|
+
const notifications = thresholdLines.flatMap((threshold) => {
|
|
52
|
+
if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
const { notificationType, value: thresholdValue, condition, customConditionText, customCondition, } = threshold;
|
|
56
|
+
const conditionEvaluation = customCondition
|
|
57
|
+
? {
|
|
58
|
+
conditionText: customConditionText,
|
|
59
|
+
isConditionMet: customCondition(seriesValue, thresholdValue),
|
|
60
|
+
}
|
|
61
|
+
: evaluateThresholdCondition(seriesValue, condition, thresholdValue);
|
|
62
|
+
if (!conditionEvaluation.isConditionMet) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return [
|
|
66
|
+
{
|
|
67
|
+
id: `threshold-${notificationType}`,
|
|
68
|
+
leadingElement: customCondition
|
|
69
|
+
? conditionEvaluation.conditionText
|
|
70
|
+
: `${conditionEvaluation.conditionText} threshold`,
|
|
71
|
+
notificationType,
|
|
72
|
+
trailingElement: valueFormatter(thresholdValue),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
});
|
|
76
|
+
return (_jsx(ChartTooltip.Content, { leadingElement: isSeriesThresholdLine
|
|
77
|
+
? `${capitalizeFirstLetter(getThresholdLineDisplayName(series.seriesName))} threshold`
|
|
78
|
+
: series.seriesName, trailingElement: valueFormatter(value), indentSquareColor: series.color, notifications: notifications }, series.seriesName));
|
|
79
|
+
})] }))}`;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=chart-tooltip-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-tooltip-formatter.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-tooltip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AAqB;4BACnB,CAAC,CAAC,GAAG,qBAAqB,CACtB,2BAA2B,CAAC,MAAM,CAAC,UAAU,CAAC,CAC/C,YAAY;4BACf,CAAC,CAAC,MAAM,CAAC,UAAU,EAEvB,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,EACtC,iBAAiB,EAAE,MAAM,CAAC,KAAK,EAC/B,aAAa,EAAE,aAAa,IAVvB,MAAM,CAAC,UAAU,CAWtB,CACH,CAAC;gBACJ,CAAC,CAAC,IACG,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 } from './chart-types';\nimport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n} from './format-utils';\nimport { evaluateThresholdCondition } from './threshold';\nimport {\n getThresholdLineDisplayName,\n isThresholdLine,\n type NormalizedThresholdLine,\n} from './threshold';\n\ntype TooltipValueFormatter = (value: unknown) => 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 formatNumberEnUS as TooltipValueFormatter;\n}\n\ntype CreateAxisTooltipFormatterParams = {\n thresholdLines: NormalizedThresholdLine[];\n userOption: ChartProps['option'];\n};\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-types.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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\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 show?: boolean;\n // TODO v5: remove this prop\n /** @deprecated Does not do anything since the wrapping is now automatic. Will be removed in v 5 */\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\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 /** Settings for how ECharts should update the chart. */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n onZoom?: (params: { startValue: number; endValue: number }) => 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\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: {\n x: number;\n y: number;\n };\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 selected?: boolean;\n deSelected?: 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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../src/charts/utils/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,gCAAgC,GAElC;IACF,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,OAAO,EAAE,gCAAgC,EAAE,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 { Condition } from './chart-types';\n\nconst defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport { defaultThresholdLineSeriesOption };\n"]}
|
|
@@ -18,21 +18,6 @@
|
|
|
18
18
|
* You should have received a copy of the GNU General Public License
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
import { useCallback, useRef } from 'react';
|
|
22
|
-
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
const useThrottle = (callback, limit) => {
|
|
24
|
-
const lastCallRef = useRef(0);
|
|
25
|
-
const throttledCallback = useCallback(
|
|
26
|
-
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
(...args) => {
|
|
28
|
-
const now = Date.now();
|
|
29
|
-
if (now - lastCallRef.current >= limit) {
|
|
30
|
-
lastCallRef.current = now;
|
|
31
|
-
callback(...args);
|
|
32
|
-
}
|
|
33
|
-
}, [callback, limit]);
|
|
34
|
-
return throttledCallback;
|
|
35
|
-
};
|
|
36
21
|
const capitalizeFirstLetter = (str) => {
|
|
37
22
|
if (!str) {
|
|
38
23
|
return str;
|
|
@@ -70,5 +55,5 @@ axisDim = 'x') => {
|
|
|
70
55
|
: encodeValueToRead;
|
|
71
56
|
return (_b = value[seriesValueIdx]) !== null && _b !== void 0 ? _b : value;
|
|
72
57
|
};
|
|
73
|
-
export { capitalizeFirstLetter,
|
|
74
|
-
//# sourceMappingURL=utils.js.map
|
|
58
|
+
export { capitalizeFirstLetter, extractValueFromTooltipSeries, formatNumberEnUS, };
|
|
59
|
+
//# sourceMappingURL=format-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/format-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAI,KAAQ,EAAc,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA4C,EAC5C,MAGC;AACD,yCAAyC;AACzC,UAAqD,GAAG,EACxD,EAAE;;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6DAA6D;IAC7D,4FAA4F;IAC5F,MAAM,iBAAiB,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,mCAAI,CAAC,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACrD,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,iBAAiB,CAAC;IAEtB,OAAO,MAAA,KAAK,CAAC,cAAc,CAAC,mCAAI,KAAK,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,GACjB,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\nconst capitalizeFirstLetter = (str: string) => {\n if (!str) {\n return str;\n }\n return str.charAt(0).toUpperCase() + str.substring(1);\n};\n\nconst enUSNumberFormatter = new Intl.NumberFormat('en-US');\n\n/**\n * Formats finite number values with en-US separators and returns all other\n * values unchanged.\n */\nconst formatNumberEnUS = <T>(value: T): string | T => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? enUSNumberFormatter.format(value) : value;\n }\n\n return value;\n};\n\n/**\n * Extract the tooltip value from the series depending on the axisDim and encode properties\n * If the value is a single value, return it as it is\n * If the encode property does not exist fallback to 1\n */\nconst extractValueFromTooltipSeries = (\n value: string | number | (number | string)[],\n encode: {\n x: number | number[];\n y: number | number[];\n },\n // We currently only support x and y axes\n axisDim: 'x' | 'y' | 'angle' | 'radius' | 'single' = 'x',\n) => {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // The axisDim is the axis that the tooltip was triggered on,\n // if it was triggered on the x axis the value should be read from the y axis and vice versa\n const encodeValueToRead = axisDim === 'x' ? encode?.y : (encode?.x ?? 1);\n\n const seriesValueIdx = Array.isArray(encodeValueToRead)\n ? encodeValueToRead[0]\n : encodeValueToRead;\n\n return value[seriesValueIdx] ?? value;\n};\n\nexport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n};\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
export const COLLAPSED_LEGEND_ROWS = 2;
|
|
22
|
+
export const COLLAPSED_LEGEND_MAX_HEIGHT = 64;
|
|
23
|
+
/**
|
|
24
|
+
* Get the computed element width, including both paddings and margins
|
|
25
|
+
*/
|
|
26
|
+
export const getComputedElementWidth = (element) => {
|
|
27
|
+
const elementRect = element.getBoundingClientRect();
|
|
28
|
+
const elementComputedStyle = window.getComputedStyle(element);
|
|
29
|
+
const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);
|
|
30
|
+
const elementMarginRight = parseFloat(elementComputedStyle.marginRight);
|
|
31
|
+
return elementRect.width + elementMarginLeft + elementMarginRight;
|
|
32
|
+
};
|
|
33
|
+
export const getItemCountThatFitsRow = (itemWidths, availableWidth, { keepOversizedFirstItem = true } = {}) => {
|
|
34
|
+
let rowWidth = 0;
|
|
35
|
+
let count = 0;
|
|
36
|
+
for (const itemWidth of itemWidths) {
|
|
37
|
+
if (count === 0 && itemWidth > availableWidth) {
|
|
38
|
+
return keepOversizedFirstItem ? 1 : 0;
|
|
39
|
+
}
|
|
40
|
+
if (rowWidth + itemWidth > availableWidth) {
|
|
41
|
+
return count;
|
|
42
|
+
}
|
|
43
|
+
rowWidth += itemWidth;
|
|
44
|
+
count += 1;
|
|
45
|
+
}
|
|
46
|
+
return count;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Calculates how many legend items fit in the two-row collapsed layout.
|
|
50
|
+
*
|
|
51
|
+
* The second row reserves space for the "View more" action so that control
|
|
52
|
+
* remains visible at the end of the collapsed legend.
|
|
53
|
+
*/
|
|
54
|
+
export const getCollapsedVisibleItemCount = (itemWidths, availableRowWidth, viewMoreButtonWidth) => {
|
|
55
|
+
const firstRowItemCount = getItemCountThatFitsRow(itemWidths, availableRowWidth);
|
|
56
|
+
const secondRowItemCount = getItemCountThatFitsRow(itemWidths.slice(firstRowItemCount), availableRowWidth - viewMoreButtonWidth, { keepOversizedFirstItem: false });
|
|
57
|
+
return firstRowItemCount + secondRowItemCount;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=legend-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend-layout.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAA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iBAAiB,CAClB,CAAC;IACF,MAAM,kBAAkB,GAAG,uBAAuB,CAChD,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,EACnC,iBAAiB,GAAG,mBAAmB,EACvC,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAClC,CAAC;IAEF,OAAO,iBAAiB,GAAG,kBAAkB,CAAC;AAChD,CAAC,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\nexport const COLLAPSED_LEGEND_ROWS = 2;\nexport const COLLAPSED_LEGEND_MAX_HEIGHT = 64;\n\n/**\n * Get the computed element width, including both paddings and margins\n */\nexport const getComputedElementWidth = (element: Element) => {\n const elementRect = element.getBoundingClientRect();\n const elementComputedStyle = window.getComputedStyle(element);\n const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);\n const elementMarginRight = parseFloat(elementComputedStyle.marginRight);\n\n return elementRect.width + elementMarginLeft + elementMarginRight;\n};\n\nexport const getItemCountThatFitsRow = (\n itemWidths: number[],\n availableWidth: number,\n { keepOversizedFirstItem = true } = {},\n) => {\n let rowWidth = 0;\n let count = 0;\n\n for (const itemWidth of itemWidths) {\n if (count === 0 && itemWidth > availableWidth) {\n return keepOversizedFirstItem ? 1 : 0;\n }\n\n if (rowWidth + itemWidth > availableWidth) {\n return count;\n }\n\n rowWidth += itemWidth;\n count += 1;\n }\n\n return count;\n};\n\n/**\n * Calculates how many legend items fit in the two-row collapsed layout.\n *\n * The second row reserves space for the \"View more\" action so that control\n * remains visible at the end of the collapsed legend.\n */\nexport const getCollapsedVisibleItemCount = (\n itemWidths: number[],\n availableRowWidth: number,\n viewMoreButtonWidth: number,\n) => {\n const firstRowItemCount = getItemCountThatFitsRow(\n itemWidths,\n availableRowWidth,\n );\n const secondRowItemCount = getItemCountThatFitsRow(\n itemWidths.slice(firstRowItemCount),\n availableRowWidth - viewMoreButtonWidth,\n { keepOversizedFirstItem: false },\n );\n\n return firstRowItemCount + secondRowItemCount;\n};\n"]}
|
|
@@ -19,79 +19,6 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { getInstanceByDom, } from 'echarts';
|
|
22
|
-
import { useCallback } from 'react';
|
|
23
|
-
const useLegendVisibility = (chartRef, selectedSeries) => {
|
|
24
|
-
const setOnlyVisible = useCallback((name) => {
|
|
25
|
-
if (chartRef.current === null) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const chart = getInstanceByDom(chartRef.current);
|
|
29
|
-
chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
|
|
30
|
-
name: name,
|
|
31
|
-
type: 'legendSelect',
|
|
32
|
-
});
|
|
33
|
-
const otherNames = Object.keys(selectedSeries).filter((n) => n !== name);
|
|
34
|
-
otherNames.forEach((name) => {
|
|
35
|
-
if (name.startsWith('thresholdLine')) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
|
|
39
|
-
name: name,
|
|
40
|
-
type: 'legendUnSelect',
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}, [chartRef, selectedSeries]);
|
|
44
|
-
const setAllVisible = useCallback(() => {
|
|
45
|
-
if (chartRef.current === null) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const chart = getInstanceByDom(chartRef.current);
|
|
49
|
-
chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
|
|
50
|
-
type: 'legendAllSelect',
|
|
51
|
-
});
|
|
52
|
-
}, [chartRef]);
|
|
53
|
-
/**
|
|
54
|
-
* Toggle the visibility of a legend series
|
|
55
|
-
*
|
|
56
|
-
* The toggle logic depends on the current state of the series:
|
|
57
|
-
* - If only the legend series that was selected is visible: show all series
|
|
58
|
-
* - If all series are visible: hide all except the series that was selected
|
|
59
|
-
* - Otherwise: toggle the legend series
|
|
60
|
-
*
|
|
61
|
-
* The isOnlyVisible and isAllSeriesSelected states can't be calculated in this
|
|
62
|
-
* function since different legend types require different logic.
|
|
63
|
-
*/
|
|
64
|
-
const toggleLegendVisibility = useCallback((name, isAllSeriesSelected, isOnlyVisible) => {
|
|
65
|
-
if (chartRef.current === null || name === undefined) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (isOnlyVisible) {
|
|
69
|
-
setAllVisible();
|
|
70
|
-
}
|
|
71
|
-
else if (isAllSeriesSelected) {
|
|
72
|
-
setOnlyVisible(name);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
const chart = getInstanceByDom(chartRef.current);
|
|
76
|
-
chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
|
|
77
|
-
name: name,
|
|
78
|
-
type: 'legendToggleSelect',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}, [chartRef, setOnlyVisible, setAllVisible]);
|
|
82
|
-
return { setAllVisible, setOnlyVisible, toggleLegendVisibility };
|
|
83
|
-
};
|
|
84
|
-
const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
|
|
85
|
-
/**
|
|
86
|
-
* Get the computed element width, including both paddings and margins
|
|
87
|
-
*/
|
|
88
|
-
const getComputedElementWidth = (element) => {
|
|
89
|
-
const elementRect = element.getBoundingClientRect();
|
|
90
|
-
const elementComputedStyle = window.getComputedStyle(element);
|
|
91
|
-
const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);
|
|
92
|
-
const elementMarginRight = parseFloat(elementComputedStyle.marginRight);
|
|
93
|
-
return elementRect.width + elementMarginLeft + elementMarginRight;
|
|
94
|
-
};
|
|
95
22
|
export const resetAllSeriesHighlight = (chart) => {
|
|
96
23
|
const option = chart.getOption();
|
|
97
24
|
const seriesList = option.series || [];
|
|
@@ -139,7 +66,6 @@ const highlightOrDownplayPieSlices = (chart, currentSeriesToDispatch, action, cu
|
|
|
139
66
|
label: {
|
|
140
67
|
opacity: isDownplay ? 1 : 0.3,
|
|
141
68
|
},
|
|
142
|
-
// ...(seriesItem.blur as Record<string, unknown>),
|
|
143
69
|
} }))),
|
|
144
70
|
});
|
|
145
71
|
// The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series
|
|
@@ -196,5 +122,5 @@ const highlightOrDownplaySeries = (chartRef, series, currentSelectedSeries, curr
|
|
|
196
122
|
highlightOrDownplayLineAndBarSeries(chart, currentSeriesToDispatch, action, currentChartOptions);
|
|
197
123
|
}
|
|
198
124
|
};
|
|
199
|
-
export {
|
|
125
|
+
export { highlightOrDownplaySeries };
|
|
200
126
|
//# sourceMappingURL=legend-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAmB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW;YACX,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,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gB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAE9C,MAAM,UAAU,GAAG,MAAA,MACjB,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MACtB,0CAAG,CAAC,CAAC,0CAAE,IAAI,CAAC;IAEb,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QACzB,4BAA4B,CAC1B,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,mCAAmC,CACjC,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,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 {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n }),\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n dataIndex: otherSeriesIndexes,\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n dataIndex: currentDataSeriesIndexes,\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
import { defaultThresholdLineSeriesOption } from './defaults';
|
|
22
|
+
export const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
|
|
23
|
+
export const getThresholdLineDisplayName = (name) => name.replace('thresholdLine-', '');
|
|
24
|
+
/**
|
|
25
|
+
* Extracts threshold-line series and resolves defaults needed by tooltips.
|
|
26
|
+
*/
|
|
27
|
+
export function normalizeThresholdLines(propsSeries) {
|
|
28
|
+
const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];
|
|
29
|
+
const thresholdLineSeries = seriesArray.filter((currentSeries) => {
|
|
30
|
+
return currentSeries.type === 'thresholdLine';
|
|
31
|
+
});
|
|
32
|
+
return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return Object.assign(Object.assign({}, currentThresholdLineSeriesOption), { condition: (_a = currentThresholdLineSeriesOption.condition) !== null && _a !== void 0 ? _a : defaultThresholdLineSeriesOption.condition, value: currentThresholdLineSeriesOption.yAxis });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Evaluates a threshold condition and returns the short label used by
|
|
39
|
+
* chart tooltip notifications.
|
|
40
|
+
*/
|
|
41
|
+
export function evaluateThresholdCondition(value, condition, threshold) {
|
|
42
|
+
switch (condition) {
|
|
43
|
+
case 'greater':
|
|
44
|
+
return {
|
|
45
|
+
conditionText: 'Above',
|
|
46
|
+
isConditionMet: value > threshold,
|
|
47
|
+
};
|
|
48
|
+
case 'greaterOrEqual':
|
|
49
|
+
return {
|
|
50
|
+
conditionText: value > threshold
|
|
51
|
+
? 'Above'
|
|
52
|
+
: value === threshold
|
|
53
|
+
? 'Equal'
|
|
54
|
+
: undefined,
|
|
55
|
+
isConditionMet: value >= threshold,
|
|
56
|
+
};
|
|
57
|
+
case 'less':
|
|
58
|
+
return {
|
|
59
|
+
conditionText: 'Below',
|
|
60
|
+
isConditionMet: value < threshold,
|
|
61
|
+
};
|
|
62
|
+
case 'lessOrEqual':
|
|
63
|
+
return {
|
|
64
|
+
conditionText: value < threshold
|
|
65
|
+
? 'Below'
|
|
66
|
+
: value === threshold
|
|
67
|
+
? 'Equal'
|
|
68
|
+
: undefined,
|
|
69
|
+
isConditionMet: value <= threshold,
|
|
70
|
+
};
|
|
71
|
+
case 'equal':
|
|
72
|
+
return {
|
|
73
|
+
conditionText: 'Equal',
|
|
74
|
+
isConditionMet: value === threshold,
|
|
75
|
+
};
|
|
76
|
+
case 'notEqual':
|
|
77
|
+
return {
|
|
78
|
+
conditionText: 'Not equal',
|
|
79
|
+
isConditionMet: value !== threshold,
|
|
80
|
+
};
|
|
81
|
+
default:
|
|
82
|
+
return { conditionText: undefined, isConditionMet: false };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns the longer condition phrase used in chart aria descriptions.
|
|
87
|
+
*/
|
|
88
|
+
export function thresholdConditionToText(condition) {
|
|
89
|
+
switch (condition) {
|
|
90
|
+
case 'greater':
|
|
91
|
+
return 'greater than';
|
|
92
|
+
case 'greaterOrEqual':
|
|
93
|
+
return 'greater than or equal to';
|
|
94
|
+
case 'less':
|
|
95
|
+
return 'less than';
|
|
96
|
+
case 'lessOrEqual':
|
|
97
|
+
return 'less than or equal to';
|
|
98
|
+
case 'equal':
|
|
99
|
+
return 'equal to';
|
|
100
|
+
case 'notEqual':
|
|
101
|
+
return 'not equal to';
|
|
102
|
+
default:
|
|
103
|
+
return 'compared to';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=threshold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threshold.js","sourceRoot":"","sources":["../../../../src/charts/utils/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAe9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAE,EAAE,CAC/C,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,eAAe,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAY,EAAE,EAAE,CAC1D,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAyB;IAEzB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAE7E,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE;QAC/D,OAAO,aAAa,CAAC,IAAI,KAAK,eAAe,CAAC;IAChD,CAAC,CAAkD,CAAC;IAEpD,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,gCAAgC,EAAE,EAAE;;QAClE,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,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAoB;IAC3D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC;QACxB,KAAK,gBAAgB;YACnB,OAAO,0BAA0B,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,WAAW,CAAC;QACrB,KAAK,aAAa;YAChB,OAAO,uBAAuB,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,UAAU,CAAC;QACpB,KAAK,UAAU;YACb,OAAO,cAAc,CAAC;QACxB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,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 {\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"]}
|
|
@@ -21,9 +21,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
21
21
|
*/
|
|
22
22
|
import { tokens } from '@neo4j-ndl/base';
|
|
23
23
|
import { renderToString } from 'react-dom/server';
|
|
24
|
-
import { ChartTooltip } from '
|
|
24
|
+
import { ChartTooltip } from '../ChartTooltip';
|
|
25
|
+
import { getTooltipValueFormatter } from './chart-tooltip-formatter';
|
|
25
26
|
import { defaultThresholdLineSeriesOption } from './defaults';
|
|
26
|
-
import { formatNumberEnUS } from './utils';
|
|
27
|
+
import { formatNumberEnUS } from './format-utils';
|
|
27
28
|
const defaultColors = Object.values(tokens.categorical);
|
|
28
29
|
export const mergeSeries = (series, theme = 'light', userOption, palette) => {
|
|
29
30
|
const colors = palette !== null && palette !== void 0 ? palette : defaultColors;
|
|
@@ -51,6 +52,7 @@ export const mergeSeries = (series, theme = 'light', userOption, palette) => {
|
|
|
51
52
|
return Object.assign(Object.assign({ type: 'line', symbolSize: 9, color, symbol: 'none' }, option), { lineStyle: Object.assign({ width: 2, type: 'solid' }, option.lineStyle), emphasis: Object.assign(Object.assign(Object.assign({ disabled: true, focus: 'series' }, option.emphasis), { itemStyle: Object.assign({ borderColor: tokens.theme[theme].color.neutral.bg.weak, shadowOffsetX: parseInt(shadowParts[0]), shadowOffsetY: parseInt(shadowParts[1]), shadowBlur: parseInt(shadowParts[2]), shadowColor: shadowParts[4] }, (_b = option.emphasis) === null || _b === void 0 ? void 0 : _b.itemStyle), label: { show: false } }), option.emphasis) });
|
|
52
53
|
}
|
|
53
54
|
if (option.type === 'pie') {
|
|
55
|
+
const valueFormatter = getTooltipValueFormatter(userOption);
|
|
54
56
|
return Object.assign(Object.assign({ animationDuration: 600, animationType: 'scale', selectedMode: 'single' }, option), {
|
|
55
57
|
// Blur opacity is set to 1 to prevent other slices from
|
|
56
58
|
// being opacitated when hovering a slice where the emphasis is enabled (used for scale effect)
|
|
@@ -62,18 +64,13 @@ export const mergeSeries = (series, theme = 'light', userOption, palette) => {
|
|
|
62
64
|
var _a, _b;
|
|
63
65
|
const paramsArray = Array.isArray(params) ? params : [params];
|
|
64
66
|
const firstParam = paramsArray[0];
|
|
65
|
-
let valueFormatter = formatNumberEnUS;
|
|
66
|
-
if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
|
|
67
|
-
userOption.tooltip !== null &&
|
|
68
|
-
'valueFormatter' in userOption.tooltip) {
|
|
69
|
-
valueFormatter = userOption.tooltip.valueFormatter;
|
|
70
|
-
}
|
|
71
67
|
return `${renderToString(_jsx("span", { className: "ndl-charts-chart-tooltip", children: _jsx(ChartTooltip.Content, { leadingElement: (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName, trailingElement: valueFormatter(Array.isArray(firstParam.value)
|
|
72
68
|
? firstParam.value[1]
|
|
73
69
|
: firstParam.value), indentSquareColor: firstParam.color }, (_b = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _b !== void 0 ? _b : firstParam.seriesName) }))}`;
|
|
74
70
|
} }, option.tooltip) });
|
|
75
71
|
}
|
|
76
72
|
if (option.type === 'bar') {
|
|
73
|
+
const valueFormatter = getTooltipValueFormatter(userOption);
|
|
77
74
|
return Object.assign(Object.assign({ barMaxWidth: 16 }, option), { blur: Object.assign({ itemStyle: Object.assign({ opacity: 0.3 }, (_e = option.blur) === null || _e === void 0 ? void 0 : _e.itemStyle) }, option.blur), emphasis: Object.assign({ disabled: true, focus: 'series' }, option.emphasis), itemStyle: Object.assign({ color, borderWidth: 20 }, option.itemStyle), markLine: {
|
|
78
75
|
emphasis: Object.assign({ disabled: true, lineStyle: Object.assign({ width: 20 }, (_g = (_f = option.markLine) === null || _f === void 0 ? void 0 : _f.emphasis) === null || _g === void 0 ? void 0 : _g.lineStyle) }, (_h = option.markLine) === null || _h === void 0 ? void 0 : _h.emphasis),
|
|
79
76
|
lineStyle: Object.assign({ width: 20 }, (_j = option.markLine) === null || _j === void 0 ? void 0 : _j.lineStyle),
|
|
@@ -83,12 +80,6 @@ export const mergeSeries = (series, theme = 'light', userOption, palette) => {
|
|
|
83
80
|
var _a;
|
|
84
81
|
const paramsArray = Array.isArray(params) ? params : [params];
|
|
85
82
|
const firstParam = paramsArray[0];
|
|
86
|
-
let valueFormatter = formatNumberEnUS;
|
|
87
|
-
if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
|
|
88
|
-
userOption.tooltip !== null &&
|
|
89
|
-
'valueFormatter' in userOption.tooltip) {
|
|
90
|
-
valueFormatter = userOption.tooltip.valueFormatter;
|
|
91
|
-
}
|
|
92
83
|
return `${renderToString(_jsxs("span", { className: "ndl-charts-chart-tooltip", children: [_jsx(ChartTooltip.Title, { children: firstParam.name }), _jsx(ChartTooltip.Content, { leadingElement: firstParam.seriesName, trailingElement: valueFormatter(Array.isArray(firstParam.value)
|
|
93
84
|
? firstParam.value[1]
|
|
94
85
|
: firstParam.value), indentSquareColor: firstParam.color }, (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName)] }))}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-option-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/user-option-utils.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAOrE,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAWxD,MAAM,CAAC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,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC5B,YAAY,CAAC,MAAM,CAAC,CACO,CAAC;IAChC,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,QAAQ,gCACN,UAAU,EAAE,KAAK,IACd,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,0CAAE,QAAQ,KAC7B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE;oBACJ,+BAA+B;oBAC/B,yDAAyD;oBACzD,IAAI,EAAE,GAAG;oBACT,IAAI,EAAE,GAAG;iBACV,GACF;SACF;KACF,CAAC;AACJ,CAAC,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 { tokens } from '@neo4j-ndl/base';\nimport { type EChartsOption, type SeriesOption } from 'echarts';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip } from '../ChartTooltip';\nimport { getTooltipValueFormatter } from './chart-tooltip-formatter';\nimport {\n type EchartsSeries,\n type HexColor,\n type NeedleSeries,\n type ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\nimport { formatNumberEnUS } from './format-utils';\n\nconst defaultColors = Object.values(tokens.categorical);\n\ntype SingleXAxisOption = Exclude<\n NonNullable<EChartsOption['xAxis']>,\n unknown[]\n>;\ntype SingleYAxisOption = Exclude<\n NonNullable<EChartsOption['yAxis']>,\n unknown[]\n>;\n\nexport const mergeSeries = (\n series: NeedleSeries,\n theme: 'light' | 'dark' = 'light',\n userOption?: Omit<\n EChartsOption,\n 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'\n >,\n palette?: HexColor[],\n): EchartsSeries => {\n const colors = palette ?? defaultColors;\n\n return series.map(\n (\n option:\n | SeriesOption\n | ThresholdLineSeriesOption<'warning'>\n | ThresholdLineSeriesOption<'danger'>,\n index: number = 0,\n ): SeriesOption => {\n if (option === undefined) {\n return {};\n }\n\n const color = Array.isArray(option.color)\n ? option.color[index]\n : (option.color ?? colors[index % colors.length]);\n\n if (option.type === 'thresholdLine') {\n const { notificationType } = option;\n // Needed to differentiate between normal lines and threshold lines\n // as we are unable to inject custom properties into echarts series lines.\n const thresholdLineName = `thresholdLine-${notificationType}`;\n return {\n symbolSize: 9,\n symbol: 'none',\n condition: defaultThresholdLineSeriesOption.condition,\n ...option,\n lineStyle: {\n width: 2,\n type: 'dashed',\n ...option.lineStyle,\n },\n name: thresholdLineName,\n type: 'line',\n data: [\n [option.xAxis[0], option.yAxis],\n [option.xAxis[1], option.yAxis],\n ],\n };\n }\n\n if (option.type === 'line') {\n const shadow = tokens.theme[theme].boxShadow.raised;\n const shadowParts = shadow.split(/ (?=\\d+px|rgba?\\()/);\n\n return {\n type: 'line',\n symbolSize: 9,\n color,\n symbol: 'none',\n ...option,\n lineStyle: {\n width: 2,\n type: 'solid' as const,\n ...option.lineStyle,\n },\n emphasis: {\n disabled: true,\n focus: 'series',\n ...option.emphasis,\n itemStyle: {\n borderColor: tokens.theme[theme].color.neutral.bg.weak,\n shadowOffsetX: parseInt(shadowParts[0]),\n shadowOffsetY: parseInt(shadowParts[1]),\n shadowBlur: parseInt(shadowParts[2]),\n shadowColor: shadowParts[4],\n ...option.emphasis?.itemStyle,\n },\n label: { show: false },\n ...option.emphasis,\n },\n };\n }\n\n if (option.type === 'pie') {\n const valueFormatter = getTooltipValueFormatter(userOption);\n\n return {\n animationDuration: 600,\n animationType: 'scale',\n selectedMode: 'single',\n ...option,\n // Blur opacity is set to 1 to prevent other slices from\n // being opacitated when hovering a slice where the emphasis is enabled (used for scale effect)\n blur: {\n itemStyle: {\n opacity: 1,\n ...option.blur?.itemStyle,\n },\n label: {\n opacity: 1,\n ...option.blur?.label,\n },\n ...option.blur,\n },\n // Emphasis is enabled and used to apply the scale effect when hovering the pie chart slices.\n emphasis: {\n disabled: false,\n focus: 'self',\n scale: true,\n scaleSize: 5,\n ...option.emphasis,\n },\n itemStyle: {\n borderColor: tokens.theme[theme].color.neutral.bg.weak,\n borderWidth: 1,\n ...option.itemStyle,\n },\n label: {\n formatter: '{d}%',\n backgroundColor: 'transparent',\n color: tokens.theme[theme].color.neutral.text.weak,\n ...option.label,\n },\n labelLine: {\n length: 5,\n show: true,\n ...option.labelLine,\n },\n tooltip: {\n trigger: 'item',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Content\n key={firstParam?.value[0] ?? firstParam.seriesName}\n leadingElement={\n firstParam?.value[0] ?? firstParam.seriesName\n }\n trailingElement={valueFormatter(\n Array.isArray(firstParam.value)\n ? firstParam.value[1]\n : firstParam.value,\n )}\n indentSquareColor={firstParam.color}\n />\n </span>,\n )}`;\n },\n ...option.tooltip,\n },\n };\n }\n\n if (option.type === 'bar') {\n const valueFormatter = getTooltipValueFormatter(userOption);\n\n return {\n barMaxWidth: 16,\n ...option,\n blur: {\n itemStyle: {\n opacity: 0.3,\n ...option.blur?.itemStyle,\n },\n ...option.blur,\n },\n emphasis: {\n disabled: true,\n focus: 'series',\n ...option.emphasis,\n },\n itemStyle: {\n color,\n borderWidth: 20,\n ...option.itemStyle,\n },\n markLine: {\n emphasis: {\n disabled: true,\n lineStyle: {\n width: 20,\n ...option.markLine?.emphasis?.lineStyle,\n },\n ...option.markLine?.emphasis,\n },\n lineStyle: {\n width: 20,\n ...option.markLine?.lineStyle,\n },\n },\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>{firstParam.name}</ChartTooltip.Title>\n <ChartTooltip.Content\n key={firstParam?.value[0] ?? firstParam.seriesName}\n leadingElement={firstParam.seriesName}\n trailingElement={valueFormatter(\n Array.isArray(firstParam.value)\n ? firstParam.value[1]\n : firstParam.value,\n )}\n indentSquareColor={firstParam.color}\n />\n </span>,\n )}`;\n },\n ...option.tooltip,\n },\n };\n }\n\n return option;\n },\n );\n};\n\nexport const mergeXAxis = (\n xAxis: EChartsOption['xAxis'],\n theme: 'light' | 'dark' = 'light',\n): EChartsOption['xAxis'] => {\n if (xAxis === undefined) {\n return [];\n }\n\n if (Array.isArray(xAxis)) {\n return xAxis.map((x) => mergeXAxis(x, theme)) as EChartsOption['xAxis'];\n }\n\n const baseXAxis = {\n ...xAxis,\n splitLine: { show: false, ...xAxis?.splitLine },\n axisLine: {\n lineStyle: {\n ...xAxis?.axisLine?.lineStyle,\n },\n ...xAxis?.axisLine,\n },\n axisTick: {\n ...xAxis?.axisTick,\n lineStyle: {\n ...xAxis?.axisTick?.lineStyle,\n },\n show: true,\n ...xAxis?.axisTick,\n },\n axisLabel: {\n margin: 16,\n formatter: {\n day: '{dd} {MMM}',\n hour: '{HH}:{mm}',\n millisecond: '{hh}:{mm}:{ss} {SSS}',\n minute: '{HH}:{mm}',\n month: '{MMM}',\n none: '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}',\n second: '{HH}:{mm}:{ss}',\n year: '{yearStyle|{yyyy}}\\n{monthStyle|{MMM}}',\n },\n overflow: 'truncate',\n ...xAxis?.axisLabel,\n },\n } as SingleXAxisOption;\n\n if (xAxis.type === 'time') {\n const timeXAxis = {\n ...baseXAxis,\n axisLabel: {\n hideOverlap: true,\n ...baseXAxis.axisLabel,\n },\n } as SingleXAxisOption;\n\n return timeXAxis;\n }\n\n if (xAxis.type === 'value' || xAxis.type === 'log') {\n const xAxisFormatter =\n xAxis.axisLabel && 'formatter' in xAxis.axisLabel\n ? xAxis.axisLabel.formatter\n : undefined;\n const valueXAxis = {\n ...baseXAxis,\n axisLabel: {\n ...baseXAxis.axisLabel,\n formatter: xAxisFormatter ?? formatNumberEnUS,\n },\n } as SingleXAxisOption;\n\n return valueXAxis;\n }\n\n if (xAxis.type === 'category') {\n const categoryXAxis = {\n ...baseXAxis,\n axisTick: {\n alignWithLabel: true,\n ...baseXAxis?.axisTick,\n },\n axisLabel: {\n width: 80,\n ...baseXAxis?.axisLabel,\n },\n } as SingleXAxisOption;\n return categoryXAxis;\n }\n\n return baseXAxis;\n};\n\nexport const mergeYAxis = (\n yAxis: EChartsOption['yAxis'],\n theme: 'light' | 'dark' = 'light',\n): EChartsOption['yAxis'] => {\n if (yAxis === undefined) {\n return [];\n }\n\n if (Array.isArray(yAxis)) {\n return yAxis.map((y) => mergeYAxis(y, theme)) as EChartsOption['yAxis'];\n }\n\n const baseYAxis = {\n ...yAxis,\n axisLine: {\n ...yAxis?.axisLine,\n lineStyle: {\n ...yAxis?.axisLine?.lineStyle,\n },\n show: true,\n },\n axisTick: {\n show: false,\n ...yAxis?.axisTick,\n lineStyle: {\n width: 1,\n ...yAxis?.axisTick?.lineStyle,\n },\n },\n axisLabel: {\n margin: 8,\n overflow: 'truncate',\n ...yAxis?.axisLabel,\n },\n splitLine: { show: true, ...yAxis?.splitLine },\n } as SingleYAxisOption;\n\n if (yAxis.type === 'time') {\n const timeYAxis = {\n ...baseYAxis,\n axisLabel: {\n hideOverlap: true,\n ...baseYAxis.axisLabel,\n },\n splitLine: { show: false, ...baseYAxis?.splitLine },\n } as SingleYAxisOption;\n\n return timeYAxis;\n }\n\n if (yAxis.type === 'value' || yAxis.type === 'log') {\n const yAxisFormatter =\n yAxis.axisLabel && 'formatter' in yAxis.axisLabel\n ? yAxis.axisLabel.formatter\n : undefined;\n const valueYAxis = {\n ...baseYAxis,\n axisLabel: {\n hideOverlap: true,\n ...baseYAxis.axisLabel,\n formatter: yAxisFormatter ?? formatNumberEnUS,\n },\n splitLine: { show: false, ...baseYAxis?.splitLine },\n } as SingleYAxisOption;\n\n return valueYAxis;\n }\n\n if (yAxis.type === 'category') {\n const categoryYAxis = {\n ...baseYAxis,\n axisLabel: {\n width: 100,\n ...baseYAxis?.axisLabel,\n },\n } as SingleYAxisOption;\n\n return categoryYAxis;\n }\n\n return baseYAxis;\n};\n\nexport const mergeDataZoom = (\n dataZoom: EChartsOption['dataZoom'],\n): EChartsOption['dataZoom'] => {\n if (Array.isArray(dataZoom)) {\n return dataZoom.map((option) =>\n mergeDataZoom(option),\n ) as EChartsOption['dataZoom'];\n }\n\n const isSlider = dataZoom?.type === 'slider';\n const isInside = dataZoom?.type === 'inside';\n\n if (isSlider) {\n return {\n bottom: 10,\n height: 28,\n left: 50,\n right: 50,\n show: true,\n type: 'slider',\n ...dataZoom,\n };\n } else if (isInside) {\n return {\n filterMode: 'none',\n xAxisIndex: [0],\n zoomOnMouseWheel: false,\n ...dataZoom,\n };\n }\n\n return dataZoom;\n};\n\nexport const mergeToolbox = (\n toolbox: EChartsOption['toolbox'],\n): EChartsOption['toolbox'] => {\n if (Array.isArray(toolbox)) {\n return toolbox.map((option) =>\n mergeToolbox(option),\n ) as EChartsOption['toolbox'];\n }\n\n return {\n feature: {\n dataZoom: {\n yAxisIndex: false,\n ...toolbox?.feature?.dataZoom,\n show: true,\n icon: {\n // This hack removes the icons.\n // Due to: https://github.com/apache/echarts/issues/10274\n back: '-',\n zoom: '-',\n },\n },\n },\n };\n};\n"]}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* You should have received a copy of the GNU General Public License
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
import { type ChartProps } from './chart-types';
|
|
21
|
+
import { type ChartProps } from './utils/chart-types';
|
|
22
22
|
/**
|
|
23
23
|
* A chart component powered by Apache ECharts with Needle's customization and theming.
|
|
24
24
|
*
|
|
@@ -33,5 +33,5 @@ import { type ChartProps } from './chart-types';
|
|
|
33
33
|
* </div>
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export declare
|
|
36
|
+
export declare const Chart: ({ style, legend, ...chartProps }: ChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
//# sourceMappingURL=Chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA8CtD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,GAAI,kCAAkC,UAAU,4CAyCjE,CAAC"}
|