@pie-lib/graphing 3.1.0-next.5 → 3.1.1-next.1
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/NEXT.CHANGELOG.json +16 -1
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +9 -6
- package/lib/bg.js.map +1 -1
- package/lib/container/index.js +4 -4
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +3 -4
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +8 -9
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js.map +1 -1
- package/lib/key-legend.js +1 -1
- package/lib/key-legend.js.map +1 -1
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +2 -2
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/point/component.js +3 -4
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/polygon/component.js +5 -7
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +7 -9
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +9 -13
- package/lib/utils.js.map +1 -1
- package/package.json +14 -14
- package/src/__tests__/bg.test.jsx +250 -0
- package/src/__tests__/coordinates-label.test.jsx +243 -0
- package/src/__tests__/graph-with-controls.test.jsx +46 -12
- package/src/__tests__/graph.test.jsx +560 -5
- package/src/__tests__/grid-setup.test.jsx +645 -0
- package/src/__tests__/grid.test.jsx +1 -1
- package/src/__tests__/key-legend.test.jsx +260 -0
- package/src/__tests__/label-svg-icon.test.jsx +278 -0
- package/src/__tests__/mark-label.test.jsx +1 -1
- package/src/__tests__/toggle-bar.test.jsx +38 -3
- package/src/__tests__/tool-menu.test.jsx +38 -1
- package/src/__tests__/use-debounce.test.js +1 -1
- package/src/__tests__/utils.test.js +15 -61
- package/src/axis/__tests__/axes.test.jsx +1 -1
- package/src/axis/axes.jsx +7 -21
- package/src/axis/index.js +1 -0
- package/src/bg.jsx +5 -5
- package/src/container/__tests__/actions.test.js +105 -0
- package/src/container/__tests__/index.test.jsx +319 -0
- package/src/container/__tests__/marks.test.js +172 -0
- package/src/container/__tests__/middleware.test.js +235 -0
- package/src/container/__tests__/reducer.test.js +324 -0
- package/src/container/index.jsx +2 -3
- package/src/coordinates-label.jsx +1 -7
- package/src/graph-with-controls.jsx +8 -6
- package/src/graph.jsx +2 -3
- package/src/grid-setup.jsx +1 -1
- package/src/key-legend.jsx +2 -1
- package/src/mark-label.jsx +7 -24
- package/src/toggle-bar.jsx +8 -1
- package/src/tools/absolute/__tests__/component.test.jsx +1 -2
- package/src/tools/absolute/component.jsx +2 -2
- package/src/tools/circle/__tests__/component.test.jsx +438 -0
- package/src/tools/circle/__tests__/index.test.js +480 -0
- package/src/tools/circle/bg-circle.jsx +2 -2
- package/src/tools/circle/component.jsx +10 -12
- package/src/tools/exponential/__tests__/component.test.jsx +0 -1
- package/src/tools/exponential/__tests__/index.test.js +729 -0
- package/src/tools/exponential/component.jsx +1 -1
- package/src/tools/line/__tests__/component.test.jsx +1 -0
- package/src/tools/line/component.jsx +4 -11
- package/src/tools/parabola/__tests__/component.test.jsx +0 -1
- package/src/tools/parabola/__tests__/index.test.js +470 -0
- package/src/tools/parabola/component.jsx +1 -1
- package/src/tools/point/__tests__/component.test.jsx +310 -2
- package/src/tools/point/__tests__/index.test.js +241 -0
- package/src/tools/point/component.jsx +1 -2
- package/src/tools/polygon/__tests__/component.test.jsx +391 -2
- package/src/tools/polygon/__tests__/index.test.js +237 -8
- package/src/tools/polygon/__tests__/line.test.jsx +13 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +19 -1
- package/src/tools/polygon/component.jsx +4 -14
- package/src/tools/polygon/line.jsx +1 -1
- package/src/tools/polygon/polygon.jsx +1 -1
- package/src/tools/ray/__tests__/component.test.jsx +1 -0
- package/src/tools/ray/component.jsx +3 -5
- package/src/tools/segment/__tests__/component.test.jsx +1 -0
- package/src/tools/segment/component.jsx +1 -1
- package/src/tools/shared/arrow-head.jsx +11 -6
- package/src/tools/shared/line/__tests__/index.test.jsx +1 -1
- package/src/tools/shared/line/__tests__/line-path.test.jsx +3 -3
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +2 -2
- package/src/tools/shared/line/index.jsx +4 -6
- package/src/tools/shared/line/line-path.jsx +2 -8
- package/src/tools/shared/point/arrow-point.jsx +2 -5
- package/src/tools/sine/component.jsx +2 -2
- package/src/tools/vector/component.jsx +1 -1
- package/src/undo-redo.jsx +3 -9
- package/src/use-debounce.js +1 -1
- package/src/utils.js +1 -5
|
@@ -18,5 +18,18 @@ describe('Line', () => {
|
|
|
18
18
|
const { container } = renderComponent();
|
|
19
19
|
expect(container.firstChild).toBeInTheDocument();
|
|
20
20
|
});
|
|
21
|
+
|
|
22
|
+
it('renders with from and to points', () => {
|
|
23
|
+
const { container } = renderComponent({
|
|
24
|
+
from: { x: 0, y: 0 },
|
|
25
|
+
to: { x: 5, y: 5 },
|
|
26
|
+
});
|
|
27
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders with className', () => {
|
|
31
|
+
const { container } = renderComponent({ className: 'custom-line' });
|
|
32
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
33
|
+
});
|
|
21
34
|
});
|
|
22
35
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render } from '@pie-lib/test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { getPointString, Polygon } from '../polygon';
|
|
4
4
|
import { graphProps } from '../../../__tests__/utils';
|
|
5
5
|
|
|
6
6
|
const xy = (x, y) => ({ x, y });
|
|
@@ -22,6 +22,24 @@ describe('Polygon', () => {
|
|
|
22
22
|
const { container } = renderComponent({ points: [{ x: 1, y: 1 }] });
|
|
23
23
|
expect(container.firstChild).toBeInTheDocument();
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
it('renders multiple points', () => {
|
|
27
|
+
const points = [xy(0, 0), xy(1, 1), xy(2, 0)];
|
|
28
|
+
const { container } = renderComponent({ points });
|
|
29
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders closed polygon', () => {
|
|
33
|
+
const points = [xy(0, 0), xy(1, 1), xy(2, 0)];
|
|
34
|
+
const { container } = renderComponent({ points, closed: true });
|
|
35
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders open polygon', () => {
|
|
39
|
+
const points = [xy(0, 0), xy(1, 1)];
|
|
40
|
+
const { container } = renderComponent({ points, closed: false });
|
|
41
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
42
|
+
});
|
|
25
43
|
});
|
|
26
44
|
});
|
|
27
45
|
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ToolPropTypeFields } from '../shared/types';
|
|
4
4
|
import { BasePoint } from '../shared/point';
|
|
5
|
-
import chunk from 'lodash
|
|
6
|
-
import initial from 'lodash/initial';
|
|
5
|
+
import { chunk, initial, isEmpty } from 'lodash-es';
|
|
7
6
|
import debug from 'debug';
|
|
8
7
|
import Line from './line';
|
|
9
8
|
import DraggablePolygon, { Polygon } from './polygon';
|
|
@@ -11,8 +10,7 @@ import { types } from '@pie-lib/plot';
|
|
|
11
10
|
import invariant from 'invariant';
|
|
12
11
|
import ReactDOM from 'react-dom';
|
|
13
12
|
import MarkLabel from '../../mark-label';
|
|
14
|
-
import
|
|
15
|
-
import { getMiddleOfTwoPoints, getRightestPoints, equalPoints } from '../../utils';
|
|
13
|
+
import { equalPoints, getMiddleOfTwoPoints, getRightestPoints } from '../../utils';
|
|
16
14
|
|
|
17
15
|
const log = debug('pie-lib:graphing:polygon');
|
|
18
16
|
|
|
@@ -366,16 +364,8 @@ export default class Component extends React.Component {
|
|
|
366
364
|
};
|
|
367
365
|
|
|
368
366
|
render() {
|
|
369
|
-
const {
|
|
370
|
-
|
|
371
|
-
mark,
|
|
372
|
-
graphProps,
|
|
373
|
-
onClick,
|
|
374
|
-
isToolActive,
|
|
375
|
-
labelNode,
|
|
376
|
-
labelModeEnabled,
|
|
377
|
-
limitLabeling,
|
|
378
|
-
} = this.props;
|
|
367
|
+
const { coordinatesOnHover, mark, graphProps, onClick, isToolActive, labelNode, labelModeEnabled, limitLabeling } =
|
|
368
|
+
this.props;
|
|
379
369
|
const { mark: stateMark } = this.state;
|
|
380
370
|
|
|
381
371
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import {
|
|
4
|
+
import { gridDraggable, types } from '@pie-lib/plot';
|
|
5
5
|
import { color } from '@pie-lib/render-ui';
|
|
6
6
|
import * as utils from '../../utils';
|
|
7
7
|
import { correct, disabled, incorrect, missing } from '../shared/styles';
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { RayLine } from '../component';
|
|
4
4
|
import { graphProps as getGraphProps } from '../../../__tests__/utils';
|
|
5
5
|
import { utils } from '@pie-lib/plot';
|
|
6
|
+
|
|
6
7
|
describe('RayLine', () => {
|
|
7
8
|
let onChange = jest.fn();
|
|
8
9
|
const renderComponent = (extras) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lineBase, lineToolComponent, styles } from '../shared/line';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { ArrowMarker, genUid } from '../shared/arrow-head';
|
|
5
5
|
import { trig, types } from '@pie-lib/plot';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
-
import {
|
|
7
|
+
import { getAdjustedGraphLimits, thinnerShapesNeeded } from '../../utils';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
|
|
10
10
|
const StyledRayRoot = styled('g')(({ theme, disabled, correctness }) => ({
|
|
@@ -48,9 +48,7 @@ export const RayLine = (props) => {
|
|
|
48
48
|
size={thinnerShapesNeeded(graphProps) ? 4 : 5}
|
|
49
49
|
id={`${finalMarkerId}-${suffix}`}
|
|
50
50
|
className={classNames(
|
|
51
|
-
suffix === 'enabled' ? 'enabledArrow' :
|
|
52
|
-
suffix === 'disabled' ? 'disabledArrow' :
|
|
53
|
-
`${suffix}Arrow`
|
|
51
|
+
suffix === 'enabled' ? 'enabledArrow' : suffix === 'disabled' ? 'disabledArrow' : `${suffix}Arrow`,
|
|
54
52
|
)}
|
|
55
53
|
/>
|
|
56
54
|
</defs>
|
|
@@ -38,8 +38,8 @@ const StyledMarker = styled('marker')(({ disabled, correctness }) => ({
|
|
|
38
38
|
}));
|
|
39
39
|
|
|
40
40
|
export const ArrowHead = ({ size, transform, points, disabled, correctness }) => (
|
|
41
|
-
<StyledArrowHead
|
|
42
|
-
points={points || `0,0 ${size},${size / 2} 0,${size}`}
|
|
41
|
+
<StyledArrowHead
|
|
42
|
+
points={points || `0,0 ${size},${size / 2} 0,${size}`}
|
|
43
43
|
transform={transform}
|
|
44
44
|
disabled={disabled}
|
|
45
45
|
correctness={correctness}
|
|
@@ -64,10 +64,15 @@ export const genUid = () => {
|
|
|
64
64
|
export const ArrowMarker = ({ id, size, className, disabled, correctness }) => {
|
|
65
65
|
// Parse styling info from className if provided (for backward compatibility)
|
|
66
66
|
const isDisabled = disabled || className?.includes('disabled');
|
|
67
|
-
const parsedCorrectness =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const parsedCorrectness =
|
|
68
|
+
correctness ||
|
|
69
|
+
(className?.includes('incorrect')
|
|
70
|
+
? 'incorrect'
|
|
71
|
+
: className?.includes('correct')
|
|
72
|
+
? 'correct'
|
|
73
|
+
: className?.includes('missing')
|
|
74
|
+
? 'missing'
|
|
75
|
+
: null);
|
|
71
76
|
|
|
72
77
|
return (
|
|
73
78
|
<StyledMarker
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { render } from '@pie-lib/test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { graphProps as getGraphProps } from '../../../../__tests__/utils';
|
|
4
|
-
import {
|
|
5
|
-
const { xy } = utils;
|
|
6
|
-
|
|
4
|
+
import { utils } from '@pie-lib/plot';
|
|
7
5
|
import * as lineUtils from '../../../../utils';
|
|
8
6
|
|
|
7
|
+
const { xy } = utils;
|
|
8
|
+
|
|
9
9
|
const { bounds, pointsToArea } = lineUtils;
|
|
10
10
|
jest.mock('../../../../utils', () => {
|
|
11
11
|
const a = jest.requireActual('../../../../utils');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { render } from '@pie-lib/test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { rootEdgeComponent,
|
|
3
|
+
import { rootEdgeComponent, rootEdgeToFromToWrapper } from '../with-root-edge';
|
|
4
4
|
import { graphProps as getGraphProps } from '../../../../__tests__/utils';
|
|
5
5
|
import { utils } from '@pie-lib/plot';
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
const { xy } = utils;
|
|
8
8
|
jest.mock('../index', () => {
|
|
9
9
|
const out = {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import isEqual from 'lodash
|
|
3
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
+
import { cloneDeep, isEmpty, isEqual } from 'lodash-es';
|
|
4
3
|
import { BasePoint } from '../point';
|
|
5
|
-
import {
|
|
4
|
+
import { gridDraggable, trig, types, utils } from '@pie-lib/plot';
|
|
6
5
|
import PropTypes from 'prop-types';
|
|
7
|
-
import { disabled, disabledSecondary,
|
|
6
|
+
import { correct, disabled, disabledSecondary, incorrect, missing } from '../styles';
|
|
8
7
|
import ReactDOM from 'react-dom';
|
|
9
8
|
import MarkLabel from '../../../mark-label';
|
|
10
|
-
import isEmpty from 'lodash/isEmpty';
|
|
11
9
|
import { color } from '@pie-lib/render-ui';
|
|
12
|
-
import {
|
|
10
|
+
import { equalPoints, getMiddleOfTwoPoints, sameAxes } from '../../../utils';
|
|
13
11
|
import { styled } from '@mui/material/styles';
|
|
14
12
|
|
|
15
13
|
const StyledLineGroup = styled('g')(({ disabled, correctness }) => ({
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { types } from '@pie-lib/plot';
|
|
5
|
-
import { disabled,
|
|
5
|
+
import { correct, disabled, disabledSecondary, incorrect, missing } from '../styles';
|
|
6
6
|
import * as vx from '@visx/shape';
|
|
7
7
|
import { color } from '@pie-lib/render-ui';
|
|
8
8
|
|
|
@@ -72,13 +72,7 @@ export class RawLinePath extends React.Component {
|
|
|
72
72
|
|
|
73
73
|
return (
|
|
74
74
|
<React.Fragment>
|
|
75
|
-
<StyledDrawLine
|
|
76
|
-
data={data}
|
|
77
|
-
className={className}
|
|
78
|
-
disabled={disabled}
|
|
79
|
-
correctness={correctness}
|
|
80
|
-
{...rest}
|
|
81
|
-
/>
|
|
75
|
+
<StyledDrawLine data={data} className={className} disabled={disabled} correctness={correctness} {...rest} />
|
|
82
76
|
<StyledLine
|
|
83
77
|
data={data}
|
|
84
78
|
className={className}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { types } from '@pie-lib/plot';
|
|
4
|
-
import {
|
|
4
|
+
import { arrowDimensions, getAngleDeg } from '../../../utils';
|
|
5
5
|
|
|
6
6
|
export class RawArrow extends React.Component {
|
|
7
7
|
static propTypes = {
|
|
@@ -39,10 +39,7 @@ export class RawArrow extends React.Component {
|
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<g className={className} {...rest}>
|
|
42
|
-
<polygon
|
|
43
|
-
points={points}
|
|
44
|
-
transform={`translate(${scale.x(x)}, ${scale.y(y)}) rotate(${angle} 0 0)`}
|
|
45
|
-
/>
|
|
42
|
+
<polygon points={points} transform={`translate(${scale.x(x)}, ${scale.y(y)}) rotate(${angle} 0 0)`} />
|
|
46
43
|
</g>
|
|
47
44
|
);
|
|
48
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { buildDataPoints, FREQ_DIVIDER, getAmplitudeAndFreq, sinY } from '@pie-lib/graphing-utils';
|
|
3
|
+
import { rootEdgeComponent, withRootEdge } from '../shared/line/with-root-edge';
|
|
4
4
|
|
|
5
5
|
const log = debug('pie-lib:graphing:sine');
|
|
6
6
|
|
package/src/undo-redo.jsx
CHANGED
|
@@ -31,15 +31,9 @@ export class UndoRedo extends React.Component {
|
|
|
31
31
|
const { className, onUndo, onRedo, onReset, language } = this.props;
|
|
32
32
|
return (
|
|
33
33
|
<div className={classNames(className)}>
|
|
34
|
-
<StyledButton onClick={() => onUndo(true)}>
|
|
35
|
-
|
|
36
|
-
</StyledButton>
|
|
37
|
-
<StyledButton onClick={() => onRedo(true)}>
|
|
38
|
-
{translator.t('graphing.redo', { lng: language })}
|
|
39
|
-
</StyledButton>
|
|
40
|
-
<StyledButton onClick={() => onReset()}>
|
|
41
|
-
{translator.t('graphing.reset', { lng: language })}
|
|
42
|
-
</StyledButton>
|
|
34
|
+
<StyledButton onClick={() => onUndo(true)}>{translator.t('common:undo', { lng: language })}</StyledButton>
|
|
35
|
+
<StyledButton onClick={() => onRedo(true)}>{translator.t('graphing.redo', { lng: language })}</StyledButton>
|
|
36
|
+
<StyledButton onClick={() => onReset()}>{translator.t('graphing.reset', { lng: language })}</StyledButton>
|
|
43
37
|
</div>
|
|
44
38
|
);
|
|
45
39
|
}
|
package/src/use-debounce.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import head from 'lodash/head';
|
|
2
|
-
import tail from 'lodash/tail';
|
|
3
1
|
import { utils } from '@pie-lib/plot';
|
|
4
2
|
import invariant from 'invariant';
|
|
5
|
-
import isEqual from 'lodash
|
|
6
|
-
import isEmpty from 'lodash/isEmpty';
|
|
7
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
3
|
+
import { cloneDeep, head, isEmpty, isEqual, tail } from 'lodash-es';
|
|
8
4
|
|
|
9
5
|
export const tickCount = utils.tickCount;
|
|
10
6
|
export const bounds = utils.bounds;
|