@pie-lib/graphing 2.11.3-next.50 → 2.11.4
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/CHANGELOG.md +16 -0
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js.map +1 -1
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js.map +1 -1
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/index.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/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.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.map +1 -1
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/axis/arrow.jsx +4 -4
- package/src/axis/axes.jsx +34 -56
- package/src/bg.jsx +3 -11
- package/src/container/actions.js +3 -3
- package/src/container/index.jsx +7 -7
- package/src/coordinates-label.jsx +8 -8
- package/src/graph-with-controls.jsx +30 -41
- package/src/graph.jsx +20 -22
- package/src/grid-setup.jsx +37 -64
- package/src/grid.jsx +17 -19
- package/src/labels.jsx +20 -20
- package/src/mark-label.jsx +13 -13
- package/src/toggle-bar.jsx +28 -30
- package/src/tool-menu.jsx +7 -12
- package/src/tools/circle/bg-circle.jsx +11 -26
- package/src/tools/circle/component.jsx +25 -25
- package/src/tools/circle/index.js +2 -2
- package/src/tools/index.js +2 -23
- package/src/tools/line/component.jsx +5 -10
- package/src/tools/parabola/component.jsx +2 -9
- package/src/tools/parabola/index.js +2 -2
- package/src/tools/point/component.jsx +5 -5
- package/src/tools/point/index.js +3 -3
- package/src/tools/polygon/component.jsx +18 -34
- package/src/tools/polygon/index.js +3 -3
- package/src/tools/polygon/line.jsx +10 -15
- package/src/tools/polygon/polygon.jsx +16 -25
- package/src/tools/ray/component.jsx +5 -10
- package/src/tools/segment/component.jsx +5 -10
- package/src/tools/shared/arrow-head.jsx +4 -4
- package/src/tools/shared/line/index.jsx +30 -31
- package/src/tools/shared/line/line-path.jsx +13 -29
- package/src/tools/shared/line/with-root-edge.jsx +14 -25
- package/src/tools/shared/point/arrow-point.jsx +6 -25
- package/src/tools/shared/point/arrow.jsx +3 -21
- package/src/tools/shared/point/base-point.jsx +3 -11
- package/src/tools/shared/point/index.jsx +11 -11
- package/src/tools/shared/styles.js +3 -3
- package/src/tools/shared/types.js +1 -1
- package/src/tools/sine/component.jsx +2 -2
- package/src/tools/sine/index.js +2 -2
- package/src/tools/vector/component.jsx +5 -10
- package/src/undo-redo.jsx +6 -6
- package/src/utils.js +29 -38
|
@@ -6,17 +6,17 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
6
6
|
import InputBase from '@material-ui/core/InputBase';
|
|
7
7
|
import { roundNumber } from './utils';
|
|
8
8
|
|
|
9
|
-
const styles = theme => ({
|
|
9
|
+
const styles = (theme) => ({
|
|
10
10
|
input: {
|
|
11
11
|
fontFamily: theme.typography.fontFamily,
|
|
12
12
|
fontSize: theme.typography.fontSize,
|
|
13
13
|
borderRadius: '8px',
|
|
14
14
|
background: '#FFFFFF',
|
|
15
|
-
color: color.primaryDark()
|
|
15
|
+
color: color.primaryDark(),
|
|
16
16
|
},
|
|
17
17
|
inputLabel: {
|
|
18
|
-
padding: 0
|
|
19
|
-
}
|
|
18
|
+
padding: 0,
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
export const getLabelPosition = (graphProps, x, y, labelLength) => {
|
|
@@ -28,13 +28,13 @@ export const getLabelPosition = (graphProps, x, y, labelLength) => {
|
|
|
28
28
|
if (rightEdge >= scale.x(domain.max)) {
|
|
29
29
|
return {
|
|
30
30
|
left: scale.x(x) - leftShift - labelLength,
|
|
31
|
-
top: scale.y(y) - topShift
|
|
31
|
+
top: scale.y(y) - topShift,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
36
|
left: scale.x(x) + leftShift,
|
|
37
|
-
top: scale.y(y) - topShift
|
|
37
|
+
top: scale.y(y) - topShift,
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -48,7 +48,7 @@ export const CoordinatesLabel = ({ x, y, graphProps, classes }) => {
|
|
|
48
48
|
pointerEvents: 'auto',
|
|
49
49
|
width: labelLength,
|
|
50
50
|
padding: 0,
|
|
51
|
-
...labelPosition
|
|
51
|
+
...labelPosition,
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
return (
|
|
@@ -66,7 +66,7 @@ CoordinatesLabel.propTypes = {
|
|
|
66
66
|
graphProps: types.GraphPropsType,
|
|
67
67
|
classes: PropTypes.object,
|
|
68
68
|
x: PropTypes.number,
|
|
69
|
-
y: PropTypes.number
|
|
69
|
+
y: PropTypes.number,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
export default withStyles(styles)(CoordinatesLabel);
|
|
@@ -10,41 +10,31 @@ import ToolMenu from './tool-menu';
|
|
|
10
10
|
import Graph, { graphPropTypes } from './graph';
|
|
11
11
|
import UndoRedo from './undo-redo';
|
|
12
12
|
import { allTools, toolsArr } from './tools';
|
|
13
|
-
import {
|
|
14
|
-
ExpansionPanel,
|
|
15
|
-
ExpansionPanelDetails,
|
|
16
|
-
ExpansionPanelSummary,
|
|
17
|
-
Typography
|
|
18
|
-
} from '@material-ui/core';
|
|
13
|
+
import { ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary, Typography } from '@material-ui/core';
|
|
19
14
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
20
15
|
|
|
21
|
-
export const setToolbarAvailability = toolbarTools =>
|
|
22
|
-
toolsArr.map(tA => ({ ...tA, toolbar: !!toolbarTools.find(t => t === tA.type) })) || [];
|
|
16
|
+
export const setToolbarAvailability = (toolbarTools) =>
|
|
17
|
+
toolsArr.map((tA) => ({ ...tA, toolbar: !!toolbarTools.find((t) => t === tA.type) })) || [];
|
|
23
18
|
|
|
24
19
|
export const toolIsAvailable = (tools, currentTool) =>
|
|
25
|
-
currentTool && tools && (tools.find(tool => tool.type === currentTool.type) || {}).toolbar;
|
|
20
|
+
currentTool && tools && (tools.find((tool) => tool.type === currentTool.type) || {}).toolbar;
|
|
26
21
|
|
|
27
|
-
export const getAvailableTool = tools => tools.find(tool => tool.toolbar);
|
|
22
|
+
export const getAvailableTool = (tools) => tools.find((tool) => tool.toolbar);
|
|
28
23
|
|
|
29
|
-
export const filterByValidToolTypes = backgroundMarks =>
|
|
30
|
-
backgroundMarks.filter(bM => !!allTools.find(tool => tool === bM.type));
|
|
24
|
+
export const filterByValidToolTypes = (backgroundMarks) =>
|
|
25
|
+
backgroundMarks.filter((bM) => !!allTools.find((tool) => tool === bM.type));
|
|
31
26
|
|
|
32
27
|
export const filterByVisibleToolTypes = (toolbarTools, marks) =>
|
|
33
|
-
marks.filter(bM => !!toolbarTools.find(tool => tool === bM.type));
|
|
28
|
+
marks.filter((bM) => !!toolbarTools.find((tool) => tool === bM.type));
|
|
34
29
|
|
|
35
|
-
const getDefaultCurrentTool = toolType => toolsArr.find(tool => tool.type === toolType) || null;
|
|
30
|
+
const getDefaultCurrentTool = (toolType) => toolsArr.find((tool) => tool.type === toolType) || null;
|
|
36
31
|
|
|
37
32
|
const Collapsible = ({ classes, children, title }) => (
|
|
38
|
-
<ExpansionPanel
|
|
39
|
-
elevation={0}
|
|
40
|
-
className={classes.expansionPanel}
|
|
41
|
-
disabledGutters={true}
|
|
42
|
-
square={true}
|
|
43
|
-
>
|
|
33
|
+
<ExpansionPanel elevation={0} className={classes.expansionPanel} disabledGutters={true} square={true}>
|
|
44
34
|
<ExpansionPanelSummary
|
|
45
35
|
classes={{
|
|
46
36
|
root: classes.summaryRoot,
|
|
47
|
-
content: classes.summaryContent
|
|
37
|
+
content: classes.summaryContent,
|
|
48
38
|
}}
|
|
49
39
|
expandIcon={<ExpandMoreIcon />}
|
|
50
40
|
>
|
|
@@ -57,7 +47,7 @@ const Collapsible = ({ classes, children, title }) => (
|
|
|
57
47
|
Collapsible.propTypes = {
|
|
58
48
|
classes: PropTypes.object,
|
|
59
49
|
children: PropTypes.array,
|
|
60
|
-
title: PropTypes.string
|
|
50
|
+
title: PropTypes.string,
|
|
61
51
|
};
|
|
62
52
|
|
|
63
53
|
export class GraphWithControls extends React.Component {
|
|
@@ -66,7 +56,7 @@ export class GraphWithControls extends React.Component {
|
|
|
66
56
|
onUndo: PropTypes.func,
|
|
67
57
|
onRedo: PropTypes.func,
|
|
68
58
|
onReset: PropTypes.func,
|
|
69
|
-
toolbarTools: PropTypes.arrayOf(PropTypes.string) // array of tool types that have to be displayed in the toolbar, same shape as 'allTools'
|
|
59
|
+
toolbarTools: PropTypes.arrayOf(PropTypes.string), // array of tool types that have to be displayed in the toolbar, same shape as 'allTools'
|
|
70
60
|
};
|
|
71
61
|
|
|
72
62
|
static defaultProps = {
|
|
@@ -76,7 +66,7 @@ export class GraphWithControls extends React.Component {
|
|
|
76
66
|
disabledTitle: false,
|
|
77
67
|
showLabels: true,
|
|
78
68
|
showTitle: true,
|
|
79
|
-
toolbarTools: []
|
|
69
|
+
toolbarTools: [],
|
|
80
70
|
};
|
|
81
71
|
|
|
82
72
|
constructor(props) {
|
|
@@ -84,7 +74,7 @@ export class GraphWithControls extends React.Component {
|
|
|
84
74
|
|
|
85
75
|
this.state = {
|
|
86
76
|
currentTool: getDefaultCurrentTool(props.defaultTool),
|
|
87
|
-
labelModeEnabled: false
|
|
77
|
+
labelModeEnabled: false,
|
|
88
78
|
};
|
|
89
79
|
}
|
|
90
80
|
|
|
@@ -98,10 +88,9 @@ export class GraphWithControls extends React.Component {
|
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
90
|
|
|
101
|
-
changeCurrentTool = (tool, tools) =>
|
|
102
|
-
this.setState({ currentTool: tools.find(t => t.type === tool) });
|
|
91
|
+
changeCurrentTool = (tool, tools) => this.setState({ currentTool: tools.find((t) => t.type === tool) });
|
|
103
92
|
|
|
104
|
-
toggleLabelMode = () => this.setState(state => ({ labelModeEnabled: !state.labelModeEnabled }));
|
|
93
|
+
toggleLabelMode = () => this.setState((state) => ({ labelModeEnabled: !state.labelModeEnabled }));
|
|
105
94
|
|
|
106
95
|
render() {
|
|
107
96
|
let { currentTool, labelModeEnabled } = this.state;
|
|
@@ -132,12 +121,12 @@ export class GraphWithControls extends React.Component {
|
|
|
132
121
|
showPixelGuides,
|
|
133
122
|
showTitle,
|
|
134
123
|
title,
|
|
135
|
-
titlePlaceholder
|
|
124
|
+
titlePlaceholder,
|
|
136
125
|
} = this.props;
|
|
137
126
|
let { backgroundMarks, marks, toolbarTools } = this.props;
|
|
138
127
|
|
|
139
128
|
// make sure only valid tool types are kept (string) and without duplicates
|
|
140
|
-
toolbarTools = uniq(toolbarTools || []).filter(tT => !!isString(tT)) || [];
|
|
129
|
+
toolbarTools = uniq(toolbarTools || []).filter((tT) => !!isString(tT)) || [];
|
|
141
130
|
|
|
142
131
|
// keep only the backgroundMarks that have valid types
|
|
143
132
|
backgroundMarks = filterByValidToolTypes(backgroundMarks || []);
|
|
@@ -159,7 +148,7 @@ export class GraphWithControls extends React.Component {
|
|
|
159
148
|
disabled={!!disabled}
|
|
160
149
|
draggableTools={draggableTools}
|
|
161
150
|
labelModeEnabled={labelModeEnabled}
|
|
162
|
-
onChange={tool => this.changeCurrentTool(tool, tools)}
|
|
151
|
+
onChange={(tool) => this.changeCurrentTool(tool, tools)}
|
|
163
152
|
onToggleLabelMode={this.toggleLabelMode}
|
|
164
153
|
toolbarTools={toolbarTools}
|
|
165
154
|
onChangeTools={onChangeTools}
|
|
@@ -181,7 +170,7 @@ export class GraphWithControls extends React.Component {
|
|
|
181
170
|
)}
|
|
182
171
|
</div>
|
|
183
172
|
|
|
184
|
-
<div ref={r => (this.labelNode = r)} />
|
|
173
|
+
<div ref={(r) => (this.labelNode = r)} />
|
|
185
174
|
|
|
186
175
|
<Graph
|
|
187
176
|
axesSettings={axesSettings}
|
|
@@ -212,11 +201,11 @@ export class GraphWithControls extends React.Component {
|
|
|
212
201
|
}
|
|
213
202
|
}
|
|
214
203
|
|
|
215
|
-
const styles = theme => ({
|
|
204
|
+
const styles = (theme) => ({
|
|
216
205
|
graphWithControls: {
|
|
217
206
|
display: 'flex',
|
|
218
207
|
flexDirection: 'column',
|
|
219
|
-
width: 'min-content'
|
|
208
|
+
width: 'min-content',
|
|
220
209
|
},
|
|
221
210
|
controls: {
|
|
222
211
|
display: 'flex',
|
|
@@ -229,26 +218,26 @@ const styles = theme => ({
|
|
|
229
218
|
borderLeft: `solid 1px ${color.primaryDark()}`,
|
|
230
219
|
borderRight: `solid 1px ${color.primaryDark()}`,
|
|
231
220
|
'& button': {
|
|
232
|
-
fontSize: theme.typography.fontSize
|
|
233
|
-
}
|
|
221
|
+
fontSize: theme.typography.fontSize,
|
|
222
|
+
},
|
|
234
223
|
},
|
|
235
224
|
expansionPanel: {
|
|
236
225
|
backgroundColor: color.primaryLight(),
|
|
237
|
-
width: '100%'
|
|
226
|
+
width: '100%',
|
|
238
227
|
},
|
|
239
228
|
summaryRoot: {
|
|
240
229
|
padding: `0 ${theme.spacing.unit}px`,
|
|
241
|
-
minHeight: '32px !important'
|
|
230
|
+
minHeight: '32px !important',
|
|
242
231
|
},
|
|
243
232
|
summaryContent: {
|
|
244
|
-
margin: '4px 0 !important'
|
|
233
|
+
margin: '4px 0 !important',
|
|
245
234
|
},
|
|
246
235
|
details: {
|
|
247
236
|
padding: 0,
|
|
248
237
|
marginTop: theme.spacing.unit,
|
|
249
238
|
display: 'flex',
|
|
250
|
-
justifyContent: 'space-between'
|
|
251
|
-
}
|
|
239
|
+
justifyContent: 'space-between',
|
|
240
|
+
},
|
|
252
241
|
});
|
|
253
242
|
|
|
254
243
|
export default withStyles(styles)(GraphWithControls);
|
package/src/graph.jsx
CHANGED
|
@@ -32,28 +32,28 @@ export const graphPropTypes = {
|
|
|
32
32
|
range: types.DomainType,
|
|
33
33
|
size: PropTypes.shape({
|
|
34
34
|
width: PropTypes.number.isRequired,
|
|
35
|
-
height: PropTypes.number.isRequired
|
|
35
|
+
height: PropTypes.number.isRequired,
|
|
36
36
|
}),
|
|
37
37
|
showLabels: PropTypes.bool,
|
|
38
38
|
showPixelGuides: PropTypes.bool,
|
|
39
39
|
showTitle: PropTypes.bool,
|
|
40
40
|
title: PropTypes.string,
|
|
41
|
-
tools: PropTypes.array
|
|
41
|
+
tools: PropTypes.array,
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const getMaskSize = size => ({
|
|
44
|
+
const getMaskSize = (size) => ({
|
|
45
45
|
x: -23,
|
|
46
46
|
y: -23,
|
|
47
47
|
width: size.width + 46,
|
|
48
|
-
height: size.height + 46
|
|
48
|
+
height: size.height + 46,
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
export const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool }) => {
|
|
52
|
-
const buildingMark = marks.filter(m => m.building)[0];
|
|
52
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
53
53
|
let newMarks = cloneDeep(marks);
|
|
54
54
|
|
|
55
55
|
if (buildingMark && currentTool && buildingMark.type !== currentTool.type) {
|
|
56
|
-
const index = newMarks.findIndex(m => isEqual(m, buildingMark));
|
|
56
|
+
const index = newMarks.findIndex((m) => isEqual(m, buildingMark));
|
|
57
57
|
|
|
58
58
|
if (index >= 0) {
|
|
59
59
|
newMarks.splice(index, 1);
|
|
@@ -66,13 +66,13 @@ export const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool }) =
|
|
|
66
66
|
export class Graph extends React.Component {
|
|
67
67
|
static propTypes = {
|
|
68
68
|
...graphPropTypes,
|
|
69
|
-
currentTool: PropTypes.object
|
|
69
|
+
currentTool: PropTypes.object,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
static defaultProps = {
|
|
73
73
|
onChangeMarks: () => {},
|
|
74
74
|
disabledLabels: false,
|
|
75
|
-
disabledTitle: false
|
|
75
|
+
disabledTitle: false,
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
state = {};
|
|
@@ -83,7 +83,7 @@ export class Graph extends React.Component {
|
|
|
83
83
|
const { onChangeMarks, marks } = this.props;
|
|
84
84
|
let newMarks = cloneDeep(marks);
|
|
85
85
|
|
|
86
|
-
const index = newMarks.findIndex(m => isEqual(m, oldMark));
|
|
86
|
+
const index = newMarks.findIndex((m) => isEqual(m, oldMark));
|
|
87
87
|
|
|
88
88
|
if (index >= 0 && !isDuplicatedMark(newMark, marks, oldMark)) {
|
|
89
89
|
newMarks.splice(index, 1, newMark);
|
|
@@ -92,9 +92,9 @@ export class Graph extends React.Component {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
completeMark = markData => {
|
|
95
|
+
completeMark = (markData) => {
|
|
96
96
|
const { currentTool, marks } = this.props;
|
|
97
|
-
const buildingMark = marks.filter(m => m.building)[0];
|
|
97
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
98
98
|
|
|
99
99
|
if (!buildingMark || !currentTool) return;
|
|
100
100
|
|
|
@@ -111,7 +111,7 @@ export class Graph extends React.Component {
|
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const index = newMarks.findIndex(m => isEqual(m, existing));
|
|
114
|
+
const index = newMarks.findIndex((m) => isEqual(m, existing));
|
|
115
115
|
|
|
116
116
|
if (index >= 0) {
|
|
117
117
|
newMarks.splice(index, 1, update);
|
|
@@ -122,15 +122,15 @@ export class Graph extends React.Component {
|
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
-
getComponent = mark => {
|
|
125
|
+
getComponent = (mark) => {
|
|
126
126
|
if (!mark) return null;
|
|
127
127
|
|
|
128
|
-
const tool = (this.props.tools || []).find(t => t.type === mark.type);
|
|
128
|
+
const tool = (this.props.tools || []).find((t) => t.type === mark.type);
|
|
129
129
|
|
|
130
130
|
return (tool && tool.Component) || null;
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
onBgClick = point => {
|
|
133
|
+
onBgClick = (point) => {
|
|
134
134
|
const { x, y } = point;
|
|
135
135
|
const { labelModeEnabled, currentTool, marks } = this.props;
|
|
136
136
|
|
|
@@ -140,7 +140,7 @@ export class Graph extends React.Component {
|
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
const buildingMark = marks.filter(m => m.building)[0];
|
|
143
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
144
144
|
let updatedMark;
|
|
145
145
|
|
|
146
146
|
// if the building mark has a different type, we just replace it
|
|
@@ -173,7 +173,7 @@ export class Graph extends React.Component {
|
|
|
173
173
|
showTitle,
|
|
174
174
|
titlePlaceholder,
|
|
175
175
|
onChangeLabels,
|
|
176
|
-
onChangeTitle
|
|
176
|
+
onChangeTitle,
|
|
177
177
|
} = this.props;
|
|
178
178
|
let { marks } = this.props;
|
|
179
179
|
|
|
@@ -185,7 +185,7 @@ export class Graph extends React.Component {
|
|
|
185
185
|
|
|
186
186
|
return (
|
|
187
187
|
<Root
|
|
188
|
-
rootRef={r => (this.rootNode = r)}
|
|
188
|
+
rootRef={(r) => (this.rootNode = r)}
|
|
189
189
|
disabledTitle={disabledTitle}
|
|
190
190
|
disabledLabels={disabledLabels}
|
|
191
191
|
labels={labels}
|
|
@@ -201,9 +201,7 @@ export class Graph extends React.Component {
|
|
|
201
201
|
>
|
|
202
202
|
<g
|
|
203
203
|
transform={
|
|
204
|
-
domain && domain.padding && domain.range
|
|
205
|
-
? `translate(${domain.padding}, ${range.padding})`
|
|
206
|
-
: undefined
|
|
204
|
+
domain && domain.padding && domain.range ? `translate(${domain.padding}, ${range.padding})` : undefined
|
|
207
205
|
}
|
|
208
206
|
>
|
|
209
207
|
<Grid {...common} />
|
|
@@ -250,7 +248,7 @@ export class Graph extends React.Component {
|
|
|
250
248
|
})}
|
|
251
249
|
|
|
252
250
|
<foreignObject
|
|
253
|
-
ref={labelNode => (this.labelNode = labelNode)}
|
|
251
|
+
ref={(labelNode) => (this.labelNode = labelNode)}
|
|
254
252
|
x="0"
|
|
255
253
|
y="0"
|
|
256
254
|
{...size}
|
package/src/grid-setup.jsx
CHANGED
|
@@ -10,17 +10,8 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
|
10
10
|
import { NumberTextFieldCustom, Toggle } from '@pie-lib/config-ui';
|
|
11
11
|
import EditableHTML from '@pie-lib/editable-html';
|
|
12
12
|
|
|
13
|
-
const GridConfig = props => {
|
|
14
|
-
const {
|
|
15
|
-
classes,
|
|
16
|
-
disabled,
|
|
17
|
-
displayedFields,
|
|
18
|
-
labelValue,
|
|
19
|
-
labelValues,
|
|
20
|
-
gridValue,
|
|
21
|
-
gridValues,
|
|
22
|
-
onChange
|
|
23
|
-
} = props;
|
|
13
|
+
const GridConfig = (props) => {
|
|
14
|
+
const { classes, disabled, displayedFields, labelValue, labelValues, gridValue, gridValues, onChange } = props;
|
|
24
15
|
const { labelStep = {}, step = {} } = displayedFields;
|
|
25
16
|
|
|
26
17
|
return (
|
|
@@ -59,27 +50,17 @@ GridConfig.propTypes = {
|
|
|
59
50
|
labelValues: PropTypes.array,
|
|
60
51
|
gridValue: PropTypes.number,
|
|
61
52
|
gridValues: PropTypes.array,
|
|
62
|
-
onChange: PropTypes.func
|
|
53
|
+
onChange: PropTypes.func,
|
|
63
54
|
};
|
|
64
55
|
|
|
65
|
-
const AxisConfig = props => {
|
|
66
|
-
const {
|
|
67
|
-
classes,
|
|
68
|
-
disabled,
|
|
69
|
-
displayedFields,
|
|
70
|
-
displayHeader,
|
|
71
|
-
label,
|
|
72
|
-
maxValue,
|
|
73
|
-
minValue,
|
|
74
|
-
onChange,
|
|
75
|
-
type
|
|
76
|
-
} = props;
|
|
56
|
+
const AxisConfig = (props) => {
|
|
57
|
+
const { classes, disabled, displayedFields, displayHeader, label, maxValue, minValue, onChange, type } = props;
|
|
77
58
|
const { axisLabel = {}, min = {}, max = {} } = displayedFields;
|
|
78
59
|
const activePlugins = [
|
|
79
60
|
'bold',
|
|
80
61
|
'italic',
|
|
81
62
|
'underline',
|
|
82
|
-
'strikethrough'
|
|
63
|
+
'strikethrough',
|
|
83
64
|
// 'languageCharacters'
|
|
84
65
|
];
|
|
85
66
|
|
|
@@ -119,7 +100,7 @@ const AxisConfig = props => {
|
|
|
119
100
|
<InputContainer label={axisLabel.label || ''} className={classes.mediumTextField}>
|
|
120
101
|
<EditableHTML
|
|
121
102
|
className={classes.axisLabel}
|
|
122
|
-
onChange={value => onChange('axisLabel', value)}
|
|
103
|
+
onChange={(value) => onChange('axisLabel', value)}
|
|
123
104
|
markup={label || ''}
|
|
124
105
|
charactersLimit={5}
|
|
125
106
|
activePlugins={activePlugins}
|
|
@@ -130,7 +111,7 @@ const AxisConfig = props => {
|
|
|
130
111
|
);
|
|
131
112
|
};
|
|
132
113
|
|
|
133
|
-
const GridSetup = props => {
|
|
114
|
+
const GridSetup = (props) => {
|
|
134
115
|
const {
|
|
135
116
|
classes,
|
|
136
117
|
domain,
|
|
@@ -143,7 +124,7 @@ const GridSetup = props => {
|
|
|
143
124
|
range,
|
|
144
125
|
size,
|
|
145
126
|
sizeConstraints,
|
|
146
|
-
standardGrid
|
|
127
|
+
standardGrid,
|
|
147
128
|
} = props;
|
|
148
129
|
const gridProps = { min: 2, max: 41 };
|
|
149
130
|
const {
|
|
@@ -154,48 +135,47 @@ const GridSetup = props => {
|
|
|
154
135
|
min = {},
|
|
155
136
|
max = {},
|
|
156
137
|
standardGridEnabled,
|
|
157
|
-
step = {}
|
|
138
|
+
step = {},
|
|
158
139
|
} = displayedFields || {};
|
|
159
|
-
const displayAxisType =
|
|
160
|
-
min.enabled || max.enabled || axisLabel.enabled || step.enabled || labelStep.enabled;
|
|
140
|
+
const displayAxisType = min.enabled || max.enabled || axisLabel.enabled || step.enabled || labelStep.enabled;
|
|
161
141
|
const gridConfigFields = { step, labelStep };
|
|
162
142
|
const axisConfigFields = { min, max, axisLabel };
|
|
163
143
|
|
|
164
|
-
const onIncludeAxes = includeAxes => {
|
|
165
|
-
const noAxesConfig = type => {
|
|
144
|
+
const onIncludeAxes = (includeAxes) => {
|
|
145
|
+
const noAxesConfig = (type) => {
|
|
166
146
|
const axis = type === 'domain' ? domain : range;
|
|
167
147
|
|
|
168
148
|
return {
|
|
169
149
|
min: 1,
|
|
170
150
|
max: axis.max < gridProps.min || axis.max > gridProps.max ? 16 : axis.max,
|
|
171
151
|
step: 1,
|
|
172
|
-
labelStep: 0
|
|
152
|
+
labelStep: 0,
|
|
173
153
|
};
|
|
174
154
|
};
|
|
175
155
|
|
|
176
156
|
const updatedRange = {
|
|
177
157
|
...range,
|
|
178
|
-
...(includeAxes ? { labelStep: 1 } : noAxesConfig('range'))
|
|
158
|
+
...(includeAxes ? { labelStep: 1 } : noAxesConfig('range')),
|
|
179
159
|
};
|
|
180
160
|
const updatedDomain = {
|
|
181
161
|
...domain,
|
|
182
|
-
...(includeAxes ? { labelStep: 1 } : noAxesConfig('domain'))
|
|
162
|
+
...(includeAxes ? { labelStep: 1 } : noAxesConfig('domain')),
|
|
183
163
|
};
|
|
184
164
|
|
|
185
165
|
onChange({ includeAxes, range: updatedRange, domain: updatedDomain });
|
|
186
166
|
};
|
|
187
167
|
|
|
188
|
-
const onStandardGridChanged = value => {
|
|
168
|
+
const onStandardGridChanged = (value) => {
|
|
189
169
|
onChange({
|
|
190
170
|
standardGrid: value,
|
|
191
171
|
range: {
|
|
192
172
|
...domain,
|
|
193
|
-
axisLabel: range.axisLabel
|
|
173
|
+
axisLabel: range.axisLabel,
|
|
194
174
|
},
|
|
195
175
|
graph: {
|
|
196
176
|
...size,
|
|
197
|
-
height: size.width
|
|
198
|
-
}
|
|
177
|
+
height: size.width,
|
|
178
|
+
},
|
|
199
179
|
});
|
|
200
180
|
};
|
|
201
181
|
|
|
@@ -254,8 +234,7 @@ const GridSetup = props => {
|
|
|
254
234
|
</div>
|
|
255
235
|
{(min.enabled || max.enabled) && (
|
|
256
236
|
<Typography className={classes.text}>
|
|
257
|
-
If you want the axis to be visible, use a zero or negative Min Value, and a positive Max
|
|
258
|
-
Value
|
|
237
|
+
If you want the axis to be visible, use a zero or negative Min Value, and a positive Max Value
|
|
259
238
|
</Typography>
|
|
260
239
|
)}
|
|
261
240
|
{(step.enabled || labelStep.enabled) && (
|
|
@@ -282,9 +261,7 @@ const GridSetup = props => {
|
|
|
282
261
|
</div>
|
|
283
262
|
)}
|
|
284
263
|
{labelStep.enabled && (
|
|
285
|
-
<Typography className={classes.text}>
|
|
286
|
-
For unnumbered gridlines, enter a label interval of 0
|
|
287
|
-
</Typography>
|
|
264
|
+
<Typography className={classes.text}>For unnumbered gridlines, enter a label interval of 0</Typography>
|
|
288
265
|
)}
|
|
289
266
|
</React.Fragment>
|
|
290
267
|
);
|
|
@@ -322,11 +299,7 @@ const GridSetup = props => {
|
|
|
322
299
|
<ExpansionPanelDetails>
|
|
323
300
|
<div className={classes.content}>
|
|
324
301
|
{includeAxesEnabled && (
|
|
325
|
-
<Toggle
|
|
326
|
-
label="Include axes and labels?"
|
|
327
|
-
toggle={onIncludeAxes}
|
|
328
|
-
checked={includeAxes}
|
|
329
|
-
/>
|
|
302
|
+
<Toggle label="Include axes and labels?" toggle={onIncludeAxes} checked={includeAxes} />
|
|
330
303
|
)}
|
|
331
304
|
{standardGridEnabled && (
|
|
332
305
|
<Toggle
|
|
@@ -386,55 +359,55 @@ GridSetup.propTypes = {
|
|
|
386
359
|
range: PropTypes.object,
|
|
387
360
|
size: PropTypes.object,
|
|
388
361
|
sizeConstraints: PropTypes.object,
|
|
389
|
-
standardGrid: PropTypes.bool
|
|
362
|
+
standardGrid: PropTypes.bool,
|
|
390
363
|
};
|
|
391
364
|
|
|
392
|
-
const styles = theme => ({
|
|
365
|
+
const styles = (theme) => ({
|
|
393
366
|
wrapper: {
|
|
394
|
-
width: '450px'
|
|
367
|
+
width: '450px',
|
|
395
368
|
},
|
|
396
369
|
content: {
|
|
397
370
|
display: 'flex',
|
|
398
371
|
flexDirection: 'column',
|
|
399
|
-
width: '100%'
|
|
372
|
+
width: '100%',
|
|
400
373
|
},
|
|
401
374
|
columnView: {
|
|
402
375
|
display: 'flex',
|
|
403
376
|
flexDirection: 'column',
|
|
404
|
-
alignItems: 'center'
|
|
377
|
+
alignItems: 'center',
|
|
405
378
|
},
|
|
406
379
|
rowView: {
|
|
407
380
|
display: 'flex',
|
|
408
381
|
justifyContent: 'space-around',
|
|
409
|
-
alignItems: 'center'
|
|
382
|
+
alignItems: 'center',
|
|
410
383
|
},
|
|
411
384
|
textField: {
|
|
412
385
|
width: '130px',
|
|
413
|
-
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px
|
|
386
|
+
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
|
|
414
387
|
},
|
|
415
388
|
mediumTextField: {
|
|
416
389
|
width: '160px',
|
|
417
|
-
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px
|
|
390
|
+
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
|
|
418
391
|
},
|
|
419
392
|
largeTextField: {
|
|
420
393
|
width: '230px',
|
|
421
|
-
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px
|
|
394
|
+
margin: `${theme.spacing.unit}px ${theme.spacing.unit / 2}px`,
|
|
422
395
|
},
|
|
423
396
|
text: {
|
|
424
397
|
fontStyle: 'italic',
|
|
425
|
-
margin: `${theme.spacing.unit}px 0
|
|
398
|
+
margin: `${theme.spacing.unit}px 0`,
|
|
426
399
|
},
|
|
427
400
|
dimensions: {
|
|
428
401
|
display: 'flex',
|
|
429
402
|
justifyContent: 'space-between',
|
|
430
|
-
alignItems: 'center'
|
|
403
|
+
alignItems: 'center',
|
|
431
404
|
},
|
|
432
405
|
disabled: {
|
|
433
|
-
color: color.disabled()
|
|
406
|
+
color: color.disabled(),
|
|
434
407
|
},
|
|
435
408
|
axisLabel: {
|
|
436
|
-
paddingTop: theme.spacing.unit * 2
|
|
437
|
-
}
|
|
409
|
+
paddingTop: theme.spacing.unit * 2,
|
|
410
|
+
},
|
|
438
411
|
});
|
|
439
412
|
|
|
440
413
|
export default withStyles(styles)(GridSetup);
|