@neo4j-ndl/react 3.0.19 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/charts/CartesianGrid.js +49 -15
- package/lib/cjs/charts/CartesianGrid.js.map +1 -1
- package/lib/cjs/charts/Chart.js +62 -60
- package/lib/cjs/charts/Chart.js.map +1 -1
- package/lib/cjs/charts/ChartTooltip.js +5 -6
- package/lib/cjs/charts/ChartTooltip.js.map +1 -1
- package/lib/cjs/charts/Charts.js +33 -13
- package/lib/cjs/charts/Charts.js.map +1 -1
- package/lib/cjs/charts/HollowDot.js +27 -4
- package/lib/cjs/charts/HollowDot.js.map +1 -1
- package/lib/cjs/charts/Line.js +1 -1
- package/lib/cjs/charts/Line.js.map +1 -1
- package/lib/cjs/charts/axis/XAxis.js +205 -0
- package/lib/cjs/charts/axis/XAxis.js.map +1 -0
- package/lib/cjs/charts/axis/YAxis.js +170 -0
- package/lib/cjs/charts/axis/YAxis.js.map +1 -0
- package/lib/cjs/charts/axis/chart-axis-utils.js +42 -0
- package/lib/cjs/charts/axis/chart-axis-utils.js.map +1 -0
- package/lib/cjs/charts/axis/chart-tick-generation.js +245 -0
- package/lib/cjs/charts/axis/chart-tick-generation.js.map +1 -0
- package/lib/cjs/dialog/Dialog.js.map +1 -1
- package/lib/cjs/popover/Popover.js +2 -1
- package/lib/cjs/popover/Popover.js.map +1 -1
- package/lib/cjs/popover/use-popover.js +7 -2
- package/lib/cjs/popover/use-popover.js.map +1 -1
- package/lib/esm/charts/CartesianGrid.js +49 -15
- package/lib/esm/charts/CartesianGrid.js.map +1 -1
- package/lib/esm/charts/Chart.js +63 -61
- package/lib/esm/charts/Chart.js.map +1 -1
- package/lib/esm/charts/ChartTooltip.js +5 -6
- package/lib/esm/charts/ChartTooltip.js.map +1 -1
- package/lib/esm/charts/Charts.js +32 -12
- package/lib/esm/charts/Charts.js.map +1 -1
- package/lib/esm/charts/HollowDot.js +4 -4
- package/lib/esm/charts/HollowDot.js.map +1 -1
- package/lib/esm/charts/Line.js +1 -1
- package/lib/esm/charts/Line.js.map +1 -1
- package/lib/esm/charts/axis/XAxis.js +176 -0
- package/lib/esm/charts/axis/XAxis.js.map +1 -0
- package/lib/esm/charts/axis/YAxis.js +164 -0
- package/lib/esm/charts/axis/YAxis.js.map +1 -0
- package/lib/esm/charts/axis/chart-axis-utils.js +38 -0
- package/lib/esm/charts/axis/chart-axis-utils.js.map +1 -0
- package/lib/esm/charts/axis/chart-tick-generation.js +217 -0
- package/lib/esm/charts/axis/chart-tick-generation.js.map +1 -0
- package/lib/esm/dialog/Dialog.js.map +1 -1
- package/lib/esm/popover/Popover.js +2 -1
- package/lib/esm/popover/Popover.js.map +1 -1
- package/lib/esm/popover/use-popover.js +8 -3
- package/lib/esm/popover/use-popover.js.map +1 -1
- package/lib/types/charts/CartesianGrid.d.ts +3 -1
- package/lib/types/charts/Chart.d.ts +0 -2
- package/lib/types/charts/ChartTooltip.d.ts +4 -1
- package/lib/types/charts/Charts.d.ts +11 -3
- package/lib/types/charts/HollowDot.d.ts +3 -2
- package/lib/types/charts/axis/XAxis.d.ts +28 -0
- package/lib/types/charts/{Axis.d.ts → axis/YAxis.d.ts} +5 -14
- package/lib/types/charts/axis/chart-axis-utils.d.ts +33 -0
- package/lib/types/charts/axis/chart-tick-generation.d.ts +33 -0
- package/lib/types/popover/Popover.d.ts +6 -1
- package/lib/types/popover/use-popover.d.ts +5 -1
- package/package.json +1 -1
- package/lib/cjs/charts/Axis.js +0 -216
- package/lib/cjs/charts/Axis.js.map +0 -1
- package/lib/esm/charts/Axis.js +0 -187
- package/lib/esm/charts/Axis.js.map +0 -1
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.HollowDot = void 0;
|
|
4
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -22,10 +45,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
22
45
|
* You should have received a copy of the GNU General Public License
|
|
23
46
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
47
|
*/
|
|
25
|
-
const react_1 = require("react");
|
|
26
|
-
const
|
|
27
|
-
console.info('
|
|
48
|
+
const react_1 = __importStar(require("react"));
|
|
49
|
+
const HollowDotComponent = (0, react_1.forwardRef)(function HollowDotComponent(props, ref) {
|
|
50
|
+
console.info('HollowDot.tsx - HollowDotComponent - render');
|
|
28
51
|
return ((0, jsx_runtime_1.jsx)("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 12 12", fill: "white" }, props, { ref: ref, x: props.x - 6, y: props.y - 6, className: "ndl-charts-chart-hollow-dot", children: (0, jsx_runtime_1.jsx)("circle", { cx: "6", cy: "6", r: "4.5", stroke: props.color, strokeWidth: "3" }) })));
|
|
29
52
|
});
|
|
30
|
-
exports.HollowDot =
|
|
53
|
+
exports.HollowDot = react_1.default.memo(HollowDotComponent);
|
|
31
54
|
//# sourceMappingURL=HollowDot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HollowDot.js","sourceRoot":"","sources":["../../../src/charts/HollowDot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HollowDot.js","sourceRoot":"","sources":["../../../src/charts/HollowDot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAA0C;AAQ1C,MAAM,kBAAkB,GAAG,IAAA,kBAAU,EACnC,SAAS,kBAAkB,CAAC,KAAK,EAAE,GAAG;IACpC,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC5D,OAAO,CACL,8CACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,OAAO,IACR,KAAK,IACT,GAAG,EAAE,GAAG,EACR,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EACd,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EACd,SAAS,EAAC,6BAA6B,YAEvC,mCAAQ,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,CAAC,EAAC,KAAK,EAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAC,GAAG,GAAG,IACjE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEW,QAAA,SAAS,GAAG,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC"}
|
package/lib/cjs/charts/Line.js
CHANGED
|
@@ -56,7 +56,7 @@ exports.Line = (0, react_1.memo)((0, react_1.forwardRef)(function LineComponent(
|
|
|
56
56
|
const { metadata } = (0, react_1.useContext)(Charts_1.ChartsContext);
|
|
57
57
|
const { scales, linePointArray } = (0, react_1.useContext)(Chart_1.ChartsChartContext);
|
|
58
58
|
if (metadata[dataId].isVisible === false)
|
|
59
|
-
return
|
|
59
|
+
return null;
|
|
60
60
|
const scaleXAxis = scales === null || scales === void 0 ? void 0 : scales[scaleXAxisId].functionWithContentWidthAsRange;
|
|
61
61
|
const scaleYAxis = scales === null || scales === void 0 ? void 0 : scales[scaleYAxisId].functionWithContentHeightAsRange;
|
|
62
62
|
const shouldNotRender = scaleYAxis === undefined || scaleXAxis === undefined || !linePointArray;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.js","sourceRoot":"","sources":["../../../src/charts/Line.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iCAAwE;AACxE,uCAAyB;AACzB,qCAAyD;AACzD,mCAKiB;AACjB,2CAAwC;AA4B3B,QAAA,IAAI,GAAG,IAAA,YAAI,EACtB,IAAA,kBAAU,EAAC,SAAS,aAAa,CAC/B,KAAgB,EAChB,GAAiC;IAEjC,yDAAyD;IAEzD,MAAM,EACJ,MAAM,EACN,UAAU,EAAE,YAAY,EACxB,UAAU,EAAE,YAAY,GACzB,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,kBAAU,EAAC,sBAAa,CAAC,CAAC;IAC/C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,kBAAU,EAAC,0BAAkB,CAAC,CAAC;IAElE,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,KAAK,KAAK;QAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"Line.js","sourceRoot":"","sources":["../../../src/charts/Line.ts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AC,CAAC,SAAS,EAAE,EAAE;oBACpB,MAAM,mBAAmB,GACvB,SAAS,CAAC,iBAAiB,KAAK,SAAS;wBACzC,SAAS,CAAC,SAAS,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;oBAClD,OAAO,mBAAmB,CAAC;gBAC7B,CAAC,CAAC;qBACD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;oBACjB,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAA,sBAAc,EACjD,SAAS,EACT,MAAM,CACP,CAAC;oBACF,OAAO,CACL,uBAAC,qBAAS,IAER,CAAC,EAAE,WAAqB,EACxB,CAAC,EAAE,WAAqB,EACxB,KAAK,EAAE,KAAK,IAHP,cAAc,WAAW,IAAI,WAAW,EAAE,CAI/C,CACH,CAAC;gBACJ,CAAC,CAAC,IACL,CACJ,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.XAxis = void 0;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* Copyright (c) "Neo4j"
|
|
34
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
35
|
+
*
|
|
36
|
+
* This file is part of Neo4j.
|
|
37
|
+
*
|
|
38
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
39
|
+
* it under the terms of the GNU General Public License as published by
|
|
40
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
41
|
+
* (at your option) any later version.
|
|
42
|
+
*
|
|
43
|
+
* This program is distributed in the hope that it will be useful,
|
|
44
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
45
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
46
|
+
* GNU General Public License for more details.
|
|
47
|
+
*
|
|
48
|
+
* You should have received a copy of the GNU General Public License
|
|
49
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
50
|
+
*/
|
|
51
|
+
const react_1 = __importStar(require("react"));
|
|
52
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
53
|
+
const usehooks_ts_1 = require("usehooks-ts");
|
|
54
|
+
const typography_1 = require("../../typography");
|
|
55
|
+
const Chart_1 = require("../Chart");
|
|
56
|
+
const d3 = __importStar(require("d3"));
|
|
57
|
+
const chart_axis_utils_1 = require("./chart-axis-utils");
|
|
58
|
+
const chart_tick_generation_1 = require("./chart-tick-generation");
|
|
59
|
+
const Charts_1 = require("../Charts");
|
|
60
|
+
const domainStrokeWidth = 2;
|
|
61
|
+
const tickLength = domainStrokeWidth + 8;
|
|
62
|
+
const marginBetweenTickAndLabel = tickLength + 8;
|
|
63
|
+
const height = '2';
|
|
64
|
+
const XAxisComponent = (0, react_1.forwardRef)(function XAxis({ position, title, labelFormat: labelFormatProp, scale: scaleId, shouldRotateTicks, }, ref) {
|
|
65
|
+
var _a, _b, _c, _d, _e;
|
|
66
|
+
const classes = (0, react_1.useMemo)(() => (0, classnames_1.default)('ndl-charts-chart-axis', 'ndl-charts-chart-axis-x', {
|
|
67
|
+
'ndl-charts-chart-axis-top': position === 'top',
|
|
68
|
+
'ndl-charts-chart-axis-bottom': position === 'bottom',
|
|
69
|
+
}), [position]);
|
|
70
|
+
const svgRef = (0, react_1.useRef)(null);
|
|
71
|
+
const chartsChartContextValue = (0, react_1.useContext)(Chart_1.ChartsChartContext);
|
|
72
|
+
const setScalerGridLines = (0, react_1.useContext)(Charts_1.ChartsContext).setScalerGridLines;
|
|
73
|
+
const xAxisRef = (0, react_1.useRef)(null);
|
|
74
|
+
const [largestTextWidth, setLargestTextWidth] = (0, react_1.useState)(50);
|
|
75
|
+
const prevDomain = (0, react_1.useRef)([0, 1]);
|
|
76
|
+
const prevRange = (0, react_1.useRef)([0, 1]);
|
|
77
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
78
|
+
const scale = (_a = chartsChartContextValue === null || chartsChartContextValue === void 0 ? void 0 : chartsChartContextValue.scales) === null || _a === void 0 ? void 0 : _a[scaleId];
|
|
79
|
+
const [ticks, setTicks] = (0, react_1.useState)([]);
|
|
80
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
81
|
+
const svgChart = containerRef.current;
|
|
82
|
+
if (!svgChart) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return svgChart;
|
|
86
|
+
});
|
|
87
|
+
const onResize = (0, usehooks_ts_1.useDebounceCallback)(() => {
|
|
88
|
+
var _a;
|
|
89
|
+
// Get text element widths
|
|
90
|
+
const textElements = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('text');
|
|
91
|
+
if (!textElements || textElements.length === 0)
|
|
92
|
+
return;
|
|
93
|
+
// Calculate largest text width
|
|
94
|
+
const textWidths = Array.from(textElements).map((current) => {
|
|
95
|
+
const currentWidth = Math.ceil(current.getBoundingClientRect().width);
|
|
96
|
+
return currentWidth;
|
|
97
|
+
});
|
|
98
|
+
setLargestTextWidth(Math.max(...textWidths));
|
|
99
|
+
// Check for overlapping text elements
|
|
100
|
+
const hasOverlap = Array.from(textElements)
|
|
101
|
+
.slice(0, -1)
|
|
102
|
+
.some((current, i) => {
|
|
103
|
+
const next = textElements[i + 1];
|
|
104
|
+
// Temporarily remove transforms to check raw positions
|
|
105
|
+
const currentTransform = current.style.transform;
|
|
106
|
+
const nextTransform = next.style.transform;
|
|
107
|
+
current.style.transform = '';
|
|
108
|
+
next.style.transform = '';
|
|
109
|
+
// Get bounding boxes
|
|
110
|
+
const currentBox = current.getBoundingClientRect();
|
|
111
|
+
const nextBox = next.getBoundingClientRect();
|
|
112
|
+
// Restore transforms
|
|
113
|
+
current.style.transform = currentTransform;
|
|
114
|
+
next.style.transform = nextTransform;
|
|
115
|
+
// Check for overlap with padding
|
|
116
|
+
const padding = 12;
|
|
117
|
+
return !(currentBox.right < nextBox.left - padding ||
|
|
118
|
+
currentBox.left > nextBox.right + padding ||
|
|
119
|
+
currentBox.bottom < nextBox.top ||
|
|
120
|
+
currentBox.top > nextBox.bottom);
|
|
121
|
+
});
|
|
122
|
+
// Apply rotated or normal styles based on overlap
|
|
123
|
+
const transform = hasOverlap || shouldRotateTicks
|
|
124
|
+
? 'rotate(315deg) translate(-10px, -10px)'
|
|
125
|
+
: 'none';
|
|
126
|
+
const anchor = hasOverlap || shouldRotateTicks ? 'end' : 'middle';
|
|
127
|
+
Array.from(textElements).forEach((el) => {
|
|
128
|
+
el.style.transform = transform;
|
|
129
|
+
el.style.textAnchor = anchor;
|
|
130
|
+
});
|
|
131
|
+
// Update SVG height to fit rotated text
|
|
132
|
+
if (svgRef.current) {
|
|
133
|
+
const maxHeight = Math.max(...Array.from(textElements).map((el) => el.getBoundingClientRect().height));
|
|
134
|
+
svgRef.current.setAttribute('height', `${maxHeight + 12}px`);
|
|
135
|
+
}
|
|
136
|
+
}, 200);
|
|
137
|
+
(0, usehooks_ts_1.useResizeObserver)({
|
|
138
|
+
ref: containerRef,
|
|
139
|
+
onResize: () => onResize(),
|
|
140
|
+
});
|
|
141
|
+
const xScale = scale === null || scale === void 0 ? void 0 : scale.functionWithContentWidthAsRange;
|
|
142
|
+
/* @ts-expect-error we don't have the correct type for the tick values */
|
|
143
|
+
const labelFormat = (0, react_1.useMemo)(() => {
|
|
144
|
+
if (labelFormatProp) {
|
|
145
|
+
return labelFormatProp;
|
|
146
|
+
}
|
|
147
|
+
else if (xScale.domain()[0] instanceof Date &&
|
|
148
|
+
xScale.domain()[1] instanceof Date) {
|
|
149
|
+
return (0, chart_tick_generation_1.getTickLabelFormatterForDate)(xScale.domain()[0], xScale.domain()[1]);
|
|
150
|
+
}
|
|
151
|
+
else if (xScale === undefined) {
|
|
152
|
+
return (dataPoint) => dataPoint.toString();
|
|
153
|
+
}
|
|
154
|
+
return xScale.tickFormat();
|
|
155
|
+
}, [labelFormatProp, xScale]);
|
|
156
|
+
(0, react_1.useEffect)(() => {
|
|
157
|
+
const AxisRefCurrent = xAxisRef.current;
|
|
158
|
+
if (AxisRefCurrent === null || xScale === undefined) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const xAxis = d3
|
|
162
|
+
.axisBottom(xScale)
|
|
163
|
+
.tickValues([xScale.domain()[0], ...xScale.ticks(), xScale.domain()[1]]); // Ensure the start and end ticks
|
|
164
|
+
xAxis.tickPadding(8);
|
|
165
|
+
d3.select(AxisRefCurrent).call(xAxis);
|
|
166
|
+
return () => {
|
|
167
|
+
d3.select(AxisRefCurrent).selectAll('*').remove();
|
|
168
|
+
};
|
|
169
|
+
}, [xScale]);
|
|
170
|
+
const pixelsAvailable = (_c = (_b = chartsChartContextValue.contentSize) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
|
|
171
|
+
(0, react_1.useEffect)(() => {
|
|
172
|
+
const currentDomain = xScale.domain();
|
|
173
|
+
const currentRange = xScale.range();
|
|
174
|
+
const isDomainEqual = prevDomain.current[0] === currentDomain[0] &&
|
|
175
|
+
prevDomain.current[1] === currentDomain[1];
|
|
176
|
+
const isRangeEqual = prevRange.current[0] === currentRange[0] &&
|
|
177
|
+
prevRange.current[1] === currentRange[1];
|
|
178
|
+
if (!isDomainEqual || !isRangeEqual) {
|
|
179
|
+
const newTicks = (0, chart_axis_utils_1.generateAxisTicks)({
|
|
180
|
+
scale: xScale,
|
|
181
|
+
pixelsAvailable,
|
|
182
|
+
largestTickSize: largestTextWidth,
|
|
183
|
+
});
|
|
184
|
+
setScalerGridLines(scaleId, newTicks);
|
|
185
|
+
setTicks(newTicks);
|
|
186
|
+
}
|
|
187
|
+
prevDomain.current = currentDomain;
|
|
188
|
+
prevRange.current = currentRange;
|
|
189
|
+
}, [scale, prevDomain, prevRange]);
|
|
190
|
+
if (xScale === undefined) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: classes, children: [position === 'top' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { className: "ndl-charts-chart-axis-title", variant: "body-medium", children: title })), (0, jsx_runtime_1.jsx)("svg", { ref: svgRef, height: 31, children: (0, jsx_runtime_1.jsxs)("g", { children: [(0, jsx_runtime_1.jsx)("line", { x1: 0, x2: (_e = (_d = svgRef.current) === null || _d === void 0 ? void 0 : _d.getBoundingClientRect().width) !== null && _e !== void 0 ? _e : 0, y1: 0, y2: height, className: "domain" }), ticks.map((tick, index) => {
|
|
194
|
+
const x = xScale(tick);
|
|
195
|
+
return ((0, jsx_runtime_1.jsxs)("g", { className: "tick", transform: `translate(${x} 0)`, children: [(0, jsx_runtime_1.jsx)("text", { y: position === 'bottom'
|
|
196
|
+
? marginBetweenTickAndLabel + tickLength
|
|
197
|
+
: 0, textAnchor: "middle", fill: "currentColor", children: labelFormat(tick) }), (0, jsx_runtime_1.jsx)("line", { y1: position === 'bottom'
|
|
198
|
+
? 0
|
|
199
|
+
: marginBetweenTickAndLabel + tickLength, y2: position === 'bottom'
|
|
200
|
+
? tickLength
|
|
201
|
+
: marginBetweenTickAndLabel, stroke: "currentColor" })] }, index));
|
|
202
|
+
})] }) }), position === 'bottom' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { className: "ndl-charts-chart-axis-title", variant: "body-medium", children: title }))] }));
|
|
203
|
+
});
|
|
204
|
+
exports.XAxis = react_1.default.memo(XAxisComponent);
|
|
205
|
+
//# sourceMappingURL=XAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XAxis.js","sourceRoot":"","sources":["../../../../src/charts/axis/XAxis.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,+CAQe;AACf,4DAAoC;AACpC,6CAAqE;AACrE,iDAA8C;AAC9C,oCAA8C;AAC9C,uCAAyB;AACzB,yDAAsE;AACtE,mEAAuE;AACvE,sCAA0C;AAM1C,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,UAAU,GAAG,iBAAiB,GAAG,CAAC,CAAC;AACzC,MAAM,yBAAyB,GAAG,UAAU,GAAG,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,GAAG,CAAC;AAEnB,MAAM,cAAc,GAAG,IAAA,kBAAU,EAAC,SAAS,KAAK,CAC9C,EACE,QAAQ,EACR,KAAK,EACL,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,OAAO,EACd,iBA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Q,KAAK,QAAQ;4CACnB,CAAC,CAAC,UAAU;4CACZ,CAAC,CAAC,yBAAyB,EAE/B,MAAM,EAAC,cAAc,GACrB,KAxBI,KAAK,CAyBT,CACL,CAAC;wBACJ,CAAC,CAAC,IACA,GACA,EACL,QAAQ,KAAK,QAAQ,IAAI,CACxB,uBAAC,uBAAU,IACT,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAC,aAAa,YAEpB,KAAK,GACK,CACd,IACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEU,QAAA,KAAK,GAAG,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.YAxis = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) "Neo4j"
|
|
11
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
12
|
+
*
|
|
13
|
+
* This file is part of Neo4j.
|
|
14
|
+
*
|
|
15
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
16
|
+
* it under the terms of the GNU General Public License as published by
|
|
17
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
18
|
+
* (at your option) any later version.
|
|
19
|
+
*
|
|
20
|
+
* This program is distributed in the hope that it will be useful,
|
|
21
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
* GNU General Public License for more details.
|
|
24
|
+
*
|
|
25
|
+
* You should have received a copy of the GNU General Public License
|
|
26
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
27
|
+
*/
|
|
28
|
+
const react_1 = require("react");
|
|
29
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
30
|
+
const usehooks_ts_1 = require("usehooks-ts");
|
|
31
|
+
const typography_1 = require("../../typography");
|
|
32
|
+
const Chart_1 = require("../Chart");
|
|
33
|
+
const chart_axis_utils_1 = require("./chart-axis-utils");
|
|
34
|
+
const Charts_1 = require("../Charts");
|
|
35
|
+
exports.YAxis = (0, react_1.forwardRef)(function YAxis({ position, title, labelFormat: labelFormatProp, scale: scaleId, shouldRotateTicks, }, ref) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
const [largestTextWidth, setLargestTextWidth] = (0, react_1.useState)(0);
|
|
38
|
+
const chartsChartContextValue = (0, react_1.useContext)(Chart_1.ChartsChartContext);
|
|
39
|
+
const scale = (_a = chartsChartContextValue === null || chartsChartContextValue === void 0 ? void 0 : chartsChartContextValue.scales) === null || _a === void 0 ? void 0 : _a[scaleId];
|
|
40
|
+
const svgRef = (0, react_1.useRef)(null);
|
|
41
|
+
const prevDomain = (0, react_1.useRef)([0, 1]);
|
|
42
|
+
const prevRange = (0, react_1.useRef)([0, 1]);
|
|
43
|
+
const [ticks, setTicks] = (0, react_1.useState)([]);
|
|
44
|
+
const setScalerGridLines = (0, react_1.useContext)(Charts_1.ChartsContext).setScalerGridLines;
|
|
45
|
+
const classes = (0, react_1.useMemo)(() => (0, classnames_1.default)('ndl-charts-chart-axis', 'ndl-charts-chart-axis-y', {
|
|
46
|
+
'ndl-charts-chart-axis-left': position === 'left',
|
|
47
|
+
'ndl-charts-chart-axis-right': position === 'right',
|
|
48
|
+
}), [position]);
|
|
49
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
50
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
51
|
+
// console.info('Axis.tsx - useImperativeHandle');
|
|
52
|
+
const svgChart = containerRef.current;
|
|
53
|
+
if (!svgChart) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return svgChart;
|
|
57
|
+
});
|
|
58
|
+
const onResize = () => {
|
|
59
|
+
var _a;
|
|
60
|
+
if (svgRef.current === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const textElements = (_a = svgRef.current) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('text');
|
|
64
|
+
if (!textElements) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (shouldRotateTicks) {
|
|
68
|
+
Array.from(textElements).forEach((element) => {
|
|
69
|
+
element.style.transform = `rotate(315deg)`;
|
|
70
|
+
element.style.textAnchor = position === 'left' ? 'end' : 'start';
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
Array.from(textElements).forEach((element) => {
|
|
75
|
+
element.style.transform = '';
|
|
76
|
+
element.style.textAnchor = position === 'left' ? 'end' : 'start';
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// Wait for the rotation transform to be applied
|
|
80
|
+
requestAnimationFrame(() => {
|
|
81
|
+
// Now measure the rotated text widths
|
|
82
|
+
const textWidths = Array.from(textElements).map((element) => {
|
|
83
|
+
const bbox = element.getBoundingClientRect();
|
|
84
|
+
// For rotated text, we need to account for both width and height
|
|
85
|
+
return shouldRotateTicks
|
|
86
|
+
? Math.sqrt(Math.pow(bbox.width, 2) + Math.pow(bbox.height, 2))
|
|
87
|
+
: bbox.width;
|
|
88
|
+
});
|
|
89
|
+
if (textWidths.length === 0) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setLargestTextWidth(Math.max(...textWidths));
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
(0, usehooks_ts_1.useResizeObserver)({
|
|
96
|
+
ref: containerRef,
|
|
97
|
+
onResize,
|
|
98
|
+
});
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
onResize();
|
|
101
|
+
}, [ticks]);
|
|
102
|
+
// the 14 is the height of the tick label, the 8 is the padding
|
|
103
|
+
const pixelsPerTick = 14 * (shouldRotateTicks ? 2 : 1) + 8;
|
|
104
|
+
const pixelsAvailable = (_c = (_b = chartsChartContextValue.contentSize) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 0;
|
|
105
|
+
(0, react_1.useEffect)(() => {
|
|
106
|
+
const currentDomain = yScale.domain();
|
|
107
|
+
const currentRange = yScale.range();
|
|
108
|
+
const isDomainEqual = prevDomain.current[0] === currentDomain[0] &&
|
|
109
|
+
prevDomain.current[1] === currentDomain[1];
|
|
110
|
+
const isRangeEqual = prevRange.current[0] === currentRange[0] &&
|
|
111
|
+
prevRange.current[1] === currentRange[1];
|
|
112
|
+
if (pixelsAvailable === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!isDomainEqual || !isRangeEqual) {
|
|
116
|
+
const newTicks = (0, chart_axis_utils_1.generateAxisTicks)({
|
|
117
|
+
scale: yScale,
|
|
118
|
+
pixelsAvailable,
|
|
119
|
+
largestTickSize: pixelsPerTick,
|
|
120
|
+
});
|
|
121
|
+
setScalerGridLines(scaleId, newTicks);
|
|
122
|
+
setTicks(newTicks);
|
|
123
|
+
prevDomain.current = currentDomain;
|
|
124
|
+
prevRange.current = currentRange;
|
|
125
|
+
}
|
|
126
|
+
}, [scale, prevDomain, prevRange, pixelsAvailable]);
|
|
127
|
+
//const yScale = scale?.function.copy().range(range);
|
|
128
|
+
const yScale = scale === null || scale === void 0 ? void 0 : scale.functionWithContentHeightAsRange;
|
|
129
|
+
//@ts-expect-error - this is a hack to get the yScale to work
|
|
130
|
+
const labelFormat = (0, react_1.useMemo)(() => {
|
|
131
|
+
var _a;
|
|
132
|
+
if (labelFormatProp) {
|
|
133
|
+
return labelFormatProp;
|
|
134
|
+
}
|
|
135
|
+
return (_a = yScale === null || yScale === void 0 ? void 0 : yScale.tickFormat()) !== null && _a !== void 0 ? _a : (() => '');
|
|
136
|
+
}, [labelFormatProp, yScale]);
|
|
137
|
+
/*useEffect(() => {
|
|
138
|
+
requestAnimationFrame(() => {
|
|
139
|
+
const newTicks = generateAxisTicks({
|
|
140
|
+
scale: yScale,
|
|
141
|
+
pixelsAvailable,
|
|
142
|
+
largestTickSize: pixelsPerTick,
|
|
143
|
+
});
|
|
144
|
+
setTicks(newTicks);
|
|
145
|
+
chartsContextValue.setScalerGridLines(scaleId, newTicks);
|
|
146
|
+
});
|
|
147
|
+
}, [
|
|
148
|
+
yScale,
|
|
149
|
+
pixelsAvailable,
|
|
150
|
+
pixelsPerTick,
|
|
151
|
+
position,
|
|
152
|
+
labelFormat,
|
|
153
|
+
chartsContextValue.setScalerGridLines,
|
|
154
|
+
scaleId,
|
|
155
|
+
]);*/
|
|
156
|
+
if (yScale === undefined) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: classes, style: { paddingLeft: '8px', paddingRight: '8px' }, children: [position === 'left' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { className: "ndl-charts-chart-axis-title", variant: "body-medium", children: title })), (0, jsx_runtime_1.jsx)("svg", { style: {
|
|
160
|
+
position: 'relative',
|
|
161
|
+
width: largestTextWidth,
|
|
162
|
+
overflow: 'visible',
|
|
163
|
+
}, ref: svgRef, children: ticks.map((tick) => {
|
|
164
|
+
const y = yScale(tick);
|
|
165
|
+
return ((0, jsx_runtime_1.jsx)("g", { className: "tick", transform: `translate(0 ${y})`, children: (0, jsx_runtime_1.jsx)("text", { textAnchor: position === 'left' ? 'end' : 'start', x: position === 'left' ? '100%' : 0, dy: shouldRotateTicks ? '2.4em' : 0, dx: shouldRotateTicks ? '-1.6em' : 0, style: {
|
|
166
|
+
alignmentBaseline: 'middle',
|
|
167
|
+
}, children: labelFormat(tick) }) }, labelFormat(tick)));
|
|
168
|
+
}) }), position === 'right' && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { className: "ndl-charts-chart-axis-title", variant: "body-medium", children: title }))] }));
|
|
169
|
+
});
|
|
170
|
+
//# sourceM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AI,CAAC,GACb,IAdF,WAAW,CAAC,IAAI,CAAC,CAepB,CACL,CAAC;gBACJ,CAAC,CAAC,GACE,EACL,QAAQ,KAAK,OAAO,IAAI,CACvB,uBAAC,uBAAU,IACT,SAAS,EAAC,6BAA6B,EACvC,OAAO,EAAC,aAAa,YAEpB,KAAK,GACK,CACd,IACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.generateAxisTicks = void 0;
|
|
24
|
+
const chart_tick_generation_1 = require("./chart-tick-generation");
|
|
25
|
+
const generateAxisTicks = ({ scale, pixelsAvailable, largestTickSize, }) => {
|
|
26
|
+
var _a;
|
|
27
|
+
let tickCount = Math.floor(pixelsAvailable / largestTickSize); // Adjust the number of ticks based on width (example logic)
|
|
28
|
+
if (tickCount <= 0) {
|
|
29
|
+
tickCount = 1;
|
|
30
|
+
}
|
|
31
|
+
const domain = scale.domain();
|
|
32
|
+
if (domain[0] instanceof Date || domain[1] instanceof Date) {
|
|
33
|
+
const wilkinsonResult = (0, chart_tick_generation_1.ExtendedWilkinsonDate)([domain[0], domain[1]], tickCount, true);
|
|
34
|
+
return wilkinsonResult.ticks;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const wilkinsonResult = (0, chart_tick_generation_1.ExtendedWilkinson)([domain[0], domain[1]], tickCount, true);
|
|
38
|
+
return (_a = wilkinsonResult.ticks) !== null && _a !== void 0 ? _a : [];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.generateAxisTicks = generateAxisTicks;
|
|
42
|
+
//# sourceMappingURL=chart-axis-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-axis-utils.js","sourceRoot":"","sources":["../../../../src/charts/axis/chart-axis-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAGH,mEAGiC;AAU1B,MAAM,iBAAiB,GAAG,CAAC,EAChC,KAAK,EACL,eAAe,EACf,eAAe,GAKhB,EAAE,EAAE;;IACH,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,4DAA4D;IAC3H,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,SAAS,GAAG,CAAC,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAE9B,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC;QAC3D,MAAM,eAAe,GAAG,IAAA,6CAAqB,EAC3C,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,MAAM,CAAC,CAAC,CAAS,CAAC,EACtC,SAAS,EACT,IAAI,CACL,CAAC;QACF,OAAO,eAAe,CAAC,KAAK,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,MAAM,eAAe,GAAG,IAAA,yCAAiB,EACvC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EACtB,SAAS,EACT,IAAI,CACL,CAAC;QACF,OAAO,MAAA,eAAe,CAAC,KAAK,mCAAI,EAAE,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AA/BW,QAAA,iBAAiB,qBA+B5B"}
|