@neo4j-ndl/react-charts 2.1.21 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LICENSES.txt +0 -295
- package/lib/NOTICE.txt +1383 -1392
- package/lib/{esm/charts/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.js} +13 -5
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js +46 -0
- package/lib/{esm/charts/tests/ChartWrapperWithTooltipFormatter.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.js} +12 -13
- package/lib/{esm/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.js} +13 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.js +35 -0
- package/lib/{esm/charts/utils/chart-types.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.js} +10 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.js +37 -0
- package/lib/cjs/_virtual/_rolldown/runtime.js +44 -0
- package/lib/cjs/charts/Chart.js +121 -111
- package/lib/cjs/charts/Chart.js.map +1 -1
- package/lib/cjs/charts/ChartContainer.js +67 -62
- package/lib/cjs/charts/ChartContainer.js.map +1 -1
- package/lib/cjs/charts/ChartEmpty.js +45 -30
- package/lib/cjs/charts/ChartEmpty.js.map +1 -1
- package/lib/cjs/charts/ChartRender.js +112 -87
- package/lib/cjs/charts/ChartRender.js.map +1 -1
- package/lib/cjs/charts/ChartTooltip.js +111 -65
- package/lib/cjs/charts/ChartTooltip.js.map +1 -1
- package/lib/cjs/charts/Legend.js +81 -69
- package/lib/cjs/charts/Legend.js.map +1 -1
- package/lib/cjs/charts/LegendItem.js +83 -62
- package/lib/cjs/charts/LegendItem.js.map +1 -1
- package/lib/cjs/charts/LegendLayout.js +330 -348
- package/lib/cjs/charts/LegendLayout.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-instance.js +115 -122
- package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-option.js +79 -80
- package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-refs.js +47 -44
- package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-zoom.js +102 -127
- package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-interactions.js +127 -132
- package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-series.js +143 -174
- package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-visibility.js +66 -85
- package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -1
- package/lib/cjs/charts/index.js +31 -40
- package/lib/cjs/charts/index.js.map +1 -1
- package/lib/cjs/charts/themes/ndl-echarts-theme.js +136 -168
- package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
- package/lib/cjs/charts/utils/aria-description.js +150 -214
- package/lib/cjs/charts/utils/aria-description.js.map +1 -1
- package/lib/cjs/charts/utils/build-chart-option.js +166 -174
- package/lib/cjs/charts/utils/build-chart-option.js.map +1 -1
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js +156 -172
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -1
- package/lib/cjs/charts/utils/chart-types.js +25 -20
- package/lib/cjs/charts/utils/chart-types.js.map +1 -1
- package/lib/cjs/charts/utils/defaults.js +69 -67
- package/lib/cjs/charts/utils/defaults.js.map +1 -1
- package/lib/cjs/charts/utils/format-utils.js +55 -66
- package/lib/cjs/charts/utils/format-utils.js.map +1 -1
- package/lib/cjs/charts/utils/legend-layout.js +54 -53
- package/lib/cjs/charts/utils/legend-layout.js.map +1 -1
- package/lib/cjs/charts/utils/legend-utils.js +82 -121
- package/lib/cjs/charts/utils/legend-utils.js.map +1 -1
- package/lib/cjs/charts/utils/scatter-tooltip-points.js +191 -266
- package/lib/cjs/charts/utils/scatter-tooltip-points.js.map +1 -1
- package/lib/cjs/charts/utils/threshold.js +89 -102
- package/lib/cjs/charts/utils/threshold.js.map +1 -1
- package/lib/cjs/charts/utils/user-option-utils.js +419 -347
- package/lib/cjs/charts/utils/user-option-utils.js.map +1 -1
- package/lib/cjs/index.js +31 -35
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs +24 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs +12 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.mjs +13 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.mjs +10 -0
- package/lib/esm/charts/Chart.mjs +123 -0
- package/lib/esm/charts/Chart.mjs.map +1 -0
- package/lib/esm/charts/ChartContainer.mjs +71 -0
- package/lib/esm/charts/ChartContainer.mjs.map +1 -0
- package/lib/esm/charts/ChartEmpty.mjs +46 -0
- package/lib/esm/charts/ChartEmpty.mjs.map +1 -0
- package/lib/esm/charts/ChartRender.mjs +113 -0
- package/lib/esm/charts/ChartRender.mjs.map +1 -0
- package/lib/esm/charts/ChartTooltip.mjs +109 -0
- package/lib/esm/charts/ChartTooltip.mjs.map +1 -0
- package/lib/esm/charts/Legend.mjs +82 -0
- package/lib/esm/charts/Legend.mjs.map +1 -0
- package/lib/esm/charts/LegendItem.mjs +82 -0
- package/lib/esm/charts/LegendItem.mjs.map +1 -0
- package/lib/esm/charts/LegendLayout.mjs +337 -0
- package/lib/esm/charts/LegendLayout.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs +119 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs +79 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs +49 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs +102 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs +138 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs +151 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs +67 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs.map +1 -0
- package/lib/esm/charts/index.mjs +27 -0
- package/lib/esm/charts/index.mjs.map +1 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs +139 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs.map +1 -0
- package/lib/esm/charts/utils/aria-description.mjs +162 -0
- package/lib/esm/charts/utils/aria-description.mjs.map +1 -0
- package/lib/esm/charts/utils/build-chart-option.mjs +184 -0
- package/lib/esm/charts/utils/build-chart-option.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs +159 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-types.mjs +24 -0
- package/lib/esm/charts/utils/chart-types.mjs.map +1 -0
- package/lib/esm/charts/utils/defaults.mjs +73 -0
- package/lib/esm/charts/utils/defaults.mjs.map +1 -0
- package/lib/esm/charts/utils/format-utils.mjs +61 -0
- package/lib/esm/charts/utils/format-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-layout.mjs +57 -0
- package/lib/esm/charts/utils/legend-layout.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-utils.mjs +90 -0
- package/lib/esm/charts/utils/legend-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs +215 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs.map +1 -0
- package/lib/esm/charts/utils/threshold.mjs +92 -0
- package/lib/esm/charts/utils/threshold.mjs.map +1 -0
- package/lib/esm/charts/utils/user-option-utils.mjs +445 -0
- package/lib/esm/charts/utils/user-option-utils.mjs.map +1 -0
- package/lib/esm/index.mjs +27 -0
- package/lib/esm/index.mjs.map +1 -0
- package/package.json +12 -16
- package/skills/ndl-react-charts/SKILL.md +2 -2
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js +0 -38
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/cjs/charts/tests/ChartZoomHarness.js +0 -113
- package/lib/cjs/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js +0 -78
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/cjs/charts/tests/PieChartWithRerender.js +0 -46
- package/lib/cjs/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/cjs/charts/tests/chart-test-utils.js +0 -527
- package/lib/cjs/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/Chart.js +0 -114
- package/lib/esm/charts/Chart.js.map +0 -1
- package/lib/esm/charts/ChartContainer.js +0 -67
- package/lib/esm/charts/ChartContainer.js.map +0 -1
- package/lib/esm/charts/ChartEmpty.js +0 -33
- package/lib/esm/charts/ChartEmpty.js.map +0 -1
- package/lib/esm/charts/ChartRender.js +0 -89
- package/lib/esm/charts/ChartRender.js.map +0 -1
- package/lib/esm/charts/ChartTooltip.js +0 -64
- package/lib/esm/charts/ChartTooltip.js.map +0 -1
- package/lib/esm/charts/Legend.js +0 -71
- package/lib/esm/charts/Legend.js.map +0 -1
- package/lib/esm/charts/LegendItem.js +0 -61
- package/lib/esm/charts/LegendItem.js.map +0 -1
- package/lib/esm/charts/LegendLayout.js +0 -323
- package/lib/esm/charts/LegendLayout.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-instance.js +0 -128
- package/lib/esm/charts/hooks/use-chart-instance.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-option.js +0 -82
- package/lib/esm/charts/hooks/use-chart-option.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-refs.js +0 -48
- package/lib/esm/charts/hooks/use-chart-refs.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-zoom.js +0 -129
- package/lib/esm/charts/hooks/use-chart-zoom.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-interactions.js +0 -145
- package/lib/esm/charts/hooks/use-legend-interactions.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-series.js +0 -184
- package/lib/esm/charts/hooks/use-legend-series.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-visibility.js +0 -87
- package/lib/esm/charts/hooks/use-legend-visibility.js.map +0 -1
- package/lib/esm/charts/index.js.map +0 -1
- package/lib/esm/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/esm/charts/tests/ChartZoomHarness.js +0 -109
- package/lib/esm/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js +0 -74
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/esm/charts/tests/PieChartWithRerender.js +0 -43
- package/lib/esm/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/esm/charts/tests/chart-test-utils.js +0 -500
- package/lib/esm/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/themes/ndl-echarts-theme.js +0 -172
- package/lib/esm/charts/themes/ndl-echarts-theme.js.map +0 -1
- package/lib/esm/charts/utils/aria-description.js +0 -228
- package/lib/esm/charts/utils/aria-description.js.map +0 -1
- package/lib/esm/charts/utils/build-chart-option.js +0 -193
- package/lib/esm/charts/utils/build-chart-option.js.map +0 -1
- package/lib/esm/charts/utils/chart-tooltip-formatter.js +0 -177
- package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +0 -1
- package/lib/esm/charts/utils/chart-types.js.map +0 -1
- package/lib/esm/charts/utils/defaults.js +0 -73
- package/lib/esm/charts/utils/defaults.js.map +0 -1
- package/lib/esm/charts/utils/format-utils.js +0 -74
- package/lib/esm/charts/utils/format-utils.js.map +0 -1
- package/lib/esm/charts/utils/legend-layout.js +0 -59
- package/lib/esm/charts/utils/legend-layout.js.map +0 -1
- package/lib/esm/charts/utils/legend-utils.js +0 -131
- package/lib/esm/charts/utils/legend-utils.js.map +0 -1
- package/lib/esm/charts/utils/scatter-tooltip-points.js +0 -291
- package/lib/esm/charts/utils/scatter-tooltip-points.js.map +0 -1
- package/lib/esm/charts/utils/threshold.js +0 -106
- package/lib/esm/charts/utils/threshold.js.map +0 -1
- package/lib/esm/charts/utils/user-option-utils.js +0 -374
- package/lib/esm/charts/utils/user-option-utils.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
package/lib/esm/charts/Chart.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
|
-
var t = {};
|
|
24
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25
|
-
t[p] = s[p];
|
|
26
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
27
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29
|
-
t[p[i]] = s[p[i]];
|
|
30
|
-
}
|
|
31
|
-
return t;
|
|
32
|
-
};
|
|
33
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
35
|
-
import { ChartContainer } from './ChartContainer';
|
|
36
|
-
import { ChartRender } from './ChartRender';
|
|
37
|
-
import { ChartRefsProvider } from './hooks/use-chart-refs';
|
|
38
|
-
import { useLegendSeries } from './hooks/use-legend-series';
|
|
39
|
-
import { Legend } from './Legend';
|
|
40
|
-
/**
|
|
41
|
-
* Bridges the rendered ECharts option into the React legend.
|
|
42
|
-
*
|
|
43
|
-
* `useLegendSeries` reads the current chart option and ECharts color state to
|
|
44
|
-
* derive the legend rows. Rendering is deferred until the chart has completed
|
|
45
|
-
* its first resize so the legend does not measure against an uninitialized
|
|
46
|
-
* chart instance.
|
|
47
|
-
*/
|
|
48
|
-
const ChartLegend = ({ chartOption, isLayoutReady, isWaitingForFirstResize, onLayoutReady, }) => {
|
|
49
|
-
const legendSeries = useLegendSeries({
|
|
50
|
-
chartOption,
|
|
51
|
-
isWaitingForFirstResize,
|
|
52
|
-
});
|
|
53
|
-
if (isWaitingForFirstResize) {
|
|
54
|
-
return (_jsx("div", { "aria-hidden": "true", className: "ndl-chart-legend-container ndl-chart-legend-container-placeholder" }));
|
|
55
|
-
}
|
|
56
|
-
return (_jsx(Legend, { series: legendSeries !== null && legendSeries !== void 0 ? legendSeries : [], onLayoutReady: onLayoutReady, isLayoutReady: isLayoutReady }));
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* A chart component powered by Apache ECharts with Needle's customization and theming.
|
|
60
|
-
*
|
|
61
|
-
* The `Chart` component fills 100% of its parent's width and height. Because it
|
|
62
|
-
* relies on the container's `clientHeight` to size the canvas, **the parent element
|
|
63
|
-
* must have an explicit height** (e.g. a fixed px/rem value or a viewport unit).
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```tsx
|
|
67
|
-
* <div style={{ height: '350px' }}>
|
|
68
|
-
* <Chart dataset={dataset} series={series} xAxis={xAxis} yAxis={yAxis} />
|
|
69
|
-
* </div>
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @remarks
|
|
73
|
-
* **Data zoom sliders.** A `dataZoom` slider passed through `option` targets
|
|
74
|
-
* the x-axis unless it is bound to an axis explicitly, so on a horizontal bar
|
|
75
|
-
* chart it zooms the value axis rather than the categories. Bind the slider to
|
|
76
|
-
* the category axis with `yAxisIndex: [0]` (or set `orient: 'vertical'`) to
|
|
77
|
-
* page through the bars instead; Needle then lays the slider out vertically on
|
|
78
|
-
* the right of the chart and reserves grid space for it. Sliders that target a
|
|
79
|
-
* continuous (`value`, `time`, or `log`) axis default to `filterMode: 'none'`
|
|
80
|
-
* so out-of-window data is clipped rather than removed, while category-axis
|
|
81
|
-
* sliders keep ECharts' `'filter'` default so the opposite value axis rescales
|
|
82
|
-
* to the visible data.
|
|
83
|
-
*
|
|
84
|
-
* **Drag-to-zoom.** Dragging in the plot area zooms the axes your `dataZoom`
|
|
85
|
-
* config targets: entries bound to a y-axis (`yAxisIndex` or
|
|
86
|
-
* `orient: 'vertical'`) make the drag select a y band, entries on both axes
|
|
87
|
-
* make it select a rectangle, and without any `dataZoom` config the drag zooms
|
|
88
|
-
* the x-axis. Set `toolbox.feature.dataZoom` through `option` to override the
|
|
89
|
-
* derived axes explicitly. When every drag-targeted axis is continuous the
|
|
90
|
-
* drag defaults to `filterMode: 'none'`, matching the slider rule above.
|
|
91
|
-
*
|
|
92
|
-
* **Axis-label tooltips.** Hovering a truncated axis label shows its full text
|
|
93
|
-
* in a tooltip. Set `xAxis.tooltip.show` or `yAxis.tooltip.show` to `false` to
|
|
94
|
-
* disable this behavior for an axis.
|
|
95
|
-
*/
|
|
96
|
-
export const Chart = (_a) => {
|
|
97
|
-
var { style, legend } = _a, chartProps = __rest(_a, ["style", "legend"]);
|
|
98
|
-
const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);
|
|
99
|
-
const [chartOption, setChartOption] = useState();
|
|
100
|
-
const [isLegendLayoutReady, setIsLegendLayoutReady] = useState(!(legend === null || legend === void 0 ? void 0 : legend.isVisible));
|
|
101
|
-
const handleLegendLayoutReady = useCallback(() => {
|
|
102
|
-
setIsLegendLayoutReady(true);
|
|
103
|
-
}, []);
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
if (!(legend === null || legend === void 0 ? void 0 : legend.isVisible)) {
|
|
106
|
-
setIsLegendLayoutReady(true);
|
|
107
|
-
}
|
|
108
|
-
}, [legend === null || legend === void 0 ? void 0 : legend.isVisible]);
|
|
109
|
-
const chartLayoutClassName = (legend === null || legend === void 0 ? void 0 : legend.isVisible) && !isLegendLayoutReady
|
|
110
|
-
? 'ndl-chart-layout ndl-chart-layout-hidden'
|
|
111
|
-
: 'ndl-chart-layout';
|
|
112
|
-
return (_jsx(ChartRefsProvider, { children: _jsxs(ChartContainer, { style: style, children: [_jsx("div", { className: chartLayoutClassName, children: _jsx(ChartRender, Object.assign({}, chartProps, { onChartOptionChange: setChartOption, onFirstResizeChange: setIsWaitingForFirstResize })) }), (legend === null || legend === void 0 ? void 0 : legend.isVisible) && (_jsx(ChartLegend, { chartOption: chartOption, isLayoutReady: isLegendLayoutReady, isWaitingForFirstResize: isWaitingForFirstResize, onLayoutReady: handleLegendLayoutReady }))] }) }));
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=Chart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAsBA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUlC;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,CAAC,EACnB,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,aAAa,GACI,EAAE,EAAE;IACrB,MAAM,YAAY,GAAG,eAAe,CAAC;QACnC,WAAW;QACX,uBAAuB;KACxB,CAAC,CAAC;IAEH,IAAI,uBAAuB,EAAE,CAAC;QAC5B,OAAO,CACL,6BACc,MAAM,EAClB,SAAS,EAAC,mEAAmE,GAC7E,CACH,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,MAAM,IACL,MAAM,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAC1B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,GAC5B,CACH,CAAC;AACJ,CAAC,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L,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,KAAI,CACpB,KAAC,WAAW,IACV,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,EAClC,uBAAuB,EAAE,uBAAuB,EAChD,aAAa,EAAE,uBAAuB,GACtC,CACH,IACc,GACC,CACrB,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 type { EChartsOption } from 'echarts';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { ChartContainer } from './ChartContainer';\nimport { ChartRender } from './ChartRender';\nimport { ChartRefsProvider } from './hooks/use-chart-refs';\nimport { useLegendSeries } from './hooks/use-legend-series';\nimport { Legend } from './Legend';\nimport { type ChartProps } from './utils/chart-types';\n\ntype ChartLegendProps = {\n chartOption: EChartsOption | undefined;\n isLayoutReady: boolean;\n isWaitingForFirstResize: boolean;\n onLayoutReady?: () => void;\n};\n\n/**\n * Bridges the rendered ECharts option into the React legend.\n *\n * `useLegendSeries` reads the current chart option and ECharts color state to\n * derive the legend rows. Rendering is deferred until the chart has completed\n * its first resize so the legend does not measure against an uninitialized\n * chart instance.\n */\nconst ChartLegend = ({\n chartOption,\n isLayoutReady,\n isWaitingForFirstResize,\n onLayoutReady,\n}: ChartLegendProps) => {\n const legendSeries = useLegendSeries({\n chartOption,\n isWaitingForFirstResize,\n });\n\n if (isWaitingForFirstResize) {\n return (\n <div\n aria-hidden=\"true\"\n className=\"ndl-chart-legend-container ndl-chart-legend-container-placeholder\"\n />\n );\n }\n\n return (\n <Legend\n series={legendSeries ?? []}\n onLayoutReady={onLayoutReady}\n isLayoutReady={isLayoutReady}\n />\n );\n};\n\n/**\n * A chart component powered by Apache ECharts with Needle's customization and theming.\n *\n * The `Chart` component fills 100% of its parent's width and height. Because it\n * relies on the container's `clientHeight` to size the canvas, **the parent element\n * must have an explicit height** (e.g. a fixed px/rem value or a viewport unit).\n *\n * @example\n * ```tsx\n * <div style={{ height: '350px' }}>\n * <Chart dataset={dataset} series={series} xAxis={xAxis} yAxis={yAxis} />\n * </div>\n * ```\n *\n * @remarks\n * **Data zoom sliders.** A `dataZoom` slider passed through `option` targets\n * the x-axis unless it is bound to an axis explicitly, so on a horizontal bar\n * chart it zooms the value axis rather than the categories. Bind the slider to\n * the category axis with `yAxisIndex: [0]` (or set `orient: 'vertical'`) to\n * page through the bars instead; Needle then lays the slider out vertically on\n * the right of the chart and reserves grid space for it. Sliders that target a\n * continuous (`value`, `time`, or `log`) axis default to `filterMode: 'none'`\n * so out-of-window data is clipped rather than removed, while category-axis\n * sliders keep ECharts' `'filter'` default so the opposite value axis rescales\n * to the visible data.\n *\n * **Drag-to-zoom.** Dragging in the plot area zooms the axes your `dataZoom`\n * config targets: entries bound to a y-axis (`yAxisIndex` or\n * `orient: 'vertical'`) make the drag select a y band, entries on both axes\n * make it select a rectangle, and without any `dataZoom` config the drag zooms\n * the x-axis. Set `toolbox.feature.dataZoom` through `option` to override the\n * derived axes explicitly. When every drag-targeted axis is continuous the\n * drag defaults to `filterMode: 'none'`, matching the slider rule above.\n *\n * **Axis-label tooltips.** Hovering a truncated axis label shows its full text\n * in a tooltip. Set `xAxis.tooltip.show` or `yAxis.tooltip.show` to `false` to\n * disable this behavior for an axis.\n */\nexport const Chart = ({ style, legend, ...chartProps }: ChartProps) => {\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n const [chartOption, setChartOption] = useState<EChartsOption>();\n const [isLegendLayoutReady, setIsLegendLayoutReady] = useState(\n !legend?.isVisible,\n );\n\n const handleLegendLayoutReady = useCallback(() => {\n setIsLegendLayoutReady(true);\n }, []);\n\n useEffect(() => {\n if (!legend?.isVisible) {\n setIsLegendLayoutReady(true);\n }\n }, [legend?.isVisible]);\n\n const chartLayoutClassName =\n legend?.isVisible && !isLegendLayoutReady\n ? 'ndl-chart-layout ndl-chart-layout-hidden'\n : 'ndl-chart-layout';\n\n return (\n <ChartRefsProvider>\n <ChartContainer style={style}>\n <div className={chartLayoutClassName}>\n <ChartRender\n {...chartProps}\n onChartOptionChange={setChartOption}\n onFirstResizeChange={setIsWaitingForFirstResize}\n />\n </div>\n {legend?.isVisible && (\n <ChartLegend\n chartOption={chartOption}\n isLayoutReady={isLegendLayoutReady}\n isWaitingForFirstResize={isWaitingForFirstResize}\n onLayoutReady={handleLegendLayoutReady}\n />\n )}\n </ChartContainer>\n </ChartRefsProvider>\n );\n};\n"]}
|
|
@@ -1,67 +0,0 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
23
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
24
|
-
const EXPANDED_LEGEND_MAX_HEIGHT_RATIO = 0.3;
|
|
25
|
-
/**
|
|
26
|
-
* Tracks the outer chart container height.
|
|
27
|
-
*
|
|
28
|
-
* The measured height is used to expose CSS sizing data to descendants, most
|
|
29
|
-
* notably the expanded legend max height. A ResizeObserver keeps the value in
|
|
30
|
-
* sync with parent layout changes.
|
|
31
|
-
*/
|
|
32
|
-
const useChartContainerHeight = (chartRef) => {
|
|
33
|
-
const [chartContainerHeight, setChartContainerHeight] = useState();
|
|
34
|
-
const updateChartContainerHeight = useCallback(() => {
|
|
35
|
-
var _a;
|
|
36
|
-
setChartContainerHeight((_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight);
|
|
37
|
-
}, [chartRef]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
updateChartContainerHeight();
|
|
40
|
-
const chartContainer = chartRef.current;
|
|
41
|
-
if (!chartContainer) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const resizeObserver = new ResizeObserver(updateChartContainerHeight);
|
|
45
|
-
resizeObserver.observe(chartContainer);
|
|
46
|
-
return () => {
|
|
47
|
-
resizeObserver.disconnect();
|
|
48
|
-
};
|
|
49
|
-
}, [chartRef, updateChartContainerHeight]);
|
|
50
|
-
return chartContainerHeight;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Provides the chart grid shell and CSS variables shared by the ECharts canvas
|
|
54
|
-
* and legend rows.
|
|
55
|
-
*
|
|
56
|
-
* The container owns the measurement ref for the full chart area so the legend
|
|
57
|
-
* can cap expanded height relative to the available chart height.
|
|
58
|
-
*/
|
|
59
|
-
export const ChartContainer = ({ children, style }) => {
|
|
60
|
-
const chartRef = useRef(null);
|
|
61
|
-
const chartContainerHeight = useChartContainerHeight(chartRef);
|
|
62
|
-
const chartContainerStyle = useMemo(() => (Object.assign(Object.assign({}, style), { '--ndl-chart-legend-expanded-max-height': chartContainerHeight === undefined
|
|
63
|
-
? undefined
|
|
64
|
-
: `${Math.floor(chartContainerHeight * EXPANDED_LEGEND_MAX_HEIGHT_RATIO)}px` })), [chartContainerHeight, style]);
|
|
65
|
-
return (_jsx("div", { ref: chartRef, className: "ndl-chart", style: chartContainerStyle, children: children }));
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=ChartContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartContainer.js","sourceRoot":"","sources":["../../../src/charts/ChartContainer.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,CAC9B,QAAgD,EAChD,EAAE;IACF,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,EAAU,CAAC;IAE3E,MAAM,0BAA0B,GAAG,WAAW,CAAC,GAAG,EAAE;;QAClD,uBAAuB,CAAC,MAAA,QAAQ,CAAC,OAAO,0CAAE,YAAY,CAAC,CAAC;IAC1D,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,SAAS,CAAC,GAAG,EAAE;QACb,0BAA0B,EAAE,CAAC;QAE7B,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC;QACxC,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,0BAA0B,CAAC,CAAC;QACtE,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEvC,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAE3C,OAAO,oBAAoB,CAAC;AAC9B,CAAC,CAAC;AAOF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAuB,EAAE,EAAE;IACzE,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAAM,mBAAmB,GAAG,OAAO,CACjC,GAAG,EAAE,CACH,iCACK,KAAK,KACR,wCAAwC,EACtC,oBAAoB,KAAK,SAAS;YAChC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CACX,oBAAoB,GAAG,gCAAgC,CACxD,IAAI,IACY,EAC3B,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,cAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,mBAAmB,YACjE,QAAQ,GACL,CACP,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 type React from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nconst EXPANDED_LEGEND_MAX_HEIGHT_RATIO = 0.3;\n\n/**\n * Tracks the outer chart container height.\n *\n * The measured height is used to expose CSS sizing data to descendants, most\n * notably the expanded legend max height. A ResizeObserver keeps the value in\n * sync with parent layout changes.\n */\nconst useChartContainerHeight = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n) => {\n const [chartContainerHeight, setChartContainerHeight] = useState<number>();\n\n const updateChartContainerHeight = useCallback(() => {\n setChartContainerHeight(chartRef.current?.clientHeight);\n }, [chartRef]);\n\n useEffect(() => {\n updateChartContainerHeight();\n\n const chartContainer = chartRef.current;\n if (!chartContainer) {\n return;\n }\n\n const resizeObserver = new ResizeObserver(updateChartContainerHeight);\n resizeObserver.observe(chartContainer);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, [chartRef, updateChartContainerHeight]);\n\n return chartContainerHeight;\n};\n\ntype ChartContainerProps = {\n children: React.ReactNode;\n style?: React.CSSProperties;\n};\n\n/**\n * Provides the chart grid shell and CSS variables shared by the ECharts canvas\n * and legend rows.\n *\n * The container owns the measurement ref for the full chart area so the legend\n * can cap expanded height relative to the available chart height.\n */\nexport const ChartContainer = ({ children, style }: ChartContainerProps) => {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartContainerHeight = useChartContainerHeight(chartRef);\n const chartContainerStyle = useMemo(\n () =>\n ({\n ...style,\n '--ndl-chart-legend-expanded-max-height':\n chartContainerHeight === undefined\n ? undefined\n : `${Math.floor(\n chartContainerHeight * EXPANDED_LEGEND_MAX_HEIGHT_RATIO,\n )}px`,\n }) as React.CSSProperties,\n [chartContainerHeight, style],\n );\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={chartContainerStyle}>\n {children}\n </div>\n );\n};\n"]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*!
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) "Neo4j"
|
|
5
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Neo4j.
|
|
8
|
-
*
|
|
9
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
-
* it under the terms of the GNU General Public License as published by
|
|
11
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
-
* (at your option) any later version.
|
|
13
|
-
*
|
|
14
|
-
* This program is distributed in the hope that it will be useful,
|
|
15
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
-
* GNU General Public License for more details.
|
|
18
|
-
*
|
|
19
|
-
* You should have received a copy of the GNU General Public License
|
|
20
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
-
*/
|
|
22
|
-
import { Typography } from '@neo4j-ndl/react';
|
|
23
|
-
import { ChartPieIconOutline, PresentationChartBarIconOutline, PresentationChartLineIconOutline, } from '@neo4j-ndl/react/icons';
|
|
24
|
-
const chartEmptyIcons = {
|
|
25
|
-
bar: PresentationChartBarIconOutline,
|
|
26
|
-
line: PresentationChartLineIconOutline,
|
|
27
|
-
pie: ChartPieIconOutline,
|
|
28
|
-
};
|
|
29
|
-
export function ChartEmpty({ action, message = 'No data available', type = 'line', }) {
|
|
30
|
-
const Icon = chartEmptyIcons[type];
|
|
31
|
-
return (_jsxs("div", { className: "ndl-chart-empty-state", children: [_jsx(Icon, { className: "ndl-chart-empty-state-icon" }), _jsx(Typography, { variant: "body-medium", children: message }), action] }));
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=ChartEmpty.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartEmpty.js","sourceRoot":"","sources":["../../../src/charts/ChartEmpty.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAIhC,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,+BAA+B;IACpC,IAAI,EAAE,gCAAgC;IACtC,GAAG,EAAE,mBAAmB;CAIzB,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,GAAG,mBAAmB,EAC7B,IAAI,GAAG,MAAM,GACG;IAChB,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,CACL,eAAK,SAAS,EAAC,uBAAuB,aACpC,KAAC,IAAI,IAAC,SAAS,EAAC,4BAA4B,GAAG,EAC/C,KAAC,UAAU,IAAC,OAAO,EAAC,aAAa,YAAE,OAAO,GAAc,EACvD,MAAM,IACH,CACP,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 */\nimport { Typography } from '@neo4j-ndl/react';\nimport {\n ChartPieIconOutline,\n PresentationChartBarIconOutline,\n PresentationChartLineIconOutline,\n} from '@neo4j-ndl/react/icons';\n\nimport { type ChartEmptyProps } from './utils/chart-types';\n\nconst chartEmptyIcons = {\n bar: PresentationChartBarIconOutline,\n line: PresentationChartLineIconOutline,\n pie: ChartPieIconOutline,\n} satisfies Record<\n NonNullable<ChartEmptyProps['type']>,\n React.ComponentType<{ className?: string }>\n>;\n\nexport function ChartEmpty({\n action,\n message = 'No data available',\n type = 'line',\n}: ChartEmptyProps): React.JSX.Element {\n const Icon = chartEmptyIcons[type];\n\n return (\n <div className=\"ndl-chart-empty-state\">\n <Icon className=\"ndl-chart-empty-state-icon\" />\n <Typography variant=\"body-medium\">{message}</Typography>\n {action}\n </div>\n );\n}\n"]}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*!
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) "Neo4j"
|
|
5
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Neo4j.
|
|
8
|
-
*
|
|
9
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
-
* it under the terms of the GNU General Public License as published by
|
|
11
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
-
* (at your option) any later version.
|
|
13
|
-
*
|
|
14
|
-
* This program is distributed in the hope that it will be useful,
|
|
15
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
-
* GNU General Public License for more details.
|
|
18
|
-
*
|
|
19
|
-
* You should have received a copy of the GNU General Public License
|
|
20
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
-
*/
|
|
22
|
-
import { useNeedleTheme } from '@neo4j-ndl/react';
|
|
23
|
-
import { useEffect, useMemo } from 'react';
|
|
24
|
-
import { useChartLifecycle, useChartLoading, useChartResize, } from './hooks/use-chart-instance';
|
|
25
|
-
import { useChartOption } from './hooks/use-chart-option';
|
|
26
|
-
import { useChartRefsContext } from './hooks/use-chart-refs';
|
|
27
|
-
import { useChartZoom } from './hooks/use-chart-zoom';
|
|
28
|
-
import { hasCategoryXAxis as getHasCategoryXAxis, hasMarkAreaInSeries, } from './utils/build-chart-option';
|
|
29
|
-
import { defaultChartSettings } from './utils/defaults';
|
|
30
|
-
import { normalizeThresholdLines } from './utils/threshold';
|
|
31
|
-
import { mergeDataZoom, mergeSeries, mergeXAxis, mergeYAxis, } from './utils/user-option-utils';
|
|
32
|
-
/**
|
|
33
|
-
* Owns the ECharts instance element and coordinates chart-specific hooks.
|
|
34
|
-
*
|
|
35
|
-
* The component normalizes user props into Needle-themed ECharts options,
|
|
36
|
-
* initializes/resizes the chart instance, applies loading and zoom behavior, and
|
|
37
|
-
* reports derived chart state back to `Chart` for legend rendering.
|
|
38
|
-
*/
|
|
39
|
-
export const ChartRender = ({ callbacks, dataset, isChartZoomDisabled = false, isLoading, onChartOptionChange, onFirstResizeChange, option: userOption, palette, series: propsSeries, settings = defaultChartSettings, xAxis: propXAxis, yAxis: propYAxis, }) => {
|
|
40
|
-
const { chartEchartRef } = useChartRefsContext();
|
|
41
|
-
const dataZoomOptions = userOption === null || userOption === void 0 ? void 0 : userOption.dataZoom;
|
|
42
|
-
const toolboxOptions = userOption === null || userOption === void 0 ? void 0 : userOption.toolbox;
|
|
43
|
-
const { theme } = useNeedleTheme();
|
|
44
|
-
const thresholdLines = useMemo(() => normalizeThresholdLines(propsSeries), [propsSeries]);
|
|
45
|
-
const dataZoom = useMemo(() => mergeDataZoom(dataZoomOptions, { xAxis: propXAxis, yAxis: propYAxis }), [dataZoomOptions, propXAxis, propYAxis]);
|
|
46
|
-
const series = useMemo(() => mergeSeries(propsSeries, theme, userOption, palette), [palette, propsSeries, theme, userOption]);
|
|
47
|
-
const xAxis = useMemo(() => mergeXAxis(propXAxis, theme), [propXAxis, theme]);
|
|
48
|
-
const yAxis = useMemo(() => mergeYAxis(propYAxis, theme), [propYAxis, theme]);
|
|
49
|
-
const hasCategoryXAxis = getHasCategoryXAxis(xAxis);
|
|
50
|
-
const hasMarkArea = hasMarkAreaInSeries(series);
|
|
51
|
-
/**
|
|
52
|
-
* Hook responsibilities:
|
|
53
|
-
* - `useChartLifecycle` creates/disposes the ECharts instance and updates theme data.
|
|
54
|
-
* - `useChartResize` keeps the canvas sized to its container before first render.
|
|
55
|
-
* - `useChartOption` builds and applies the merged ECharts option.
|
|
56
|
-
* - `useChartZoom` attaches consumer zoom callbacks.
|
|
57
|
-
* - `useChartLoading` synchronizes the loading overlay with chart readiness.
|
|
58
|
-
*/
|
|
59
|
-
useChartLifecycle({ palette, theme });
|
|
60
|
-
const { isWaitingForFirstResize } = useChartResize();
|
|
61
|
-
const chartOption = useChartOption({
|
|
62
|
-
dataZoom,
|
|
63
|
-
dataset,
|
|
64
|
-
hasCategoryXAxis,
|
|
65
|
-
hasMarkArea,
|
|
66
|
-
propsSeries,
|
|
67
|
-
series,
|
|
68
|
-
settings,
|
|
69
|
-
thresholdLines,
|
|
70
|
-
toolboxOptions,
|
|
71
|
-
userOption,
|
|
72
|
-
xAxis,
|
|
73
|
-
yAxis,
|
|
74
|
-
});
|
|
75
|
-
useChartZoom({ callbacks, isChartZoomDisabled });
|
|
76
|
-
useChartLoading({
|
|
77
|
-
isLoading,
|
|
78
|
-
isWaitingForFirstResize,
|
|
79
|
-
theme,
|
|
80
|
-
});
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
onFirstResizeChange(isWaitingForFirstResize);
|
|
83
|
-
}, [isWaitingForFirstResize, onFirstResizeChange]);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
onChartOptionChange(chartOption);
|
|
86
|
-
}, [chartOption, onChartOptionChange]);
|
|
87
|
-
return _jsx("div", { ref: chartEchartRef, className: "ndl-chart-echart" });
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=ChartRender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartRender.js","sourceRoot":"","sources":["../../../src/charts/ChartRender.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,GACf,MAAM,4BAA4B,CAAC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,mBAAmB,CAAC,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEvC,OAAO,cAAK,GAAG,EAAE,cAAc,EAAE,SAAS,EAAC,kBAAkB,GAAG,CAAC;AACnE,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 { useNeedleTheme } from '@neo4j-ndl/react';\nimport type { EChartsOption } from 'echarts';\nimport { useEffect, useMemo } from 'react';\n\nimport {\n useChartLifecycle,\n useChartLoading,\n useChartResize,\n} from './hooks/use-chart-instance';\nimport { useChartOption } from './hooks/use-chart-option';\nimport { useChartRefsContext } from './hooks/use-chart-refs';\nimport { useChartZoom } from './hooks/use-chart-zoom';\nimport {\n hasCategoryXAxis as getHasCategoryXAxis,\n hasMarkAreaInSeries,\n} from './utils/build-chart-option';\nimport type { ChartProps } from './utils/chart-types';\nimport { defaultChartSettings } from './utils/defaults';\nimport { normalizeThresholdLines } from './utils/threshold';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeXAxis,\n mergeYAxis,\n} from './utils/user-option-utils';\n\ntype ChartRenderProps = Omit<ChartProps, 'legend' | 'style'> & {\n onChartOptionChange: (chartOption: EChartsOption | undefined) => void;\n onFirstResizeChange: (isWaitingForFirstResize: boolean) => void;\n};\n\n/**\n * Owns the ECharts instance element and coordinates chart-specific hooks.\n *\n * The component normalizes user props into Needle-themed ECharts options,\n * initializes/resizes the chart instance, applies loading and zoom behavior, and\n * reports derived chart state back to `Chart` for legend rendering.\n */\nexport const ChartRender = ({\n callbacks,\n dataset,\n isChartZoomDisabled = false,\n isLoading,\n onChartOptionChange,\n onFirstResizeChange,\n option: userOption,\n palette,\n series: propsSeries,\n settings = defaultChartSettings,\n xAxis: propXAxis,\n yAxis: propYAxis,\n}: ChartRenderProps) => {\n const { chartEchartRef } = useChartRefsContext();\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n const { theme } = useNeedleTheme();\n\n const thresholdLines = useMemo(\n () => normalizeThresholdLines(propsSeries),\n [propsSeries],\n );\n const dataZoom = useMemo(\n () =>\n mergeDataZoom(dataZoomOptions, { xAxis: propXAxis, yAxis: propYAxis }),\n [dataZoomOptions, propXAxis, propYAxis],\n );\n const series = useMemo(\n () => mergeSeries(propsSeries, theme, userOption, palette),\n [palette, propsSeries, theme, userOption],\n );\n const xAxis = useMemo(() => mergeXAxis(propXAxis, theme), [propXAxis, theme]);\n const yAxis = useMemo(() => mergeYAxis(propYAxis, theme), [propYAxis, theme]);\n const hasCategoryXAxis = getHasCategoryXAxis(xAxis);\n const hasMarkArea = hasMarkAreaInSeries(series);\n\n /**\n * Hook responsibilities:\n * - `useChartLifecycle` creates/disposes the ECharts instance and updates theme data.\n * - `useChartResize` keeps the canvas sized to its container before first render.\n * - `useChartOption` builds and applies the merged ECharts option.\n * - `useChartZoom` attaches consumer zoom callbacks.\n * - `useChartLoading` synchronizes the loading overlay with chart readiness.\n */\n useChartLifecycle({ palette, theme });\n const { isWaitingForFirstResize } = useChartResize();\n const chartOption = useChartOption({\n dataZoom,\n dataset,\n hasCategoryXAxis,\n hasMarkArea,\n propsSeries,\n series,\n settings,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n });\n useChartZoom({ callbacks, isChartZoomDisabled });\n useChartLoading({\n isLoading,\n isWaitingForFirstResize,\n theme,\n });\n\n useEffect(() => {\n onFirstResizeChange(isWaitingForFirstResize);\n }, [isWaitingForFirstResize, onFirstResizeChange]);\n\n useEffect(() => {\n onChartOptionChange(chartOption);\n }, [chartOption, onChartOptionChange]);\n\n return <div ref={chartEchartRef} className=\"ndl-chart-echart\" />;\n};\n"]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
/*!
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) "Neo4j"
|
|
16
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Neo4j.
|
|
19
|
-
*
|
|
20
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU General Public License as published by
|
|
22
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
-
* (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* This program is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*/
|
|
33
|
-
import { Popover, StatusIndicator, TextLink, Typography, } from '@neo4j-ndl/react';
|
|
34
|
-
import classNames from 'classnames';
|
|
35
|
-
export const ChartTooltipComponent = function ChartTooltipComponent({ children, isOpen, style, anchorPosition, ref, }) {
|
|
36
|
-
return (_jsx(Popover, { isOpen: isOpen, anchorPosition: anchorPosition, placement: "middle-end-middle-start", children: _jsx(Popover.Content, { ref: ref, style: style, children: children }) }));
|
|
37
|
-
};
|
|
38
|
-
const ChartTooltipTitle = function ChartTooltipTitle({ children, indentSquareColor, ref, }) {
|
|
39
|
-
const classes = classNames(`ndl-charts-chart-tooltip-title`);
|
|
40
|
-
const title = (_jsx(Typography, { ref: ref, variant: "body-small", className: classes, children: children }));
|
|
41
|
-
if (indentSquareColor === undefined) {
|
|
42
|
-
return title;
|
|
43
|
-
}
|
|
44
|
-
return (_jsxs("div", { className: "ndl-charts-chart-tooltip-title-line", children: [_jsx("div", { className: "ndl-charts-chart-tooltip-title-indent-square", style: { backgroundColor: indentSquareColor } }), title] }));
|
|
45
|
-
};
|
|
46
|
-
const ChartTooltipContent = function ChartTooltipContent({ leadingElement, trailingElement, indentSquareColor, notifications, ref, }) {
|
|
47
|
-
const classes = classNames(`ndl-charts-chart-tooltip-content`);
|
|
48
|
-
return (_jsxs("div", { ref: ref, className: classes, children: [_jsxs("div", { className: "ndl-charts-chart-tooltip-content-line", children: [indentSquareColor && (_jsx("div", { className: "ndl-charts-chart-tooltip-content-indent-square", style: { backgroundColor: indentSquareColor } })), leadingElement && (_jsx(Typography, { variant: trailingElement ? 'body-medium' : 'label', className: "ndl-charts-chart-tooltip-content-left-element", children: leadingElement })), trailingElement && (_jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-trailing-element", children: trailingElement }))] }), notifications &&
|
|
49
|
-
notifications.map((notification) => {
|
|
50
|
-
const { id, notificationType, leadingElement, trailingElement } = notification;
|
|
51
|
-
return (_jsxs("div", { className: `ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`, children: [_jsx(StatusIndicator, { variant: notificationType }), _jsx(Typography, { variant: "body-medium", className: "ndl-charts-chart-tooltip-content-notification-left-element", children: leadingElement }), _jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-notification-trailing-element", children: trailingElement })] }, `notification-${id}`));
|
|
52
|
-
})] }));
|
|
53
|
-
};
|
|
54
|
-
const ChartTooltipLink = function ChartTooltipAction(_a) {
|
|
55
|
-
var { ref } = _a, restProps = __rest(_a, ["ref"]);
|
|
56
|
-
return _jsx(TextLink, Object.assign({ ref: ref }, restProps));
|
|
57
|
-
};
|
|
58
|
-
const ChartTooltip = Object.assign(ChartTooltipComponent, {
|
|
59
|
-
Content: ChartTooltipContent,
|
|
60
|
-
Link: ChartTooltipLink,
|
|
61
|
-
Title: ChartTooltipTitle,
|
|
62
|
-
});
|
|
63
|
-
export { ChartTooltip };
|
|
64
|
-
//# sourceMappingURL=ChartTooltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltip.js","sourceRoot":"","sources":["../../../src/charts/ChartTooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,UAAU,GACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AAQpC,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,qBAAqB,CAAC,EAClE,QAAQ,EACR,MAAM,EACN,KAAK,EACL,cAAc,EACd,GAAG,GACe;IAClB,OAAO,CACL,KAAC,OAAO,IACN,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAC,yBAAyB,YAEnC,KAAC,OAAO,CAAC,OAAO,IAAC,GAAG,EAAE,GA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AS,EAAC,mDAAmD,YAE5D,eAAe,GACL,CACd,IACG,EAEL,aAAa;gBACZ,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;oBACjC,MAAM,EAAE,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,GAC7D,YAAY,CAAC;oBAEf,OAAO,CACL,eAEE,SAAS,EAAE,kEAAkE,gBAAgB,EAAE,aAE/F,KAAC,eAAe,IAAC,OAAO,EAAE,gBAAgB,GAAI,EAC9C,KAAC,UAAU,IACT,OAAO,EAAC,aAAa,EACrB,SAAS,EAAC,4DAA4D,YAErE,cAAc,GACJ,EACb,KAAC,UAAU,IACT,OAAO,EAAC,OAAO,EACf,SAAS,EAAC,gEAAgE,YAEzE,eAAe,GACL,KAfR,gBAAgB,EAAE,EAAE,CAgBrB,CACP,CAAC;gBACJ,CAAC,CAAC,IACA,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,SAAS,kBAAkB,CAAC,EAGb;QAHa,EACnD,GAAG,OAEmC,EADnC,SAAS,cAFuC,OAGpD,CADa;IAEZ,OAAO,KAAC,QAAQ,kBAAC,GAAG,EAAE,GAAG,IAAM,SAAS,EAAI,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;IACxD,OAAO,EAAE,mBAAmB;IAC5B,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,iBAAiB;CACzB,CAAC,CAAC;AAEH,OAAO,EAAE,YAAY,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 */\nimport {\n Popover,\n StatusIndicator,\n TextLink,\n Typography,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport {\n type ChartTooltipContentProps,\n type ChartTooltipProps,\n} from './utils/chart-types';\n\nexport const ChartTooltipComponent = function ChartTooltipComponent({\n children,\n isOpen,\n style,\n anchorPosition,\n ref,\n}: ChartTooltipProps) {\n return (\n <Popover\n isOpen={isOpen}\n anchorPosition={anchorPosition}\n placement=\"middle-end-middle-start\"\n >\n <Popover.Content ref={ref} style={style}>\n {children}\n </Popover.Content>\n </Popover>\n );\n};\n\ntype ChartTooltipTitleProps = {\n children: React.ReactNode;\n /**\n * Color swatch shown before the title, for tooltips where every row below\n * the title belongs to the same series and the rows carry no swatch.\n */\n indentSquareColor?: string;\n ref?: React.Ref<HTMLSpanElement>;\n};\n\nconst ChartTooltipTitle = function ChartTooltipTitle({\n children,\n indentSquareColor,\n ref,\n}: ChartTooltipTitleProps) {\n const classes = classNames(`ndl-charts-chart-tooltip-title`);\n\n const title = (\n <Typography ref={ref} variant=\"body-small\" className={classes}>\n {children}\n </Typography>\n );\n\n if (indentSquareColor === undefined) {\n return title;\n }\n\n return (\n <div className=\"ndl-charts-chart-tooltip-title-line\">\n <div\n className=\"ndl-charts-chart-tooltip-title-indent-square\"\n style={{ backgroundColor: indentSquareColor }}\n />\n {title}\n </div>\n );\n};\n\nconst ChartTooltipContent = function ChartTooltipContent({\n leadingElement,\n trailingElement,\n indentSquareColor,\n notifications,\n ref,\n}: ChartTooltipContentProps) {\n const classes = classNames(`ndl-charts-chart-tooltip-content`);\n\n return (\n <div ref={ref} className={classes}>\n <div className=\"ndl-charts-chart-tooltip-content-line\">\n {indentSquareColor && (\n <div\n className=\"ndl-charts-chart-tooltip-content-indent-square\"\n style={{ backgroundColor: indentSquareColor }}\n />\n )}\n {leadingElement && (\n <Typography\n variant={trailingElement ? 'body-medium' : 'label'}\n className=\"ndl-charts-chart-tooltip-content-left-element\"\n >\n {leadingElement}\n </Typography>\n )}\n {trailingElement && (\n <Typography\n variant=\"label\"\n className=\"ndl-charts-chart-tooltip-content-trailing-element\"\n >\n {trailingElement}\n </Typography>\n )}\n </div>\n\n {notifications &&\n notifications.map((notification) => {\n const { id, notificationType, leadingElement, trailingElement } =\n notification;\n\n return (\n <div\n key={`notification-${id}`}\n className={`ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`}\n >\n <StatusIndicator variant={notificationType} />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-charts-chart-tooltip-content-notification-left-element\"\n >\n {leadingElement}\n </Typography>\n <Typography\n variant=\"label\"\n className=\"ndl-charts-chart-tooltip-content-notification-trailing-element\"\n >\n {trailingElement}\n </Typography>\n </div>\n );\n })}\n </div>\n );\n};\n\nconst ChartTooltipLink = function ChartTooltipAction({\n ref,\n ...restProps\n}: React.ComponentProps<typeof TextLink>) {\n return <TextLink ref={ref} {...restProps} />;\n};\n\nconst ChartTooltip = Object.assign(ChartTooltipComponent, {\n Content: ChartTooltipContent,\n Link: ChartTooltipLink,\n Title: ChartTooltipTitle,\n});\n\nexport { ChartTooltip };\n"]}
|
package/lib/esm/charts/Legend.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
/*!
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) "Neo4j"
|
|
16
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Neo4j.
|
|
19
|
-
*
|
|
20
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU General Public License as published by
|
|
22
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
-
* (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* This program is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*/
|
|
33
|
-
import { useLegendHoverHighlight, useLegendSelection, } from './hooks/use-legend-interactions';
|
|
34
|
-
import { useLegendVisibility } from './hooks/use-legend-visibility';
|
|
35
|
-
import { LegendItem } from './LegendItem';
|
|
36
|
-
import { LegendLayout } from './LegendLayout';
|
|
37
|
-
/**
|
|
38
|
-
* Renders the interactive chart legend and keeps legend state synchronized with
|
|
39
|
-
* ECharts.
|
|
40
|
-
*
|
|
41
|
-
* The component owns the React-side selected-series state, mirrors it into the
|
|
42
|
-
* shared ref consumed when rebuilding chart options, and wires item hover/click
|
|
43
|
-
* interactions back to the ECharts instance.
|
|
44
|
-
*/
|
|
45
|
-
export const Legend = (_a) => {
|
|
46
|
-
var { className, series, isLayoutReady = true, onLayoutReady, htmlAttributes } = _a, restProps = __rest(_a, ["className", "series", "isLayoutReady", "onLayoutReady", "htmlAttributes"]);
|
|
47
|
-
const { renderedSelectedSeries } = useLegendSelection({
|
|
48
|
-
series,
|
|
49
|
-
});
|
|
50
|
-
const { toggleHighlight } = useLegendHoverHighlight({
|
|
51
|
-
selectedSeries: renderedSelectedSeries,
|
|
52
|
-
series,
|
|
53
|
-
});
|
|
54
|
-
const { toggleLegendVisibility } = useLegendVisibility(renderedSelectedSeries);
|
|
55
|
-
const selectedSeriesLength = Object.values(renderedSelectedSeries).filter(Boolean).length;
|
|
56
|
-
const isAllSeriesVisible = selectedSeriesLength === series.length;
|
|
57
|
-
const hasMoreThanOneItem = series.length > 1;
|
|
58
|
-
return (_jsx(LegendLayout, Object.assign({ className: className, isLayoutReady: isLayoutReady, itemCount: series.length, onLayoutReady: onLayoutReady, htmlAttributes: htmlAttributes }, restProps, { children: series.map((currentSeries, index) => {
|
|
59
|
-
var _a, _b, _c;
|
|
60
|
-
return (_jsx(LegendItem, { name: currentSeries.name, color: currentSeries.color, hasButtons: hasMoreThanOneItem && currentSeries.name !== undefined, onLegendItemMouseEnter: () => toggleHighlight(currentSeries, true), onLegendItemMouseLeave: () => toggleHighlight(currentSeries, false), onLegendItemClick: () => {
|
|
61
|
-
var _a;
|
|
62
|
-
const isOnlyVisible = renderedSelectedSeries[(_a = currentSeries.name) !== null && _a !== void 0 ? _a : ''] &&
|
|
63
|
-
selectedSeriesLength === 1;
|
|
64
|
-
toggleLegendVisibility(currentSeries.name, isAllSeriesVisible, isOnlyVisible);
|
|
65
|
-
}, isSelected: !isAllSeriesVisible &&
|
|
66
|
-
renderedSelectedSeries[(_a = currentSeries.name) !== null && _a !== void 0 ? _a : ''], isDeselected: currentSeries.name === undefined
|
|
67
|
-
? false
|
|
68
|
-
: !renderedSelectedSeries[currentSeries.name], children: (_b = currentSeries.name) !== null && _b !== void 0 ? _b : `Series ${index}` }, (_c = currentSeries.name) !== null && _c !== void 0 ? _c : index));
|
|
69
|
-
}) })));
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=Legend.js.map
|
|
@@ -1 +0,0 @@
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AAM,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE;;YAAC,OAAA,CACpC,KAAC,UAAU,IAET,IAAI,EAAE,aAAa,CAAC,IAAI,EACxB,KAAK,EAAE,aAAa,CAAC,KAAK,EAC1B,UAAU,EAAE,kBAAkB,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS,EAClE,sBAAsB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,CAAC,EAClE,sBAAsB,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,aAAa,EAAE,KAAK,CAAC,EACnE,iBAAiB,EAAE,GAAG,EAAE;;oBACtB,MAAM,aAAa,GACjB,sBAAsB,CAAC,MAAA,aAAa,CAAC,IAAI,mCAAI,EAAE,CAAC;wBAChD,oBAAoB,KAAK,CAAC,CAAC;oBAE7B,sBAAsB,CACpB,aAAa,CAAC,IAAI,EAClB,kBAAkB,EAClB,aAAa,CACd,CAAC;gBACJ,CAAC,EACD,UAAU,EACR,CAAC,kBAAkB;oBACnB,sBAAsB,CAAC,MAAA,aAAa,CAAC,IAAI,mCAAI,EAAE,CAAC,EAElD,YAAY,EACV,aAAa,CAAC,IAAI,KAAK,SAAS;oBAC9B,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,CAAC,sBAAsB,CAAC,aAAa,CAAC,IAAI,CAAC,YAGhD,MAAA,aAAa,CAAC,IAAI,mCAAI,UAAU,KAAK,EAAE,IA3BnC,MAAA,aAAa,CAAC,IAAI,mCAAI,KAAK,CA4BrB,CACd,CAAA;SAAA,CAAC,IACW,CAChB,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 {\n useLegendHoverHighlight,\n useLegendSelection,\n} from './hooks/use-legend-interactions';\nimport { useLegendVisibility } from './hooks/use-legend-visibility';\nimport { LegendItem } from './LegendItem';\nimport { LegendLayout } from './LegendLayout';\nimport { type CommonProps, type LegendProps } from './utils/chart-types';\n\ntype LegendComponentProps = LegendProps & {\n isLayoutReady?: boolean;\n onLayoutReady?: () => void;\n};\n\n/**\n * Renders the interactive chart legend and keeps legend state synchronized with\n * ECharts.\n *\n * The component owns the React-side selected-series state, mirrors it into the\n * shared ref consumed when rebuilding chart options, and wires item hover/click\n * interactions back to the ECharts instance.\n */\nexport const Legend = ({\n className,\n series,\n isLayoutReady = true,\n onLayoutReady,\n htmlAttributes,\n ...restProps\n}: Omit<CommonProps<'div', LegendComponentProps>, 'ref'>) => {\n const { renderedSelectedSeries } = useLegendSelection({\n series,\n });\n\n const { toggleHighlight } = useLegendHoverHighlight({\n selectedSeries: renderedSelectedSeries,\n series,\n });\n\n const { toggleLegendVisibility } = useLegendVisibility(\n renderedSelectedSeries,\n );\n\n const selectedSeriesLength = Object.values(renderedSelectedSeries).filter(\n Boolean,\n ).length;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n const hasMoreThanOneItem = series.length > 1;\n\n return (\n <LegendLayout\n className={className}\n isLayoutReady={isLayoutReady}\n itemCount={series.length}\n onLayoutReady={onLayoutReady}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {series.map((currentSeries, index) => (\n <LegendItem\n key={currentSeries.name ?? index}\n name={currentSeries.name}\n color={currentSeries.color}\n hasButtons={hasMoreThanOneItem && currentSeries.name !== undefined}\n onLegendItemMouseEnter={() => toggleHighlight(currentSeries, true)}\n onLegendItemMouseLeave={() => toggleHighlight(currentSeries, false)}\n onLegendItemClick={() => {\n const isOnlyVisible =\n renderedSelectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesVisible,\n isOnlyVisible,\n );\n }}\n isSelected={\n !isAllSeriesVisible &&\n renderedSelectedSeries[currentSeries.name ?? '']\n }\n isDeselected={\n currentSeries.name === undefined\n ? false\n : !renderedSelectedSeries[currentSeries.name]\n }\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n ))}\n </LegendLayout>\n );\n};\n"]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
/*!
|
|
14
|
-
*
|
|
15
|
-
* Copyright (c) "Neo4j"
|
|
16
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Neo4j.
|
|
19
|
-
*
|
|
20
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU General Public License as published by
|
|
22
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
-
* (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* This program is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*/
|
|
33
|
-
import { Typography } from '@neo4j-ndl/react';
|
|
34
|
-
import { CheckIconOutline } from '@neo4j-ndl/react/icons';
|
|
35
|
-
import classNames from 'classnames';
|
|
36
|
-
import { isThresholdLine } from './utils/threshold';
|
|
37
|
-
/**
|
|
38
|
-
* Renders a single legend entry with its series color, selection indicator, and
|
|
39
|
-
* optional button semantics.
|
|
40
|
-
*
|
|
41
|
-
* Threshold-line series are intentionally skipped because they are chart
|
|
42
|
-
* annotations rather than user-toggleable data series.
|
|
43
|
-
*/
|
|
44
|
-
export const LegendItem = (_a) => {
|
|
45
|
-
var _b;
|
|
46
|
-
var { children, as, className, name, isSelected, isDeselected, onLegendItemClick, color, hasButtons = true, ref, onLegendItemMouseEnter, onLegendItemMouseLeave } = _a, restProps = __rest(_a, ["children", "as", "className", "name", "isSelected", "isDeselected", "onLegendItemClick", "color", "hasButtons", "ref", "onLegendItemMouseEnter", "onLegendItemMouseLeave"]);
|
|
47
|
-
const Component = as !== null && as !== void 0 ? as : (hasButtons ? 'button' : 'div');
|
|
48
|
-
const classes = classNames('ndl-chart-legend-item', {
|
|
49
|
-
'ndl-chart-legend-item-deselected': isDeselected,
|
|
50
|
-
'ndl-chart-legend-item-selected': isSelected,
|
|
51
|
-
}, className);
|
|
52
|
-
// We don't want to display threshold lines in the legend
|
|
53
|
-
if ((_b = isThresholdLine(name)) !== null && _b !== void 0 ? _b : false) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
return (_jsxs(Component, Object.assign({ className: classes, ref: ref, "data-labelname": name, title: name, onClick: hasButtons ? onLegendItemClick : undefined, onMouseEnter: onLegendItemMouseEnter, onMouseLeave: onLegendItemMouseLeave }, restProps, { children: [_jsx("span", { className: "ndl-chart-legend-item-square", style: {
|
|
57
|
-
'--ndl-chart-legend-item-color': color,
|
|
58
|
-
backgroundColor: isDeselected === true ? 'transparent' : color,
|
|
59
|
-
}, children: isSelected === true && (_jsx(CheckIconOutline, { className: "ndl-chart-legend-item-square-checkmark" })) }), _jsx(Typography, { variant: "body-medium", className: "ndl-chart-legend-item-text", children: children })] })));
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=LegendItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendItem.js","sourceRoot":"","sources":["../../../src/charts/LegendItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAcT,EAAE,EAAE;;QAdK,EACzB,QAAQ,EACR,EAAE,EACF,SAAS,EACT,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,UAAU,GAAG,IAAI,EACjB,GAAG,EACH,sBAAsB,EACtB,sBAAsB,OAEN,EADb,SAAS,cAba,4KAc1B,CADa;IAEZ,MAAM,SAAS,GAAG,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAExD,MAAM,OAAO,GAAG,UAAU,CACxB,uBAAuB,EACvB;QACE,kCAAkC,EAAE,YAAY;QAChD,gCAAgC,EAAE,UAAU;KAC7C,EACD,SAAS,CACV,CAAC;IAEF,yDAAyD;IACzD,IAAI,MAAA,eAAe,CAAC,IAAI,CAAC,mCAAI,KAAK,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,MAAC,SAAS,kBACR,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,GAAG,oBACQ,IAAI,EACpB,KAAK,EAAE,IAAI,EACX,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EACnD,YAAY,EAAE,sBAAsB,EACpC,YAAY,EAAE,sBAAsB,IAChC,SAAS,eAEb,eACE,SAAS,EAAC,8BAA8B,EACxC,KAAK,EACH;oBACE,+BAA+B,EAAE,KAAK;oBACtC,eAAe,EAAE,YAAY,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK;iBACxC,YAGzB,UAAU,KAAK,IAAI,IAAI,CACtB,KAAC,gBAAgB,IAAC,SAAS,EAAC,wCAAwC,GAAG,CACxE,GACI,EACP,KAAC,UAAU,IAAC,OAAO,EAAC,aAAa,EAAC,SAAS,EAAC,4BAA4B,YACrE,QAAQ,GACE,KACH,CACb,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 { Typography } from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type LegendItemProps } from './utils/chart-types';\nimport { isThresholdLine } from './utils/threshold';\n\n/**\n * Renders a single legend entry with its series color, selection indicator, and\n * optional button semantics.\n *\n * Threshold-line series are intentionally skipped because they are chart\n * annotations rather than user-toggleable data series.\n */\nexport const LegendItem = ({\n children,\n as,\n className,\n name,\n isSelected,\n isDeselected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) => {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': isDeselected,\n 'ndl-chart-legend-item-selected': isSelected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: isDeselected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {isSelected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n"]}
|