@pie-lib/graphing 4.0.23 → 4.0.24-beta.2

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +0 -92
  2. package/lib/mark-label.js +7 -197
  3. package/lib/mark-label.js.map +1 -1
  4. package/lib/tools/circle/component.js +3 -34
  5. package/lib/tools/circle/component.js.map +1 -1
  6. package/lib/tools/point/component.js +8 -29
  7. package/lib/tools/point/component.js.map +1 -1
  8. package/lib/tools/polygon/component.js +6 -31
  9. package/lib/tools/polygon/component.js.map +1 -1
  10. package/lib/tools/shared/line/index.js +3 -34
  11. package/lib/tools/shared/line/index.js.map +1 -1
  12. package/package.json +17 -17
  13. package/src/mark-label.jsx +8 -209
  14. package/src/tools/circle/component.jsx +3 -26
  15. package/src/tools/point/component.jsx +8 -21
  16. package/src/tools/polygon/component.jsx +6 -24
  17. package/src/tools/shared/line/index.jsx +3 -26
  18. package/LICENSE.md +0 -5
  19. package/src/__tests__/bg.test.jsx +0 -250
  20. package/src/__tests__/coordinates-label.test.jsx +0 -243
  21. package/src/__tests__/graph-with-controls.test.jsx +0 -198
  22. package/src/__tests__/graph.test.jsx +0 -796
  23. package/src/__tests__/grid-setup.test.jsx +0 -645
  24. package/src/__tests__/grid.test.jsx +0 -22
  25. package/src/__tests__/key-legend.test.jsx +0 -260
  26. package/src/__tests__/label-svg-icon.test.jsx +0 -278
  27. package/src/__tests__/labels.test.jsx +0 -55
  28. package/src/__tests__/mark-label.test.jsx +0 -437
  29. package/src/__tests__/toggle-bar.test.jsx +0 -146
  30. package/src/__tests__/tool-menu.test.jsx +0 -115
  31. package/src/__tests__/undo-redo.test.jsx +0 -24
  32. package/src/__tests__/use-debounce.test.js +0 -21
  33. package/src/__tests__/utils.js +0 -41
  34. package/src/__tests__/utils.test.js +0 -105
  35. package/src/axis/__tests__/arrow.test.jsx +0 -38
  36. package/src/axis/__tests__/axes.test.jsx +0 -216
  37. package/src/container/__tests__/actions.test.js +0 -105
  38. package/src/container/__tests__/index.test.jsx +0 -319
  39. package/src/container/__tests__/marks.test.js +0 -172
  40. package/src/container/__tests__/middleware.test.js +0 -235
  41. package/src/container/__tests__/reducer.test.js +0 -324
  42. package/src/tools/absolute/__tests__/component.test.jsx +0 -53
  43. package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
  44. package/src/tools/circle/__tests__/component.test.jsx +0 -494
  45. package/src/tools/circle/__tests__/index.test.js +0 -480
  46. package/src/tools/exponential/__tests__/component.test.jsx +0 -53
  47. package/src/tools/exponential/__tests__/index.test.js +0 -729
  48. package/src/tools/line/__tests__/component.test.jsx +0 -37
  49. package/src/tools/parabola/__tests__/component.test.jsx +0 -48
  50. package/src/tools/parabola/__tests__/index.test.js +0 -470
  51. package/src/tools/point/__tests__/component.test.jsx +0 -475
  52. package/src/tools/point/__tests__/index.test.js +0 -241
  53. package/src/tools/polygon/__tests__/component.test.jsx +0 -471
  54. package/src/tools/polygon/__tests__/index.test.js +0 -294
  55. package/src/tools/polygon/__tests__/line.test.jsx +0 -35
  56. package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
  57. package/src/tools/ray/__tests__/component.test.jsx +0 -29
  58. package/src/tools/segment/__tests__/component.test.jsx +0 -28
  59. package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
  60. package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
  61. package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
  62. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
  63. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
  64. package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
  65. package/src/tools/sine/__tests__/component.test.jsx +0 -51
  66. package/src/tools/vector/__tests__/component.test.jsx +0 -25
@@ -1,73 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { rootEdgeComponent, rootEdgeToFromToWrapper } from '../with-root-edge';
4
- import { graphProps as getGraphProps } from '../../../../__tests__/utils';
5
- import { utils } from '@pie-lib/plot';
6
-
7
- const { xy } = utils;
8
- jest.mock('../index', () => {
9
- const out = {
10
- lineBase: jest.fn().mockReturnValue(() => <div />),
11
- lineToolComponent: jest.fn().mockReturnValue(() => <div />),
12
- };
13
- return out;
14
- });
15
-
16
- describe('rootEdgeToToFromWrapper', () => {
17
- let Comp;
18
- let onChange = jest.fn();
19
- beforeEach(() => {
20
- Comp = rootEdgeToFromToWrapper(() => <div />);
21
- });
22
- const renderComponent = (extras) => {
23
- const defaults = {
24
- mark: { root: xy(1, 1), edge: xy(2, 2) },
25
- onChange,
26
- };
27
- const props = { ...defaults, ...extras };
28
- return render(<Comp {...props} />);
29
- };
30
-
31
- it('renders without crashing', () => {
32
- const { container } = renderComponent();
33
- expect(container.firstChild).toBeInTheDocument();
34
- });
35
-
36
- it('passes mark as from/to', () => {
37
- const { container } = renderComponent();
38
- // Component transforms root/edge to from/to internally
39
- expect(container.firstChild).toBeInTheDocument();
40
- });
41
-
42
- it('handles onChange with root/edge transformation', () => {
43
- renderComponent();
44
- // onChange transformation is tested through component behavior
45
- expect(onChange).toBeDefined();
46
- });
47
- });
48
-
49
- describe('rootEdgeComponent', () => {
50
- let onChange = jest.fn();
51
- let Comp;
52
- let mark;
53
- beforeEach(() => {
54
- mark = { root: xy(0, 0), edge: xy(1, 1) };
55
- Comp = rootEdgeComponent(() => <text />);
56
- });
57
- const renderComponent = (extras) => {
58
- const defaults = {
59
- mark,
60
- graphProps: getGraphProps(),
61
- onChange,
62
- };
63
-
64
- const props = { ...defaults, ...extras };
65
- return render(<Comp {...props} />);
66
- };
67
- describe('rendering', () => {
68
- it('renders without crashing', () => {
69
- const { container } = renderComponent();
70
- expect(container.firstChild).toBeInTheDocument();
71
- });
72
- });
73
- });
@@ -1,91 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { ArrowPoint } from '../index';
4
- import { graphProps } from '../../../../__tests__/utils';
5
- import { bounds } from '../../../../utils';
6
- import { gridDraggable, utils } from '@pie-lib/plot';
7
-
8
- const { xy } = utils;
9
- jest.mock('../../../../utils', () => {
10
- const { point, getAngleDeg, arrowDimensions } = jest.requireActual('../../../../utils');
11
- return {
12
- bounds: jest.fn(),
13
- point,
14
- getAngleDeg,
15
- arrowDimensions,
16
- };
17
- });
18
-
19
- jest.mock('@pie-lib/plot', () => {
20
- const { types, utils } = jest.requireActual('@pie-lib/plot');
21
- return {
22
- gridDraggable: jest.fn((opts) => (Comp) => Comp),
23
- types,
24
- utils,
25
- };
26
- });
27
-
28
- describe('ArrowPoint', () => {
29
- let onChange = jest.fn();
30
- const renderComponent = (extras) => {
31
- const defaults = {
32
- classes: {},
33
- className: 'className',
34
- onChange,
35
- graphProps: graphProps(),
36
- from: xy(0, 0),
37
- to: xy(1, 1),
38
- x: 0,
39
- y: 0,
40
- };
41
- const props = { ...defaults, ...extras };
42
- return render(<ArrowPoint {...props} />);
43
- };
44
-
45
- describe('rendering', () => {
46
- it('renders without crashing', () => {
47
- const { container } = renderComponent();
48
- expect(container.firstChild).toBeInTheDocument();
49
- });
50
- });
51
-
52
- describe('gridDraggable options', () => {
53
- let opts;
54
- let domain;
55
- let range;
56
- beforeEach(() => {
57
- domain = {
58
- min: 0,
59
- max: 1,
60
- step: 1,
61
- };
62
- range = {
63
- min: 0,
64
- max: 1,
65
- step: 1,
66
- };
67
- renderComponent();
68
- opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
69
- });
70
-
71
- describe('bounds', () => {
72
- it('calls utils.bounds with area', () => {
73
- const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
74
- expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
75
- });
76
- });
77
- describe('anchorPoint', () => {
78
- it('returns x/y', () => {
79
- const result = opts.anchorPoint({ x: 0, y: 0 });
80
- expect(result).toEqual({ x: 0, y: 0 });
81
- });
82
- });
83
-
84
- describe('fromDelta', () => {
85
- it('returns a new point from the x/y + delta', () => {
86
- const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
87
- expect(result).toEqual({ x: 0, y: 3 });
88
- });
89
- });
90
- });
91
- });
@@ -1,87 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { BasePoint } from '../index';
4
- import { gridDraggable } from '@pie-lib/plot';
5
- import { graphProps } from '../../../../__tests__/utils';
6
- import { bounds } from '../../../../utils';
7
-
8
- jest.mock('../../../../utils', () => {
9
- const { point, thinnerShapesNeeded } = jest.requireActual('../../../../utils');
10
- return {
11
- bounds: jest.fn(),
12
- point,
13
- thinnerShapesNeeded,
14
- };
15
- });
16
-
17
- jest.mock('@pie-lib/plot', () => {
18
- const { types, utils } = jest.requireActual('@pie-lib/plot');
19
- return {
20
- gridDraggable: jest.fn((opts) => (Comp) => Comp),
21
- types,
22
- utils,
23
- };
24
- });
25
-
26
- describe('BasePoint', () => {
27
- let onChange = jest.fn();
28
- const renderComponent = (extras) => {
29
- const defaults = {
30
- classes: {},
31
- className: 'className',
32
- onChange,
33
- graphProps: graphProps(),
34
- x: 0,
35
- y: 0,
36
- };
37
- const props = { ...defaults, ...extras };
38
- return render(<BasePoint {...props} />);
39
- };
40
-
41
- describe('rendering', () => {
42
- it('renders without crashing', () => {
43
- const { container } = renderComponent();
44
- expect(container.firstChild).toBeInTheDocument();
45
- });
46
- });
47
-
48
- describe('gridDraggable options', () => {
49
- let opts;
50
- let domain;
51
- let range;
52
- beforeEach(() => {
53
- domain = {
54
- min: 0,
55
- max: 1,
56
- step: 1,
57
- };
58
- range = {
59
- min: 0,
60
- max: 1,
61
- step: 1,
62
- };
63
- renderComponent();
64
- opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
65
- });
66
-
67
- describe('bounds', () => {
68
- it('calls utils.bounds with area', () => {
69
- const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
70
- expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
71
- });
72
- });
73
- describe('anchorPoint', () => {
74
- it('returns x/y', () => {
75
- const result = opts.anchorPoint({ x: 0, y: 0 });
76
- expect(result).toEqual({ x: 0, y: 0 });
77
- });
78
- });
79
-
80
- describe('fromDelta', () => {
81
- it('returns a new point from the x/y + delta', () => {
82
- const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
83
- expect(result).toEqual({ x: 0, y: 3 });
84
- });
85
- });
86
- });
87
- });
@@ -1,51 +0,0 @@
1
- import { withRootEdge } from '../../shared/line/with-root-edge';
2
- import { buildDataPoints, sinY } from '@pie-lib/graphing-utils';
3
- import { utils } from '@pie-lib/plot';
4
-
5
- import { graphProps as getGraphProps } from '../../../__tests__/utils';
6
-
7
- const { xy } = utils;
8
- jest.mock('@pie-lib/graphing-utils', () => ({
9
- sinY: jest.fn().mockReturnValue(0),
10
- buildDataPoints: jest.fn().mockReturnValue([]),
11
- parabolaFromTwoPoints: jest.fn(() => jest.fn()),
12
- getAmplitudeAndFreq: jest.fn().mockReturnValue({ freq: 4, amplitude: 1 }),
13
- FREQ_DIVIDER: 16,
14
- }));
15
-
16
- jest.mock('../../shared/line/with-root-edge', () => ({
17
- withRootEdge: jest.fn(),
18
- rootEdgeComponent: jest.fn(),
19
- }));
20
- describe('Parabola', () => {
21
- let fnBody;
22
- let graphProps;
23
- let root;
24
- let edge;
25
- let result;
26
- beforeEach(() => {
27
- require('../component');
28
- fnBody = withRootEdge.mock.calls[0][0];
29
- graphProps = getGraphProps();
30
- root = xy(0, 0);
31
- edge = xy(1, 1);
32
-
33
- result = fnBody({ graphProps, root, edge });
34
- });
35
- it('fnBody is not null', () => {
36
- expect(fnBody).toBeDefined();
37
- });
38
-
39
- it('calls buildDataPoints', () => {
40
- const { domain, range } = graphProps;
41
- expect(buildDataPoints).toHaveBeenCalledWith({ ...domain, step: 0.25 }, range, root, edge, expect.anything());
42
- });
43
-
44
- it('calls sinY', () => {
45
- expect(sinY).toHaveBeenCalledWith(1, 4, expect.anything());
46
- });
47
-
48
- it('returns dataPoints', () => {
49
- expect(result).toEqual({ root, edge, dataPoints: [] });
50
- });
51
- });
@@ -1,25 +0,0 @@
1
- import { render } from '@pie-lib/test-utils';
2
- import React from 'react';
3
- import { Line } from '../component';
4
- import { graphProps as getGraphProps } from '../../../__tests__/utils';
5
- import { utils } from '@pie-lib/plot';
6
-
7
- describe('Line', () => {
8
- const renderComponent = (extras) => {
9
- const defaults = {
10
- classes: {},
11
- className: 'className',
12
- graphProps: getGraphProps(),
13
- from: utils.xy(0, 0),
14
- to: utils.xy(1, 1),
15
- };
16
- const props = { ...defaults, ...extras };
17
- return render(<Line {...props} />);
18
- };
19
- describe('rendering', () => {
20
- it('renders without crashing', () => {
21
- const { container } = renderComponent();
22
- expect(container.firstChild).toBeInTheDocument();
23
- });
24
- });
25
- });