@neo4j-ndl/react-charts 2.1.21 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/LICENSES.txt +0 -295
- package/lib/NOTICE.txt +1383 -1392
- package/lib/{esm/charts/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.js} +13 -5
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js +46 -0
- package/lib/{esm/charts/tests/ChartWrapperWithTooltipFormatter.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.js} +12 -13
- package/lib/{esm/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.js} +13 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.js +35 -0
- package/lib/{esm/charts/utils/chart-types.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.js} +10 -2
- package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.js +37 -0
- package/lib/cjs/_virtual/_rolldown/runtime.js +44 -0
- package/lib/cjs/charts/Chart.js +121 -111
- package/lib/cjs/charts/Chart.js.map +1 -1
- package/lib/cjs/charts/ChartContainer.js +67 -62
- package/lib/cjs/charts/ChartContainer.js.map +1 -1
- package/lib/cjs/charts/ChartEmpty.js +45 -30
- package/lib/cjs/charts/ChartEmpty.js.map +1 -1
- package/lib/cjs/charts/ChartRender.js +112 -87
- package/lib/cjs/charts/ChartRender.js.map +1 -1
- package/lib/cjs/charts/ChartTooltip.js +111 -65
- package/lib/cjs/charts/ChartTooltip.js.map +1 -1
- package/lib/cjs/charts/Legend.js +81 -69
- package/lib/cjs/charts/Legend.js.map +1 -1
- package/lib/cjs/charts/LegendItem.js +83 -62
- package/lib/cjs/charts/LegendItem.js.map +1 -1
- package/lib/cjs/charts/LegendLayout.js +330 -348
- package/lib/cjs/charts/LegendLayout.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-instance.js +115 -122
- package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-option.js +79 -80
- package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-refs.js +47 -44
- package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -1
- package/lib/cjs/charts/hooks/use-chart-zoom.js +102 -127
- package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-interactions.js +127 -132
- package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-series.js +143 -174
- package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -1
- package/lib/cjs/charts/hooks/use-legend-visibility.js +66 -85
- package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -1
- package/lib/cjs/charts/index.js +31 -40
- package/lib/cjs/charts/index.js.map +1 -1
- package/lib/cjs/charts/themes/ndl-echarts-theme.js +136 -168
- package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
- package/lib/cjs/charts/utils/aria-description.js +150 -214
- package/lib/cjs/charts/utils/aria-description.js.map +1 -1
- package/lib/cjs/charts/utils/build-chart-option.js +166 -174
- package/lib/cjs/charts/utils/build-chart-option.js.map +1 -1
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js +156 -172
- package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -1
- package/lib/cjs/charts/utils/chart-types.js +25 -20
- package/lib/cjs/charts/utils/chart-types.js.map +1 -1
- package/lib/cjs/charts/utils/defaults.js +69 -67
- package/lib/cjs/charts/utils/defaults.js.map +1 -1
- package/lib/cjs/charts/utils/format-utils.js +55 -66
- package/lib/cjs/charts/utils/format-utils.js.map +1 -1
- package/lib/cjs/charts/utils/legend-layout.js +54 -53
- package/lib/cjs/charts/utils/legend-layout.js.map +1 -1
- package/lib/cjs/charts/utils/legend-utils.js +82 -121
- package/lib/cjs/charts/utils/legend-utils.js.map +1 -1
- package/lib/cjs/charts/utils/scatter-tooltip-points.js +191 -266
- package/lib/cjs/charts/utils/scatter-tooltip-points.js.map +1 -1
- package/lib/cjs/charts/utils/threshold.js +89 -102
- package/lib/cjs/charts/utils/threshold.js.map +1 -1
- package/lib/cjs/charts/utils/user-option-utils.js +419 -347
- package/lib/cjs/charts/utils/user-option-utils.js.map +1 -1
- package/lib/cjs/index.js +31 -35
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs +24 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs +12 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.mjs +11 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.mjs +13 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.mjs +8 -0
- package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.mjs +10 -0
- package/lib/esm/charts/Chart.mjs +123 -0
- package/lib/esm/charts/Chart.mjs.map +1 -0
- package/lib/esm/charts/ChartContainer.mjs +71 -0
- package/lib/esm/charts/ChartContainer.mjs.map +1 -0
- package/lib/esm/charts/ChartEmpty.mjs +46 -0
- package/lib/esm/charts/ChartEmpty.mjs.map +1 -0
- package/lib/esm/charts/ChartRender.mjs +113 -0
- package/lib/esm/charts/ChartRender.mjs.map +1 -0
- package/lib/esm/charts/ChartTooltip.mjs +109 -0
- package/lib/esm/charts/ChartTooltip.mjs.map +1 -0
- package/lib/esm/charts/Legend.mjs +82 -0
- package/lib/esm/charts/Legend.mjs.map +1 -0
- package/lib/esm/charts/LegendItem.mjs +82 -0
- package/lib/esm/charts/LegendItem.mjs.map +1 -0
- package/lib/esm/charts/LegendLayout.mjs +337 -0
- package/lib/esm/charts/LegendLayout.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs +119 -0
- package/lib/esm/charts/hooks/use-chart-instance.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs +79 -0
- package/lib/esm/charts/hooks/use-chart-option.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs +49 -0
- package/lib/esm/charts/hooks/use-chart-refs.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs +102 -0
- package/lib/esm/charts/hooks/use-chart-zoom.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs +138 -0
- package/lib/esm/charts/hooks/use-legend-interactions.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs +151 -0
- package/lib/esm/charts/hooks/use-legend-series.mjs.map +1 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs +67 -0
- package/lib/esm/charts/hooks/use-legend-visibility.mjs.map +1 -0
- package/lib/esm/charts/index.mjs +27 -0
- package/lib/esm/charts/index.mjs.map +1 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs +139 -0
- package/lib/esm/charts/themes/ndl-echarts-theme.mjs.map +1 -0
- package/lib/esm/charts/utils/aria-description.mjs +162 -0
- package/lib/esm/charts/utils/aria-description.mjs.map +1 -0
- package/lib/esm/charts/utils/build-chart-option.mjs +184 -0
- package/lib/esm/charts/utils/build-chart-option.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs +159 -0
- package/lib/esm/charts/utils/chart-tooltip-formatter.mjs.map +1 -0
- package/lib/esm/charts/utils/chart-types.mjs +24 -0
- package/lib/esm/charts/utils/chart-types.mjs.map +1 -0
- package/lib/esm/charts/utils/defaults.mjs +73 -0
- package/lib/esm/charts/utils/defaults.mjs.map +1 -0
- package/lib/esm/charts/utils/format-utils.mjs +61 -0
- package/lib/esm/charts/utils/format-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-layout.mjs +57 -0
- package/lib/esm/charts/utils/legend-layout.mjs.map +1 -0
- package/lib/esm/charts/utils/legend-utils.mjs +90 -0
- package/lib/esm/charts/utils/legend-utils.mjs.map +1 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs +215 -0
- package/lib/esm/charts/utils/scatter-tooltip-points.mjs.map +1 -0
- package/lib/esm/charts/utils/threshold.mjs +92 -0
- package/lib/esm/charts/utils/threshold.mjs.map +1 -0
- package/lib/esm/charts/utils/user-option-utils.mjs +445 -0
- package/lib/esm/charts/utils/user-option-utils.mjs.map +1 -0
- package/lib/esm/index.mjs +27 -0
- package/lib/esm/index.mjs.map +1 -0
- package/package.json +12 -16
- package/skills/ndl-react-charts/SKILL.md +2 -2
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js +0 -38
- package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/cjs/charts/tests/ChartZoomHarness.js +0 -113
- package/lib/cjs/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js +0 -78
- package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/cjs/charts/tests/PieChartWithRerender.js +0 -46
- package/lib/cjs/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/cjs/charts/tests/chart-test-utils.js +0 -527
- package/lib/cjs/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/Chart.js +0 -114
- package/lib/esm/charts/Chart.js.map +0 -1
- package/lib/esm/charts/ChartContainer.js +0 -67
- package/lib/esm/charts/ChartContainer.js.map +0 -1
- package/lib/esm/charts/ChartEmpty.js +0 -33
- package/lib/esm/charts/ChartEmpty.js.map +0 -1
- package/lib/esm/charts/ChartRender.js +0 -89
- package/lib/esm/charts/ChartRender.js.map +0 -1
- package/lib/esm/charts/ChartTooltip.js +0 -64
- package/lib/esm/charts/ChartTooltip.js.map +0 -1
- package/lib/esm/charts/Legend.js +0 -71
- package/lib/esm/charts/Legend.js.map +0 -1
- package/lib/esm/charts/LegendItem.js +0 -61
- package/lib/esm/charts/LegendItem.js.map +0 -1
- package/lib/esm/charts/LegendLayout.js +0 -323
- package/lib/esm/charts/LegendLayout.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-instance.js +0 -128
- package/lib/esm/charts/hooks/use-chart-instance.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-option.js +0 -82
- package/lib/esm/charts/hooks/use-chart-option.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-refs.js +0 -48
- package/lib/esm/charts/hooks/use-chart-refs.js.map +0 -1
- package/lib/esm/charts/hooks/use-chart-zoom.js +0 -129
- package/lib/esm/charts/hooks/use-chart-zoom.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-interactions.js +0 -145
- package/lib/esm/charts/hooks/use-legend-interactions.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-series.js +0 -184
- package/lib/esm/charts/hooks/use-legend-series.js.map +0 -1
- package/lib/esm/charts/hooks/use-legend-visibility.js +0 -87
- package/lib/esm/charts/hooks/use-legend-visibility.js.map +0 -1
- package/lib/esm/charts/index.js.map +0 -1
- package/lib/esm/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
- package/lib/esm/charts/tests/ChartZoomHarness.js +0 -109
- package/lib/esm/charts/tests/ChartZoomHarness.js.map +0 -1
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js +0 -74
- package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
- package/lib/esm/charts/tests/PieChartWithRerender.js +0 -43
- package/lib/esm/charts/tests/PieChartWithRerender.js.map +0 -1
- package/lib/esm/charts/tests/chart-test-utils.js +0 -500
- package/lib/esm/charts/tests/chart-test-utils.js.map +0 -1
- package/lib/esm/charts/themes/ndl-echarts-theme.js +0 -172
- package/lib/esm/charts/themes/ndl-echarts-theme.js.map +0 -1
- package/lib/esm/charts/utils/aria-description.js +0 -228
- package/lib/esm/charts/utils/aria-description.js.map +0 -1
- package/lib/esm/charts/utils/build-chart-option.js +0 -193
- package/lib/esm/charts/utils/build-chart-option.js.map +0 -1
- package/lib/esm/charts/utils/chart-tooltip-formatter.js +0 -177
- package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +0 -1
- package/lib/esm/charts/utils/chart-types.js.map +0 -1
- package/lib/esm/charts/utils/defaults.js +0 -73
- package/lib/esm/charts/utils/defaults.js.map +0 -1
- package/lib/esm/charts/utils/format-utils.js +0 -74
- package/lib/esm/charts/utils/format-utils.js.map +0 -1
- package/lib/esm/charts/utils/legend-layout.js +0 -59
- package/lib/esm/charts/utils/legend-layout.js.map +0 -1
- package/lib/esm/charts/utils/legend-utils.js +0 -131
- package/lib/esm/charts/utils/legend-utils.js.map +0 -1
- package/lib/esm/charts/utils/scatter-tooltip-points.js +0 -291
- package/lib/esm/charts/utils/scatter-tooltip-points.js.map +0 -1
- package/lib/esm/charts/utils/threshold.js +0 -106
- package/lib/esm/charts/utils/threshold.js.map +0 -1
- package/lib/esm/charts/utils/user-option-utils.js +0 -374
- package/lib/esm/charts/utils/user-option-utils.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
|
@@ -1,38 +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
|
-
"use strict";
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.ChartWrapperWithTooltipFormatter = ChartWrapperWithTooltipFormatter;
|
|
25
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
26
|
-
const Chart_1 = require("../Chart");
|
|
27
|
-
/** Chart Wrapper is required to get a valid tooltip formatter for the chart
|
|
28
|
-
* This is to do with the way Playwright mounts components for testing.
|
|
29
|
-
* https://playwright.dev/docs/test-components#test-stories
|
|
30
|
-
*/
|
|
31
|
-
function ChartWrapperWithTooltipFormatter(props) {
|
|
32
|
-
return ((0, jsx_runtime_1.jsx)(Chart_1.Chart, Object.assign({}, props, { option: {
|
|
33
|
-
tooltip: {
|
|
34
|
-
valueFormatter: (value) => `formatted ${value}`,
|
|
35
|
-
},
|
|
36
|
-
} })));
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=ChartWrapperWithTooltipFormatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartWrapperWithTooltipFormatter.js","sourceRoot":"","sources":["../../../../src/charts/tests/ChartWrapperWithTooltipFormatter.tsx"],"names":[],"mappings":";;AA4BA,4EAaC;;AAnBD,oCAAiC;AACjC;;;GAGG;AAEH,SAAgB,gCAAgC,CAC9C,KAAmC;IAEnC,OAAO,CACL,uBAAC,aAAK,oBACA,KAAK,IACT,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,aAAa,KAAK,EAAE;aACzD;SACF,IACD,CACH,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 { type ComponentProps } from 'react';\n\nimport { Chart } from '../Chart';\n/** Chart Wrapper is required to get a valid tooltip formatter for the chart\n * This is to do with the way Playwright mounts components for testing.\n * https://playwright.dev/docs/test-components#test-stories\n */\n\nexport function ChartWrapperWithTooltipFormatter(\n props: ComponentProps<typeof Chart>,\n): React.JSX.Element {\n return (\n <Chart\n {...props}\n option={{\n tooltip: {\n valueFormatter: (value: unknown) => `formatted ${value}`,\n },\n }}\n />\n );\n}\n"]}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChartZoomHarness = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
/*!
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) "Neo4j"
|
|
8
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
9
|
-
*
|
|
10
|
-
* This file is part of Neo4j.
|
|
11
|
-
*
|
|
12
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
13
|
-
* it under the terms of the GNU General Public License as published by
|
|
14
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
15
|
-
* (at your option) any later version.
|
|
16
|
-
*
|
|
17
|
-
* This program is distributed in the hope that it will be useful,
|
|
18
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
* GNU General Public License for more details.
|
|
21
|
-
*
|
|
22
|
-
* You should have received a copy of the GNU General Public License
|
|
23
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
*/
|
|
25
|
-
const react_charts_1 = require("@neo4j-ndl/react-charts");
|
|
26
|
-
const echarts_1 = require("echarts");
|
|
27
|
-
const react_1 = require("react");
|
|
28
|
-
const POINT_COUNT = 180;
|
|
29
|
-
const zoomHarnessDataset = [
|
|
30
|
-
['time', 'value'],
|
|
31
|
-
...Array.from({ length: POINT_COUNT }, (_unused, index) => [
|
|
32
|
-
index,
|
|
33
|
-
Number((40 + Math.sin(index / 6) * 12).toFixed(2)),
|
|
34
|
-
]),
|
|
35
|
-
];
|
|
36
|
-
const defaultOption = {
|
|
37
|
-
dataZoom: [
|
|
38
|
-
{
|
|
39
|
-
filterMode: 'none',
|
|
40
|
-
type: 'inside',
|
|
41
|
-
zoomOnMouseWheel: false,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
toolbox: {
|
|
45
|
-
feature: {
|
|
46
|
-
dataZoom: {
|
|
47
|
-
yAxisIndex: false,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Reproduces the consumer setup from the metrics UI: a chart with toolbox
|
|
54
|
-
* brush-zoom whose parent re-renders while the chart stays mounted, passing a
|
|
55
|
-
* freshly built `option` object on every render.
|
|
56
|
-
*
|
|
57
|
-
* `option` and `seriesType` swap in other zoom setups, such as a scatter
|
|
58
|
-
* chart with one slider per axis.
|
|
59
|
-
*/
|
|
60
|
-
const ChartZoomHarness = ({ option = defaultOption, seriesType = 'line', settings, }) => {
|
|
61
|
-
const containerRef = (0, react_1.useRef)(null);
|
|
62
|
-
const zoomCallsRef = (0, react_1.useRef)([]);
|
|
63
|
-
const [, setRerenderCount] = (0, react_1.useState)(0);
|
|
64
|
-
const handleZoom = (0, react_1.useCallback)((zoom) => {
|
|
65
|
-
zoomCallsRef.current = [...zoomCallsRef.current, zoom];
|
|
66
|
-
}, []);
|
|
67
|
-
(0, react_1.useEffect)(() => {
|
|
68
|
-
const getChart = () => {
|
|
69
|
-
var _a;
|
|
70
|
-
const echartElement = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.ndl-chart-echart');
|
|
71
|
-
return echartElement instanceof HTMLElement
|
|
72
|
-
? (0, echarts_1.getInstanceByDom)(echartElement)
|
|
73
|
-
: undefined;
|
|
74
|
-
};
|
|
75
|
-
window.chartZoomHarness = {
|
|
76
|
-
getAppliedZoomWindows: () => {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
const dataZoom = (_b = (_a = getChart()) === null || _a === void 0 ? void 0 : _a.getOption()) === null || _b === void 0 ? void 0 : _b.dataZoom;
|
|
79
|
-
return (dataZoom !== null && dataZoom !== void 0 ? dataZoom : [])
|
|
80
|
-
.filter((item) => (item === null || item === void 0 ? void 0 : item.startValue) !== undefined && item.endValue !== undefined)
|
|
81
|
-
.map((item) => ({
|
|
82
|
-
endValue: item.endValue,
|
|
83
|
-
startValue: item.startValue,
|
|
84
|
-
}));
|
|
85
|
-
},
|
|
86
|
-
getZoomCalls: () => zoomCallsRef.current,
|
|
87
|
-
pixelToValue: (pixelX) => { var _a; return (_a = getChart()) === null || _a === void 0 ? void 0 : _a.convertFromPixel({ xAxisIndex: 0 }, pixelX); },
|
|
88
|
-
resetZoomCalls: () => {
|
|
89
|
-
zoomCallsRef.current = [];
|
|
90
|
-
},
|
|
91
|
-
zoomTo: (dataZoomId, start, end) => {
|
|
92
|
-
var _a;
|
|
93
|
-
(_a = getChart()) === null || _a === void 0 ? void 0 : _a.dispatchAction({
|
|
94
|
-
dataZoomId,
|
|
95
|
-
end,
|
|
96
|
-
start,
|
|
97
|
-
type: 'dataZoom',
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}, []);
|
|
102
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, style: { height: '420px', width: '900px' }, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", "data-testid": "force-rerender", onClick: () => setRerenderCount((count) => count + 1), children: "Re-render" }), (0, jsx_runtime_1.jsx)("div", { className: "ndl-chart", style: { height: '380px', width: '100%' }, children: (0, jsx_runtime_1.jsx)(react_charts_1.Chart, { callbacks: { onZoom: handleZoom }, dataset: [{ source: zoomHarnessDataset }], series: [
|
|
103
|
-
{
|
|
104
|
-
// E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
|
|
105
|
-
// oxlint-disable-next-line id-length
|
|
106
|
-
encode: { x: 'time', y: 'value' },
|
|
107
|
-
name: 'Value',
|
|
108
|
-
type: seriesType,
|
|
109
|
-
},
|
|
110
|
-
], settings: settings, xAxis: { type: 'value' }, yAxis: { type: 'value' }, option: structuredClone(option) }) })] }));
|
|
111
|
-
};
|
|
112
|
-
exports.ChartZoomHarness = ChartZoomHarness;
|
|
113
|
-
//# sourceMappingURL=ChartZoomHarness.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartZoomHarness.js","sourceRoot":"","sources":["../../../../src/charts/tests/ChartZoomHarness.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0DAAgD;AAChD,qCAA2C;AAC3C,iCAMe;AA8Bf,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,kBAAkB,GAAG;IACzB,CAAC,MAAM,EAAE,OAAO,CAAC;IACjB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,KAAK;QACL,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAA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AAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,0BAG9C,EACT,gCAAK,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAClE,uBAAC,oBAAK,IACJ,SAAS,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EACjC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,EACzC,MAAM,EAAE;wBACN;4BACE,qGAAqG;4BACrG,qCAAqC;4BACrC,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE;4BACjC,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,UAAU;yBACjB;qBACF,EACD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EACxB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EACxB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAC/B,GACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAhGW,QAAA,gBAAgB,oBAgG3B","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 { Chart } from '@neo4j-ndl/react-charts';\nimport { getInstanceByDom } from 'echarts';\nimport {\n type ComponentProps,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport type { ChartZoomEntry } from '../utils/chart-types';\n\ntype ChartComponentProps = ComponentProps<typeof Chart>;\ntype ChartSettings = ChartComponentProps['settings'];\nexport type ChartOption = ChartComponentProps['option'];\n\nexport type ZoomCall = {\n dataZoom: ChartZoomEntry[];\n endValue: number;\n startValue: number;\n};\n\nexport type ZoomWindow = { endValue: number; startValue: number };\n\nexport type ZoomHarnessApi = {\n /** Applied zoom windows, in data values, as ECharts currently has them. */\n getAppliedZoomWindows: () => ZoomWindow[];\n /** Every `callbacks.onZoom` invocation the consumer received. */\n getZoomCalls: () => ZoomCall[];\n /** Data value at a pixel offset inside the chart element. */\n pixelToValue: (pixelX: number) => number;\n resetZoomCalls: () => void;\n /** Applies a zoom window, in percent, to one `dataZoom` entry by its `id`. */\n zoomTo: (dataZoomId: string, start: number, end: number) => void;\n};\n\ntype HarnessWindow = Window & { chartZoomHarness?: ZoomHarnessApi };\n\nconst POINT_COUNT = 180;\n\nconst zoomHarnessDataset = [\n ['time', 'value'],\n ...Array.from({ length: POINT_COUNT }, (_unused, index) => [\n index,\n Number((40 + Math.sin(index / 6) * 12).toFixed(2)),\n ]),\n];\n\nconst defaultOption: ChartOption = {\n dataZoom: [\n {\n filterMode: 'none',\n type: 'inside',\n zoomOnMouseWheel: false,\n },\n ],\n toolbox: {\n feature: {\n dataZoom: {\n yAxisIndex: false,\n },\n },\n },\n};\n\n/**\n * Reproduces the consumer setup from the metrics UI: a chart with toolbox\n * brush-zoom whose parent re-renders while the chart stays mounted, passing a\n * freshly built `option` object on every render.\n *\n * `option` and `seriesType` swap in other zoom setups, such as a scatter\n * chart with one slider per axis.\n */\nexport const ChartZoomHarness = ({\n option = defaultOption,\n seriesType = 'line',\n settings,\n}: {\n option?: ChartOption;\n seriesType?: 'line' | 'scatter';\n settings?: ChartSettings;\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const zoomCallsRef = useRef<ZoomCall[]>([]);\n const [, setRerenderCount] = useState(0);\n\n const handleZoom = useCallback((zoom: ZoomCall) => {\n zoomCallsRef.current = [...zoomCallsRef.current, zoom];\n }, []);\n\n useEffect(() => {\n const getChart = () => {\n const echartElement =\n containerRef.current?.querySelector('.ndl-chart-echart');\n return echartElement instanceof HTMLElement\n ? getInstanceByDom(echartElement)\n : undefined;\n };\n\n (window as HarnessWindow).chartZoomHarness = {\n getAppliedZoomWindows: () => {\n const dataZoom = (\n getChart()?.getOption() as\n | {\n dataZoom?: ({\n endValue?: number;\n startValue?: number;\n } | null)[];\n }\n | undefined\n )?.dataZoom;\n\n return (dataZoom ?? [])\n .filter(\n (item): item is ZoomWindow =>\n item?.startValue !== undefined && item.endValue !== undefined,\n )\n .map((item) => ({\n endValue: item.endValue as number,\n startValue: item.startValue as number,\n }));\n },\n getZoomCalls: () => zoomCallsRef.current,\n pixelToValue: (pixelX: number) =>\n getChart()?.convertFromPixel({ xAxisIndex: 0 }, pixelX) as number,\n resetZoomCalls: () => {\n zoomCallsRef.current = [];\n },\n zoomTo: (dataZoomId: string, start: number, end: number) => {\n getChart()?.dispatchAction({\n dataZoomId,\n end,\n start,\n type: 'dataZoom',\n });\n },\n };\n }, []);\n\n return (\n <div ref={containerRef} style={{ height: '420px', width: '900px' }}>\n <button\n type=\"button\"\n data-testid=\"force-rerender\"\n onClick={() => setRerenderCount((count) => count + 1)}\n >\n Re-render\n </button>\n <div className=\"ndl-chart\" style={{ height: '380px', width: '100%' }}>\n <Chart\n callbacks={{ onZoom: handleZoom }}\n dataset={[{ source: zoomHarnessDataset }]}\n series={[\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'time', y: 'value' },\n name: 'Value',\n type: seriesType,\n },\n ]}\n settings={settings}\n xAxis={{ type: 'value' }}\n yAxis={{ type: 'value' }}\n option={structuredClone(option)}\n />\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HorizontalBarWithVerticalSlider = exports.verticalSliderCategories = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
/*!
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) "Neo4j"
|
|
8
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
9
|
-
*
|
|
10
|
-
* This file is part of Neo4j.
|
|
11
|
-
*
|
|
12
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
13
|
-
* it under the terms of the GNU General Public License as published by
|
|
14
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
15
|
-
* (at your option) any later version.
|
|
16
|
-
*
|
|
17
|
-
* This program is distributed in the hope that it will be useful,
|
|
18
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
* GNU General Public License for more details.
|
|
21
|
-
*
|
|
22
|
-
* You should have received a copy of the GNU General Public License
|
|
23
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
*/
|
|
25
|
-
const react_charts_1 = require("@neo4j-ndl/react-charts");
|
|
26
|
-
const echarts_1 = require("echarts");
|
|
27
|
-
const react_1 = require("react");
|
|
28
|
-
exports.verticalSliderCategories = [
|
|
29
|
-
'Friday',
|
|
30
|
-
'Saturday',
|
|
31
|
-
'Sunday',
|
|
32
|
-
'Monday',
|
|
33
|
-
'Tuesday',
|
|
34
|
-
'Wednesday',
|
|
35
|
-
'Thursday',
|
|
36
|
-
'Friday II',
|
|
37
|
-
];
|
|
38
|
-
const dataset = [
|
|
39
|
-
{
|
|
40
|
-
dimensions: ['day', 'First'],
|
|
41
|
-
source: exports.verticalSliderCategories.map((day, index) => [
|
|
42
|
-
day,
|
|
43
|
-
10 + index * 12,
|
|
44
|
-
]),
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
const getChart = () => {
|
|
48
|
-
const element = document.querySelector('.ndl-chart-echart');
|
|
49
|
-
return element instanceof HTMLElement ? (0, echarts_1.getInstanceByDom)(element) : undefined;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Horizontal bar chart (value x-axis, category y-axis) with a slider bound to
|
|
53
|
-
* the category axis, which Needle lays out as a vertical slider on the right.
|
|
54
|
-
*/
|
|
55
|
-
const HorizontalBarWithVerticalSlider = () => {
|
|
56
|
-
(0, react_1.useEffect)(() => {
|
|
57
|
-
window.verticalSliderHarness = {
|
|
58
|
-
getResolvedLayout: () => {
|
|
59
|
-
var _a, _b, _c, _d, _e;
|
|
60
|
-
const option = (_a = getChart()) === null || _a === void 0 ? void 0 : _a.getOption();
|
|
61
|
-
return {
|
|
62
|
-
grid: (_c = (_b = option === null || option === void 0 ? void 0 : option.grid) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : {},
|
|
63
|
-
slider: (_e = (_d = option === null || option === void 0 ? void 0 : option.dataZoom) === null || _d === void 0 ? void 0 : _d[0]) !== null && _e !== void 0 ? _e : {},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
zoomTo: (start, end) => {
|
|
67
|
-
var _a;
|
|
68
|
-
(_a = getChart()) === null || _a === void 0 ? void 0 : _a.dispatchAction({ end, start, type: 'dataZoom' });
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}, []);
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { height: '420px', width: '760px' }, children: (0, jsx_runtime_1.jsx)(react_charts_1.Chart, { dataset: dataset, series: [
|
|
73
|
-
// oxlint-disable-next-line
|
|
74
|
-
{ encode: { x: 'First', y: 'day' }, name: 'First', type: 'bar' },
|
|
75
|
-
], xAxis: { type: 'value' }, yAxis: { type: 'category' }, option: { dataZoom: [{ type: 'slider', yAxisIndex: [0] }] } }) }));
|
|
76
|
-
};
|
|
77
|
-
exports.HorizontalBarWithVerticalSlider = HorizontalBarWithVerticalSlider;
|
|
78
|
-
//# sourceMappingURL=HorizontalBarWithVerticalSlider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HorizontalBarWithVerticalSlider.js","sourceRoot":"","sources":["../../../../src/charts/tests/HorizontalBarWithVerticalSlider.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0DAAgD;AAChD,qCAA2C;AAC3C,iCAAkC;AAErB,QAAA,wBAAwB,GAAG;IACtC,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,WAAW;IACX,UAAU;IACV,WAAW;CACZ,CAAC;AAEF,MAAM,OAAO,GAAG;IACd;QACE,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;QAC5B,MAAM,EAAE,gCAAwB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;YACnD,GAAG;YACH,EAAE,GAAG,KAAK,GAAG,EAAE;SAChB,CAAC;KACH;CACF,CAAC;AAgBF,MAAM,QAAQ,GAAG,GAAG,EAAE;IACpB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC5D,OAAO,OAAO,YAAY,WAAW,CAAC,CAAC,CAAC,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACZ,MAAwB,CAAC,qBAAqB,GAAG;YAChD,iBAAiB,EAAE,GAAG,EAAE;;gBACtB,MAAM,MAAM,GAAG,MAAA,QAAQ,EAAE,0CAAE,SAAS,EAKvB,CAAC;gBAEd,OAAO;oBACL,IAAI,EAAE,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAG,CAAC,CAAC,mCAAI,EAAE;oBAC7B,MAAM,EAAE,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAG,CAAC,CAAC,mCAAI,EAAE;iBACpC,CAAC;YACJ,CAAC;YACD,MAAM,EAAE,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;;gBACrC,MAAA,QAAQ,EAAE,0CAAE,cAAc,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;YAC/D,CAAC;SACF,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,gCAAK,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,YAC7C,uBAAC,oBAAK,IACJ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE;gBACN,2BAA2B;gBAC3B,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;aACjE,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EACxB,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAC3B,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAC3D,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,+BAA+B,mCAoC1C","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 { Chart } from '@neo4j-ndl/react-charts';\nimport { getInstanceByDom } from 'echarts';\nimport { useEffect } from 'react';\n\nexport const verticalSliderCategories = [\n 'Friday',\n 'Saturday',\n 'Sunday',\n 'Monday',\n 'Tuesday',\n 'Wednesday',\n 'Thursday',\n 'Friday II',\n];\n\nconst dataset = [\n {\n dimensions: ['day', 'First'],\n source: verticalSliderCategories.map((day, index) => [\n day,\n 10 + index * 12,\n ]),\n },\n];\n\nexport type VerticalSliderHarnessApi = {\n /** Resolved layout of the first dataZoom component and the grid. */\n getResolvedLayout: () => {\n grid: { right?: number | string };\n slider: Record<string, unknown>;\n };\n /** Applies a zoom window through the slider's dataZoom action. */\n zoomTo: (start: number, end: number) => void;\n};\n\ntype HarnessWindow = Window & {\n verticalSliderHarness?: VerticalSliderHarnessApi;\n};\n\nconst getChart = () => {\n const element = document.querySelector('.ndl-chart-echart');\n return element instanceof HTMLElement ? getInstanceByDom(element) : undefined;\n};\n\n/**\n * Horizontal bar chart (value x-axis, category y-axis) with a slider bound to\n * the category axis, which Needle lays out as a vertical slider on the right.\n */\nexport const HorizontalBarWithVerticalSlider = () => {\n useEffect(() => {\n (window as HarnessWindow).verticalSliderHarness = {\n getResolvedLayout: () => {\n const option = getChart()?.getOption() as\n | {\n dataZoom?: Record<string, unknown>[];\n grid?: { right?: number | string }[];\n }\n | undefined;\n\n return {\n grid: option?.grid?.[0] ?? {},\n slider: option?.dataZoom?.[0] ?? {},\n };\n },\n zoomTo: (start: number, end: number) => {\n getChart()?.dispatchAction({ end, start, type: 'dataZoom' });\n },\n };\n }, []);\n\n return (\n <div style={{ height: '420px', width: '760px' }}>\n <Chart\n dataset={dataset}\n series={[\n // oxlint-disable-next-line\n { encode: { x: 'First', y: 'day' }, name: 'First', type: 'bar' },\n ]}\n xAxis={{ type: 'value' }}\n yAxis={{ type: 'category' }}\n option={{ dataZoom: [{ type: 'slider', yAxisIndex: [0] }] }}\n />\n </div>\n );\n};\n"]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PieChartWithRerenderComponent = PieChartWithRerenderComponent;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
/*!
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) "Neo4j"
|
|
8
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
9
|
-
*
|
|
10
|
-
* This file is part of Neo4j.
|
|
11
|
-
*
|
|
12
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
13
|
-
* it under the terms of the GNU General Public License as published by
|
|
14
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
15
|
-
* (at your option) any later version.
|
|
16
|
-
*
|
|
17
|
-
* This program is distributed in the hope that it will be useful,
|
|
18
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
* GNU General Public License for more details.
|
|
21
|
-
*
|
|
22
|
-
* You should have received a copy of the GNU General Public License
|
|
23
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
-
*/
|
|
25
|
-
const react_charts_1 = require("@neo4j-ndl/react-charts");
|
|
26
|
-
const react_1 = require("react");
|
|
27
|
-
function PieChartWithRerenderComponent({ dataset1, dataset2, datasetNewCategories, }) {
|
|
28
|
-
const [renderCount, setRenderCount] = (0, react_1.useState)(0);
|
|
29
|
-
const [shouldUseNewCategories, setShouldUseNewCategories] = (0, react_1.useState)(false);
|
|
30
|
-
const chartRenderCount = (0, react_1.useRef)(0);
|
|
31
|
-
chartRenderCount.current += 1;
|
|
32
|
-
const currentDataset = shouldUseNewCategories
|
|
33
|
-
? datasetNewCategories
|
|
34
|
-
: renderCount % 2 === 0
|
|
35
|
-
? dataset1
|
|
36
|
-
: dataset2;
|
|
37
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '8px', marginBottom: '12px' }, children: [(0, jsx_runtime_1.jsx)("button", { type: "button", "data-testid": "rerender-button", onClick: () => setRenderCount((count) => count + 1), children: "Re-render" }), (0, jsx_runtime_1.jsx)("button", { type: "button", "data-testid": "switch-categories-button", onClick: () => setShouldUseNewCategories((value) => !value), children: "Switch categories" }), (0, jsx_runtime_1.jsx)("span", { "data-testid": "render-count", children: chartRenderCount.current })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: '350px', width: '100%' }, children: (0, jsx_runtime_1.jsx)(react_charts_1.Chart, { legend: { isVisible: true }, series: [
|
|
38
|
-
{
|
|
39
|
-
center: ['50%', '50%'],
|
|
40
|
-
encode: { itemName: 'product', value: '2015' },
|
|
41
|
-
radius: '90%',
|
|
42
|
-
type: 'pie',
|
|
43
|
-
},
|
|
44
|
-
], dataset: currentDataset }) })] }));
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=PieChartWithRerender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PieChartWithRerender.js","sourceRoot":"","sources":["../../../../src/charts/tests/PieChartWithRerender.tsx"],"names":[],"mappings":";;AA+BA,sEAmDC;;AAlFD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0DAAgD;AAEhD,iCAAyC;AAQzC,SAAgB,6BAA6B,CAAC,EAC5C,QAAQ,EACR,QAAQ,EACR,oBAAoB,GACM;IAC1B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAClD,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC5E,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC,CAAC,CAAC,CAAC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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 { Chart } from '@neo4j-ndl/react-charts';\nimport type { EChartsOption } from 'echarts';\nimport { useRef, useState } from 'react';\n\ntype PieChartWithRerenderProps = {\n dataset1: EChartsOption['dataset'];\n dataset2: EChartsOption['dataset'];\n datasetNewCategories: EChartsOption['dataset'];\n};\n\nexport function PieChartWithRerenderComponent({\n dataset1,\n dataset2,\n datasetNewCategories,\n}: PieChartWithRerenderProps) {\n const [renderCount, setRenderCount] = useState(0);\n const [shouldUseNewCategories, setShouldUseNewCategories] = useState(false);\n const chartRenderCount = useRef(0);\n chartRenderCount.current += 1;\n\n const currentDataset = shouldUseNewCategories\n ? datasetNewCategories\n : renderCount % 2 === 0\n ? dataset1\n : dataset2;\n\n return (\n <div>\n <div style={{ display: 'flex', gap: '8px', marginBottom: '12px' }}>\n <button\n type=\"button\"\n data-testid=\"rerender-button\"\n onClick={() => setRenderCount((count) => count + 1)}\n >\n Re-render\n </button>\n <button\n type=\"button\"\n data-testid=\"switch-categories-button\"\n onClick={() => setShouldUseNewCategories((value) => !value)}\n >\n Switch categories\n </button>\n <span data-testid=\"render-count\">{chartRenderCount.current}</span>\n </div>\n <div style={{ height: '350px', width: '100%' }}>\n <Chart\n legend={{ isVisible: true }}\n series={[\n {\n center: ['50%', '50%'],\n encode: { itemName: 'product', value: '2015' },\n radius: '90%',\n type: 'pie',\n },\n ]}\n dataset={currentDataset}\n />\n </div>\n </div>\n );\n}\n"]}
|