@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,52 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
let react = require("react");
|
|
7
|
+
// src/charts/hooks/use-chart-refs.ts
|
|
2
8
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.ChartRefsProvider = ChartRefsProvider;
|
|
24
|
-
exports.useChartRefsContext = useChartRefsContext;
|
|
25
|
-
const react_1 = require("react");
|
|
26
|
-
const ChartRefsContext = (0, react_1.createContext)(undefined);
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) "Neo4j"
|
|
11
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
12
|
+
*
|
|
13
|
+
* This file is part of Neo4j.
|
|
14
|
+
*
|
|
15
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
16
|
+
* it under the terms of the GNU General Public License as published by
|
|
17
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
18
|
+
* (at your option) any later version.
|
|
19
|
+
*
|
|
20
|
+
* This program is distributed in the hope that it will be useful,
|
|
21
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
* GNU General Public License for more details.
|
|
24
|
+
*
|
|
25
|
+
* You should have received a copy of the GNU General Public License
|
|
26
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
27
|
+
*/
|
|
28
|
+
const ChartRefsContext = (0, react.createContext)(void 0);
|
|
27
29
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
* Creates the mutable refs shared between `ChartRender` and legend components.
|
|
31
|
+
*
|
|
32
|
+
* `chartEchartRef` points at the ECharts host element, while the legend refs act
|
|
33
|
+
* as a bridge for state that ECharts needs synchronously during option rebuilds
|
|
34
|
+
* without forcing extra React renders.
|
|
35
|
+
*/
|
|
34
36
|
function ChartRefsProvider({ children }) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const chartEchartRef = (0, react.useRef)(null);
|
|
38
|
+
const legendSelectedRef = (0, react.useRef)({});
|
|
39
|
+
const legendColorCacheRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
40
|
+
const refs = (0, react.useMemo)(() => ({
|
|
41
|
+
chartEchartRef,
|
|
42
|
+
legendColorCacheRef,
|
|
43
|
+
legendSelectedRef
|
|
44
|
+
}), []);
|
|
45
|
+
return (0, react.createElement)(ChartRefsContext.Provider, { value: refs }, children);
|
|
44
46
|
}
|
|
45
47
|
function useChartRefsContext() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return refs;
|
|
48
|
+
const refs = (0, react.useContext)(ChartRefsContext);
|
|
49
|
+
if (refs === void 0) throw new Error("useChartRefsContext must be used within ChartRefsProvider");
|
|
50
|
+
return refs;
|
|
51
51
|
}
|
|
52
|
+
exports.ChartRefsProvider = ChartRefsProvider;
|
|
53
|
+
exports.useChartRefsContext = useChartRefsContext;
|
|
54
|
+
|
|
52
55
|
//# sourceMappingURL=use-chart-refs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chart-refs.js","
|
|
1
|
+
{"version":3,"file":"use-chart-refs.js","names":["createContext","useRef","useMemo","createElement","useContext"],"sources":["../../../../src/charts/hooks/use-chart-refs.ts"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n createContext,\n createElement,\n type ReactNode,\n useContext,\n useMemo,\n useRef,\n} from 'react';\n\nexport type ChartRefs = {\n chartEchartRef: React.RefObject<HTMLDivElement | null>;\n legendColorCacheRef: React.RefObject<Map<string, string>>;\n legendSelectedRef: React.RefObject<Record<string, boolean>>;\n};\n\nconst ChartRefsContext = createContext<ChartRefs | undefined>(undefined);\n\n/**\n * Creates the mutable refs shared between `ChartRender` and legend components.\n *\n * `chartEchartRef` points at the ECharts host element, while the legend refs act\n * as a bridge for state that ECharts needs synchronously during option rebuilds\n * without forcing extra React renders.\n */\nexport function ChartRefsProvider({ children }: { children: ReactNode }) {\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const legendSelectedRef = useRef<Record<string, boolean>>({});\n const legendColorCacheRef = useRef<Map<string, string>>(new Map());\n const refs = useMemo(\n () => ({\n chartEchartRef,\n legendColorCacheRef,\n legendSelectedRef,\n }),\n [],\n );\n\n return createElement(ChartRefsContext.Provider, { value: refs }, children);\n}\n\nexport function useChartRefsContext() {\n const refs = useContext(ChartRefsContext);\n if (refs === undefined) {\n throw new Error(\n 'useChartRefsContext must be used within ChartRefsProvider',\n );\n }\n\n return refs;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,oBAAA,GAAmBA,MAAAA,cAAAA,CAAqC,KAAA,CAAS;;;;;;;;AASvE,SAAgB,kBAAkB,EAAE,YAAqC;CACvE,MAAM,kBAAA,GAAiBC,MAAAA,OAAAA,CAAuB,IAAI;CAClD,MAAM,qBAAA,GAAoBA,MAAAA,OAAAA,CAAgC,CAAC,CAAC;CAC5D,MAAM,uBAAA,GAAsBA,MAAAA,OAAAA,iBAA4B,IAAI,IAAI,CAAC;CACjE,MAAM,QAAA,GAAOC,MAAAA,QAAAA,QACJ;EACL;EACA;EACA;CACF,IACA,CAAC,CACH;CAEA,QAAA,GAAOC,MAAAA,cAAAA,CAAc,iBAAiB,UAAU,EAAE,OAAO,KAAK,GAAG,QAAQ;AAC3E;AAEA,SAAgB,sBAAsB;CACpC,MAAM,QAAA,GAAOC,MAAAA,WAAAA,CAAW,gBAAgB;CACxC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MACR,2DACF;CAGF,OAAO;AACT"}
|
|
@@ -1,132 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
const require_charts_hooks_use_chart_refs = require("./use-chart-refs.js");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let echarts = require("echarts");
|
|
9
|
+
// src/charts/hooks/use-chart-zoom.ts
|
|
2
10
|
/*!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.useChartZoom = useChartZoom;
|
|
24
|
-
const echarts_1 = require("echarts");
|
|
25
|
-
const react_1 = require("react");
|
|
26
|
-
const use_chart_refs_1 = require("./use-chart-refs");
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) "Neo4j"
|
|
13
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
14
|
+
*
|
|
15
|
+
* This file is part of Neo4j.
|
|
16
|
+
*
|
|
17
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
18
|
+
* it under the terms of the GNU General Public License as published by
|
|
19
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
20
|
+
* (at your option) any later version.
|
|
21
|
+
*
|
|
22
|
+
* This program is distributed in the hope that it will be useful,
|
|
23
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25
|
+
* GNU General Public License for more details.
|
|
26
|
+
*
|
|
27
|
+
* You should have received a copy of the GNU General Public License
|
|
28
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
*/
|
|
27
30
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function useChartZoom({ callbacks, isChartZoomDisabled
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
type: 'dataZoom',
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
if (!isChartZoomDisabled) {
|
|
106
|
-
chart === null || chart === void 0 ? void 0 : chart.getZr().on('mousedown', handleMouseDown);
|
|
107
|
-
}
|
|
108
|
-
const chartRefCurrentElement = chartEchartRef.current;
|
|
109
|
-
const element = chartRefCurrentElement === null || chartRefCurrentElement === void 0 ? void 0 : chartRefCurrentElement.children[0];
|
|
110
|
-
return () => {
|
|
111
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('mousemove', handleMouseMove);
|
|
112
|
-
if (chartRefCurrentElement) {
|
|
113
|
-
const chart = (0, echarts_1.getInstanceByDom)(chartRefCurrentElement);
|
|
114
|
-
chart === null || chart === void 0 ? void 0 : chart.off('datazoom', handleDataZoom);
|
|
115
|
-
chart === null || chart === void 0 ? void 0 : chart.getZr().off('mousedown', handleMouseDown);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
if (chartEchartRef.current !== null && !isChartZoomDisabled) {
|
|
120
|
-
const chart = (0, echarts_1.getInstanceByDom)(chartEchartRef.current);
|
|
121
|
-
if (chart) {
|
|
122
|
-
// Needs to be re-set on every re-render. Sets the selectable zoom area
|
|
123
|
-
// over the chart body, not the slider.
|
|
124
|
-
chart.dispatchAction({
|
|
125
|
-
dataZoomSelectActive: true,
|
|
126
|
-
key: 'dataZoomSelect',
|
|
127
|
-
type: 'takeGlobalCursor',
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
31
|
+
* Owns ECharts zoom interactions and forwards zoom changes to consumers.
|
|
32
|
+
*
|
|
33
|
+
* The hook subscribes to ECharts `datazoom` events, enables drag-to-zoom through
|
|
34
|
+
* ECharts' global cursor API, resets zoom on double click, and clears ECharts'
|
|
35
|
+
* SVG cursor override after mouse movement so Needle's default cursor styling is
|
|
36
|
+
* preserved.
|
|
37
|
+
*
|
|
38
|
+
* The effect re-runs on every render, so each listener has to be detached again
|
|
39
|
+
* on cleanup. Otherwise they pile up and consumers get one `onZoom` call per
|
|
40
|
+
* render that has happened so far.
|
|
41
|
+
*/
|
|
42
|
+
function useChartZoom({ callbacks, isChartZoomDisabled }) {
|
|
43
|
+
const { chartEchartRef } = require_charts_hooks_use_chart_refs.useChartRefsContext();
|
|
44
|
+
(0, react.useEffect)(() => {
|
|
45
|
+
var _chartEchartRef$curre;
|
|
46
|
+
const chart = chartEchartRef.current === null ? void 0 : (0, echarts.getInstanceByDom)(chartEchartRef.current);
|
|
47
|
+
const handleDataZoom = () => {
|
|
48
|
+
var _chartOption$dataZoom, _callbacks$onZoom;
|
|
49
|
+
if (chartEchartRef.current === null) return;
|
|
50
|
+
const currentChart = (0, echarts.getInstanceByDom)(chartEchartRef.current);
|
|
51
|
+
if (!currentChart) return;
|
|
52
|
+
const dataZoom = ((_chartOption$dataZoom = currentChart.getOption().dataZoom) !== null && _chartOption$dataZoom !== void 0 ? _chartOption$dataZoom : []).filter((entry) => entry !== null).map(({ end, endValue, id, start, startValue, xAxisIndex, yAxisIndex }) => ({
|
|
53
|
+
endPercent: end,
|
|
54
|
+
endValue,
|
|
55
|
+
id,
|
|
56
|
+
startPercent: start,
|
|
57
|
+
startValue,
|
|
58
|
+
xAxisIndex,
|
|
59
|
+
yAxisIndex
|
|
60
|
+
}));
|
|
61
|
+
if (dataZoom.length === 0) return;
|
|
62
|
+
callbacks === null || callbacks === void 0 || (_callbacks$onZoom = callbacks.onZoom) === null || _callbacks$onZoom === void 0 || _callbacks$onZoom.call(callbacks, {
|
|
63
|
+
dataZoom,
|
|
64
|
+
endValue: dataZoom[0].endValue,
|
|
65
|
+
startValue: dataZoom[0].startValue
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
if (callbacks === null || callbacks === void 0 ? void 0 : callbacks.onZoom) chart === null || chart === void 0 || chart.on("datazoom", handleDataZoom);
|
|
69
|
+
const handleMouseMove = () => {
|
|
70
|
+
chart === null || chart === void 0 || chart.getZr().setCursorStyle("default");
|
|
71
|
+
};
|
|
72
|
+
const chartChild = (_chartEchartRef$curre = chartEchartRef.current) === null || _chartEchartRef$curre === void 0 ? void 0 : _chartEchartRef$curre.children[0];
|
|
73
|
+
if (!isChartZoomDisabled) chartChild === null || chartChild === void 0 || chartChild.addEventListener("mousemove", handleMouseMove);
|
|
74
|
+
const handleMouseDown = (params) => {
|
|
75
|
+
if (params.event.detail === 2) {
|
|
76
|
+
if (chart === void 0) return;
|
|
77
|
+
chart === null || chart === void 0 || chart.dispatchAction({
|
|
78
|
+
end: 100,
|
|
79
|
+
start: 0,
|
|
80
|
+
type: "dataZoom"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (!isChartZoomDisabled) chart === null || chart === void 0 || chart.getZr().on("mousedown", handleMouseDown);
|
|
85
|
+
const chartRefCurrentElement = chartEchartRef.current;
|
|
86
|
+
const element = chartRefCurrentElement === null || chartRefCurrentElement === void 0 ? void 0 : chartRefCurrentElement.children[0];
|
|
87
|
+
return () => {
|
|
88
|
+
element === null || element === void 0 || element.removeEventListener("mousemove", handleMouseMove);
|
|
89
|
+
if (chartRefCurrentElement) {
|
|
90
|
+
const chart = (0, echarts.getInstanceByDom)(chartRefCurrentElement);
|
|
91
|
+
chart === null || chart === void 0 || chart.off("datazoom", handleDataZoom);
|
|
92
|
+
chart === null || chart === void 0 || chart.getZr().off("mousedown", handleMouseDown);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
if (chartEchartRef.current !== null && !isChartZoomDisabled) {
|
|
97
|
+
const chart = (0, echarts.getInstanceByDom)(chartEchartRef.current);
|
|
98
|
+
if (chart) chart.dispatchAction({
|
|
99
|
+
dataZoomSelectActive: true,
|
|
100
|
+
key: "dataZoomSelect",
|
|
101
|
+
type: "takeGlobalCursor"
|
|
102
|
+
});
|
|
103
|
+
}
|
|
131
104
|
}
|
|
105
|
+
exports.useChartZoom = useChartZoom;
|
|
106
|
+
|
|
132
107
|
//# sourceMappingURL=use-chart-zoom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chart-zoom.js","
|
|
1
|
+
{"version":3,"file":"use-chart-zoom.js","names":["useChartRefsContext","getInstanceByDom"],"sources":["../../../../src/charts/hooks/use-chart-zoom.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 { getInstanceByDom } from 'echarts';\nimport { useEffect } from 'react';\n\nimport type { ChartProps, ChartZoomEntry } from '../utils/chart-types';\nimport { useChartRefsContext } from './use-chart-refs';\n\ntype UseChartZoomParams = {\n callbacks: ChartProps['callbacks'];\n isChartZoomDisabled: boolean;\n};\n\n// Besides the zoom fields, each entry carries every option ECharts merged in,\n// such as the slider styling from the theme.\ntype EchartsDataZoomEntry = Omit<\n ChartZoomEntry,\n 'startPercent' | 'endPercent'\n> & { start: number; end: number } & Record<string, unknown>;\n\n/**\n * Owns ECharts zoom interactions and forwards zoom changes to consumers.\n *\n * The hook subscribes to ECharts `datazoom` events, enables drag-to-zoom through\n * ECharts' global cursor API, resets zoom on double click, and clears ECharts'\n * SVG cursor override after mouse movement so Needle's default cursor styling is\n * preserved.\n *\n * The effect re-runs on every render, so each listener has to be detached again\n * on cleanup. Otherwise they pile up and consumers get one `onZoom` call per\n * render that has happened so far.\n */\nexport function useChartZoom({\n callbacks,\n isChartZoomDisabled,\n}: UseChartZoomParams) {\n const { chartEchartRef } = useChartRefsContext();\n\n useEffect(() => {\n const chart =\n chartEchartRef.current === null\n ? undefined\n : getInstanceByDom(chartEchartRef.current);\n\n const handleDataZoom = () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const chartOption = currentChart.getOption();\n const echartsDataZoom = (chartOption.dataZoom ??\n []) as (EchartsDataZoomEntry | null)[];\n const dataZoom: ChartZoomEntry[] = echartsDataZoom\n .filter((entry) => entry !== null)\n // map to trim unnecessary values, just keeping the relevant fields\n .map(\n ({\n end,\n endValue,\n id,\n start,\n startValue,\n xAxisIndex,\n yAxisIndex,\n }) => ({\n endPercent: end,\n endValue,\n id,\n startPercent: start,\n startValue,\n xAxisIndex,\n yAxisIndex,\n }),\n );\n if (dataZoom.length === 0) {\n return;\n }\n\n callbacks?.onZoom?.({\n dataZoom,\n endValue: dataZoom[0].endValue as number,\n startValue: dataZoom[0].startValue as number,\n });\n };\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', handleDataZoom);\n }\n\n const handleMouseMove = () => {\n // ECharts updates SVG cursor styles on mouse move, so Needle has to\n // reset it after ECharts' internal handler runs.\n chart?.getZr().setCursorStyle('default');\n };\n const chartChild = chartEchartRef.current?.children[0] as\n | HTMLElement\n | undefined;\n if (!isChartZoomDisabled) {\n chartChild?.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n end: 100,\n start: 0,\n type: 'dataZoom',\n });\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n element?.removeEventListener('mousemove', handleMouseMove);\n\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.off('datazoom', handleDataZoom);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render. Sets the selectable zoom area\n // over the chart body, not the slider.\n chart.dispatchAction({\n dataZoomSelectActive: true,\n key: 'dataZoomSelect',\n type: 'takeGlobalCursor',\n });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,aAAa,EAC3B,WACA,uBACqB;CACrB,MAAM,EAAE,mBAAmBA,oCAAAA,oBAAoB;CAE/C,CAAA,GAAA,MAAA,UAAA,OAAgB;;EACd,MAAM,QACJ,eAAe,YAAY,OACvB,KAAA,KAAA,GACAC,QAAAA,iBAAAA,CAAiB,eAAe,OAAO;EAE7C,MAAM,uBAAuB;;GAC3B,IAAI,eAAe,YAAY,MAC7B;GAGF,MAAM,gBAAA,GAAeA,QAAAA,iBAAAA,CAAiB,eAAe,OAAO;GAC5D,IAAI,CAAC,cACH;GAMF,MAAM,aAAA,wBAHc,aAAa,UACE,CAAC,CAAC,cAAA,QAAA,0BAAA,KAAA,IAAA,wBACnC,CAAC,EAAA,CAEA,QAAQ,UAAU,UAAU,IAAI,CAAC,CAEjC,KACE,EACC,KACA,UACA,IACA,OACA,YACA,YACA,kBACK;IACL,YAAY;IACZ;IACA;IACA,cAAc;IACd;IACA;IACA;GACF,EACF;GACF,IAAI,SAAS,WAAW,GACtB;GAGF,cAAA,QAAA,cAAA,KAAA,MAAA,oBAAA,UAAW,YAAA,QAAA,sBAAA,KAAA,KAAA,kBAAA,KAAA,WAAS;IAClB;IACA,UAAU,SAAS,EAAE,CAAC;IACtB,YAAY,SAAS,EAAE,CAAC;GAC1B,CAAC;EACH;EAEA,IAAA,cAAA,QAAA,cAAA,KAAA,IAAA,KAAA,IAAI,UAAW,QACb,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,GAAG,YAAY,cAAc;EAGtC,MAAM,wBAAwB;GAG5B,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,MAAM,CAAC,CAAC,eAAe,SAAS;EACzC;EACA,MAAM,cAAA,wBAAa,eAAe,aAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAS,SAAS;EAGpD,IAAI,CAAC,qBACH,eAAA,QAAA,eAAA,KAAA,KAAA,WAAY,iBAAiB,aAAa,eAAe;EAG3D,MAAM,mBAAmB,WAAkC;GAIzD,IAHc,OAAO,MACa,WACY,GAC3B;IACjB,IAAI,UAAU,KAAA,GACZ;IAEF,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,eAAe;KACpB,KAAK;KACL,OAAO;KACP,MAAM;IACR,CAAC;GACH;EACF;EACA,IAAI,CAAC,qBACH,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,MAAM,CAAC,CAAC,GAAG,aAAa,eAAe;EAGhD,MAAM,yBAAyB,eAAe;EAC9C,MAAM,UAAA,2BAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAU,uBAAwB,SAAS;EACjD,aAAa;GACX,YAAA,QAAA,YAAA,KAAA,KAAA,QAAS,oBAAoB,aAAa,eAAe;GAEzD,IAAI,wBAAwB;IAC1B,MAAM,SAAA,GAAQA,QAAAA,iBAAAA,CAAiB,sBAAsB;IACrD,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,IAAI,YAAY,cAAc;IACrC,UAAA,QAAA,UAAA,KAAA,KAAA,MAAO,MAAM,CAAC,CAAC,IAAI,aAAa,eAAe;GACjD;EACF;CACF,CAAC;CAED,IAAI,eAAe,YAAY,QAAQ,CAAC,qBAAqB;EAC3D,MAAM,SAAA,GAAQA,QAAAA,iBAAAA,CAAiB,eAAe,OAAO;EACrD,IAAI,OAGF,MAAM,eAAe;GACnB,sBAAsB;GACtB,KAAK;GACL,MAAM;EACR,CAAC;CAEL;AACF"}
|