@recharts/devtools 0.0.3 → 0.0.5
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/README.md +50 -21
- package/dist/components/RechartsDevtools.js +58 -0
- package/dist/components/useEventDispatch.js +11 -0
- package/dist/constants.js +1 -0
- package/dist/context/RechartsDevtoolsContext.d.ts +8 -0
- package/dist/context/RechartsDevtoolsContext.js +19 -0
- package/dist/generateMockData.js +14 -0
- package/dist/hooks/useSessionStorageState.d.ts +7 -0
- package/dist/hooks/useSessionStorageState.js +28 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/{src/inspectors → inspectors}/ActiveTooltipLabelInspector.d.ts +1 -1
- package/dist/inspectors/ActiveTooltipLabelInspector.js +12 -0
- package/dist/{src/inspectors → inspectors}/ChartDimensionInspector.d.ts +1 -1
- package/dist/inspectors/ChartDimensionInspector.js +18 -0
- package/dist/{src/inspectors → inspectors}/MarginInspector.d.ts +1 -1
- package/dist/inspectors/MarginInspector.js +37 -0
- package/dist/{src/inspectors → inspectors}/OffsetInspector.d.ts +1 -1
- package/dist/inspectors/OffsetInspector.js +39 -0
- package/dist/{src/inspectors → inspectors}/PlotAreaInspector.d.ts +1 -1
- package/dist/inspectors/PlotAreaInspector.js +30 -0
- package/dist/{src/inspectors → inspectors}/UseActiveTooltipDataPointsInspector.d.ts +1 -1
- package/dist/inspectors/UseActiveTooltipDataPointsInspector.js +12 -0
- package/dist/{src/inspectors → inspectors}/XAxisDomainInspector.d.ts +1 -1
- package/dist/inspectors/XAxisDomainInspector.js +12 -0
- package/dist/{src/inspectors → inspectors}/YAxisDomainInspector.d.ts +1 -1
- package/dist/inspectors/YAxisDomainInspector.js +12 -0
- package/dist/inspectors/generic/ArrayInspector.js +27 -0
- package/dist/inspectors/generic/ObjectInspector.js +43 -0
- package/dist/inspectors/generic/PrimitiveInspector.js +8 -0
- package/dist/inspectors/utils/SvgDimensionShower.js +60 -0
- package/dist/{src/random.js → random.js} +2 -6
- package/package.json +11 -8
- package/dist/src/components/RechartsDevtools.js +0 -80
- package/dist/src/components/useEventDispatch.js +0 -14
- package/dist/src/constants.js +0 -4
- package/dist/src/generateMockData.js +0 -17
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -20
- package/dist/src/inspectors/ActiveTooltipLabelInspector.js +0 -18
- package/dist/src/inspectors/ChartDimensionInspector.js +0 -24
- package/dist/src/inspectors/MarginInspector.js +0 -43
- package/dist/src/inspectors/OffsetInspector.js +0 -45
- package/dist/src/inspectors/PlotAreaInspector.js +0 -36
- package/dist/src/inspectors/UseActiveTooltipDataPointsInspector.js +0 -18
- package/dist/src/inspectors/XAxisDomainInspector.js +0 -18
- package/dist/src/inspectors/YAxisDomainInspector.js +0 -18
- package/dist/src/inspectors/generic/ArrayInspector.js +0 -63
- package/dist/src/inspectors/generic/ObjectInspector.js +0 -77
- package/dist/src/inspectors/generic/PrimitiveInspector.js +0 -15
- package/dist/src/inspectors/utils/SvgDimensionShower.js +0 -66
- package/dist/src/types.js +0 -2
- package/dist/test/generateMockData.spec.js +0 -27
- package/dist/test/random.spec.d.ts +0 -1
- package/dist/test/random.spec.js +0 -30
- /package/dist/{src/components → components}/RechartsDevtools.d.ts +0 -0
- /package/dist/{src/components → components}/useEventDispatch.d.ts +0 -0
- /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/{src/generateMockData.d.ts → generateMockData.d.ts} +0 -0
- /package/dist/{src/inspectors → inspectors}/generic/ArrayInspector.d.ts +0 -0
- /package/dist/{src/inspectors → inspectors}/generic/ObjectInspector.d.ts +0 -0
- /package/dist/{src/inspectors → inspectors}/generic/PrimitiveInspector.d.ts +0 -0
- /package/dist/{src/inspectors → inspectors}/utils/SvgDimensionShower.d.ts +0 -0
- /package/dist/{src/random.d.ts → random.d.ts} +0 -0
- /package/dist/{src/types.d.ts → types.d.ts} +0 -0
- /package/dist/{test/generateMockData.spec.d.ts → types.js} +0 -0
|
@@ -1,66 +0,0 @@
|
|
|
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.SvgDimensionShower = SvgDimensionShower;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
/**
|
|
9
|
-
* Renders a line with arrows on left and right.
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
function HorizontalLineWithArrows({ x1, x2, y, label, stroke = 'black', }) {
|
|
13
|
-
const strokeWidth = 2;
|
|
14
|
-
const arrowSize = 7;
|
|
15
|
-
const width = x2 - x1;
|
|
16
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
17
|
-
react_1.default.createElement("line", { x1: x1, y1: y, x2: x2, y2: y, stroke: stroke, strokeWidth: strokeWidth }),
|
|
18
|
-
react_1.default.createElement("line", { x1: x1, y1: y, x2: x1 + arrowSize, y2: y - arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
19
|
-
react_1.default.createElement("line", { x1: x1, y1: y, x2: x1 + arrowSize, y2: y + arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
20
|
-
react_1.default.createElement("line", { x1: x2, y1: y, x2: x2 - arrowSize, y2: y - arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
21
|
-
react_1.default.createElement("line", { x1: x2, y1: y, x2: x2 - arrowSize, y2: y + arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
22
|
-
react_1.default.createElement("text", { x: width * 0.9, y: y + 8, textAnchor: "end", dominantBaseline: "hanging", stroke: "red" }, label)));
|
|
23
|
-
}
|
|
24
|
-
function Background({ width, height, label, }) {
|
|
25
|
-
const patternId = `pattern+${label.replace(/\s+/g, '-')}`;
|
|
26
|
-
return (react_1.default.createElement("svg", { width: width, height: height, style: { position: 'absolute', top: 0, left: 0 } },
|
|
27
|
-
react_1.default.createElement("defs", null,
|
|
28
|
-
react_1.default.createElement("pattern", { id: patternId, x: 0, y: 0, width: 120, height: 50, patternUnits: "userSpaceOnUse", patternTransform: "rotate(30)" },
|
|
29
|
-
react_1.default.createElement("text", { x: 0, y: 10, fontSize: 24, stroke: "#eee", fill: "#eee", dominantBaseline: "hanging" }, label.toUpperCase()))),
|
|
30
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: width, height: height, fill: `url(#${patternId})` })));
|
|
31
|
-
}
|
|
32
|
-
function VerticalLineWithArrows({ x, y1, y2, label, stroke = 'black', }) {
|
|
33
|
-
const strokeWidth = 2;
|
|
34
|
-
const arrowSize = 7;
|
|
35
|
-
const height = y2 - y1;
|
|
36
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
37
|
-
react_1.default.createElement("line", { x1: x, y1: y1, x2: x, y2: y2, stroke: stroke, strokeWidth: strokeWidth }),
|
|
38
|
-
react_1.default.createElement("line", { x1: x, y1: y1, x2: x - arrowSize, y2: y1 + arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
39
|
-
react_1.default.createElement("line", { x1: x, y1: y1, x2: x + arrowSize, y2: y1 + arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
40
|
-
react_1.default.createElement("line", { x1: x, y1: y2, x2: x - arrowSize, y2: y2 - arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
41
|
-
react_1.default.createElement("line", { x1: x, y1: y2, x2: x + arrowSize, y2: y2 - arrowSize, stroke: stroke, strokeWidth: strokeWidth }),
|
|
42
|
-
react_1.default.createElement("text", { x: x + 8, y: height * 0.7, textAnchor: "start", dominantBaseline: "middle", stroke: "blue" }, label)));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Creates a label for the horizontal line.
|
|
46
|
-
* It will trim information to save space if the width is too small.
|
|
47
|
-
* @param width number of pixels to display
|
|
48
|
-
* @param label description of the width
|
|
49
|
-
* @return the label to display
|
|
50
|
-
*/
|
|
51
|
-
function makeHorizontalLabel(width, label) {
|
|
52
|
-
if (width < 50) {
|
|
53
|
-
return String(width);
|
|
54
|
-
}
|
|
55
|
-
if (width < 100) {
|
|
56
|
-
return `${width}px`;
|
|
57
|
-
}
|
|
58
|
-
return `${label}: ${width}px`;
|
|
59
|
-
}
|
|
60
|
-
function SvgDimensionShower({ x = 0, y = 0, width, height, labels, }) {
|
|
61
|
-
return (react_1.default.createElement("svg", { width: width, height: height, x: x, y: y, style: { pointerEvents: 'none' } },
|
|
62
|
-
react_1.default.createElement(Background, { width: width, height: height, label: labels.background }),
|
|
63
|
-
react_1.default.createElement("rect", { x: 0, y: 0, width: width, height: height, fill: "none", stroke: "green", strokeWidth: 5, strokeDasharray: "3 3" }),
|
|
64
|
-
labels.horizontal && (react_1.default.createElement(HorizontalLineWithArrows, { x1: 0, y: height * 0.15, x2: width, stroke: "red", label: makeHorizontalLabel(width, labels.horizontal) })),
|
|
65
|
-
labels.vertical && (react_1.default.createElement(VerticalLineWithArrows, { x: width * 0.1, y1: 0, y2: height, stroke: "blue", label: `${labels.vertical}: ${height}px` }))));
|
|
66
|
-
}
|
package/dist/src/types.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const generateMockData_1 = require("../src/generateMockData");
|
|
4
|
-
describe('generateMockData', () => {
|
|
5
|
-
test('should generate data with correct length', () => {
|
|
6
|
-
const data = (0, generateMockData_1.generateMockData)(10, 123);
|
|
7
|
-
expect(data).toHaveLength(10);
|
|
8
|
-
});
|
|
9
|
-
test('should be deterministic with same seed', () => {
|
|
10
|
-
const data1 = (0, generateMockData_1.generateMockData)(5, 456);
|
|
11
|
-
const data2 = (0, generateMockData_1.generateMockData)(5, 456);
|
|
12
|
-
expect(data1).toEqual(data2);
|
|
13
|
-
});
|
|
14
|
-
test('should generate different data with different seeds', () => {
|
|
15
|
-
const data1 = (0, generateMockData_1.generateMockData)(5, 456);
|
|
16
|
-
const data2 = (0, generateMockData_1.generateMockData)(5, 789);
|
|
17
|
-
expect(data1).not.toEqual(data2);
|
|
18
|
-
});
|
|
19
|
-
test('should have expected structure', () => {
|
|
20
|
-
const data = (0, generateMockData_1.generateMockData)(1, 100);
|
|
21
|
-
const item = data[0];
|
|
22
|
-
expect(item).toHaveProperty('label');
|
|
23
|
-
expect(item).toHaveProperty('x');
|
|
24
|
-
expect(item).toHaveProperty('y');
|
|
25
|
-
expect(item).toHaveProperty('z');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/test/random.spec.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const random_1 = require("../src/random");
|
|
4
|
-
describe('random', () => {
|
|
5
|
-
test.each([
|
|
6
|
-
[0.1, 7574, 43828, 10324, 53467, 12342, 8206, 25691, 26326, 8414, 41291],
|
|
7
|
-
[0.2, 15074, 16495, 57533, 55144, 7043, 4003, 38151, 43308, 36861, 12095],
|
|
8
|
-
[0.3, 22574, 54699, 39205, 56821, 1744, 65337, 50611, 60290, 65308, 48436],
|
|
9
|
-
[0, 74, 5624, 28652, 51790, 17641, 12409, 13231, 9344, 45504, 4950],
|
|
10
|
-
[-5, 65236, 43036, 16461, 54983, 60505, 15896, 12608, 28156, 14590, 45732],
|
|
11
|
-
])('should provide pseudorandom numbers for seed %d', (seed, ...numbers) => {
|
|
12
|
-
const gen = (0, random_1.random)(seed);
|
|
13
|
-
numbers.forEach(n => {
|
|
14
|
-
expect(gen.next().value).toBe(n);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('between', () => {
|
|
19
|
-
test.each([
|
|
20
|
-
[100, 5, 10, 5],
|
|
21
|
-
[100, 5, 17, 9],
|
|
22
|
-
[101, 5, 17, 10],
|
|
23
|
-
])('should take a generator %d and boundaries <%d, %d> and return %d', (value, min, max, expected) => {
|
|
24
|
-
function* gen() {
|
|
25
|
-
yield value;
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
expect((0, random_1.between)(gen(), min, max)).toBe(expected);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|