@pie-lib/plot 2.1.10-next.266 → 2.1.10-next.540
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 +22 -0
- package/lib/draggable.js +17 -26
- package/lib/draggable.js.map +1 -1
- package/lib/graph-props.js +4 -6
- package/lib/graph-props.js.map +1 -1
- package/lib/grid-draggable.js +42 -71
- package/lib/grid-draggable.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/root.js +64 -71
- package/lib/root.js.map +1 -1
- package/lib/trig.js +2 -2
- package/lib/trig.js.map +1 -1
- package/lib/types.js +2 -2
- package/lib/types.js.map +1 -1
- package/lib/utils.js +4 -4
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/graph-props.js +3 -6
- package/src/root.jsx +57 -30
- package/src/utils.js +2 -2
package/src/root.jsx
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChildrenType } from './types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
-
import Typography from '@material-ui/core/Typography';
|
|
5
4
|
import { select, mouse } from 'd3-selection';
|
|
6
5
|
import PropTypes from 'prop-types';
|
|
7
6
|
import { GraphPropsType } from './types';
|
|
8
7
|
import { color } from '@pie-lib/render-ui';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
export const GraphTitle = withStyles(theme => ({
|
|
12
|
-
title: {
|
|
13
|
-
color: color.text(),
|
|
14
|
-
textAlign: 'center',
|
|
15
|
-
paddingTop: theme.spacing.unit * 2,
|
|
16
|
-
fontSize: theme.typography.fontSize + 6
|
|
17
|
-
}
|
|
18
|
-
}))(({ value, classes }) => (
|
|
19
|
-
<Typography
|
|
20
|
-
className={classes.title}
|
|
21
|
-
color="primary"
|
|
22
|
-
variant="h5"
|
|
23
|
-
dangerouslySetInnerHTML={{ __html: value }}
|
|
24
|
-
/>
|
|
25
|
-
));
|
|
8
|
+
import EditableHtml from '@pie-lib/editable-html';
|
|
9
|
+
import cn from 'classnames';
|
|
26
10
|
|
|
27
11
|
export class Root extends React.Component {
|
|
28
12
|
static propTypes = {
|
|
@@ -31,8 +15,8 @@ export class Root extends React.Component {
|
|
|
31
15
|
graphProps: GraphPropsType.isRequired,
|
|
32
16
|
onMouseMove: PropTypes.func,
|
|
33
17
|
classes: PropTypes.object.isRequired,
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
showTitle: PropTypes.bool,
|
|
19
|
+
rootRef: PropTypes.func
|
|
36
20
|
};
|
|
37
21
|
|
|
38
22
|
mouseMove = g => {
|
|
@@ -66,18 +50,52 @@ export class Root extends React.Component {
|
|
|
66
50
|
}
|
|
67
51
|
|
|
68
52
|
render() {
|
|
69
|
-
const {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
const {
|
|
54
|
+
disabledTitle,
|
|
55
|
+
graphProps,
|
|
56
|
+
children,
|
|
57
|
+
classes,
|
|
58
|
+
onChangeTitle,
|
|
59
|
+
showTitle,
|
|
60
|
+
title,
|
|
61
|
+
rootRef
|
|
62
|
+
} = this.props;
|
|
63
|
+
const {
|
|
64
|
+
size: { width = 500, height = 500 },
|
|
65
|
+
domain,
|
|
66
|
+
range
|
|
67
|
+
} = graphProps;
|
|
68
|
+
const topPadding = 50;
|
|
69
|
+
const leftPadding = topPadding + 10; // left side requires an extra padding of 10
|
|
70
|
+
const finalWidth = width + leftPadding * 2 + (domain.padding || 0) * 2;
|
|
71
|
+
const finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
|
|
74
72
|
|
|
75
|
-
const
|
|
76
|
-
|
|
73
|
+
const activeTitlePlugins = [
|
|
74
|
+
'bold',
|
|
75
|
+
'italic',
|
|
76
|
+
'underline',
|
|
77
|
+
'strikethrough'
|
|
78
|
+
// 'languageCharacters'
|
|
79
|
+
];
|
|
77
80
|
|
|
78
81
|
return (
|
|
79
82
|
<div className={classes.root}>
|
|
80
|
-
{
|
|
83
|
+
{showTitle && (
|
|
84
|
+
<EditableHtml
|
|
85
|
+
className={cn(
|
|
86
|
+
{
|
|
87
|
+
[classes.disabledTitle]: disabledTitle
|
|
88
|
+
},
|
|
89
|
+
classes.graphTitle
|
|
90
|
+
)}
|
|
91
|
+
markup={title || ''}
|
|
92
|
+
width={finalWidth}
|
|
93
|
+
onChange={onChangeTitle}
|
|
94
|
+
placeholder={!disabledTitle && 'Click here to add a title for this graph'}
|
|
95
|
+
toolbarOpts={{ noBorder: true }}
|
|
96
|
+
activePlugins={activeTitlePlugins}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
81
99
|
<svg width={finalWidth} height={finalHeight} className={classes.svg}>
|
|
82
100
|
<g
|
|
83
101
|
ref={r => {
|
|
@@ -87,7 +105,7 @@ export class Root extends React.Component {
|
|
|
87
105
|
}
|
|
88
106
|
}}
|
|
89
107
|
className={classes.graphBox}
|
|
90
|
-
transform={`translate(${
|
|
108
|
+
transform={`translate(${leftPadding}, ${topPadding})`}
|
|
91
109
|
>
|
|
92
110
|
{children}
|
|
93
111
|
</g>
|
|
@@ -96,7 +114,7 @@ export class Root extends React.Component {
|
|
|
96
114
|
);
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
|
-
const styles =
|
|
117
|
+
const styles = theme => ({
|
|
100
118
|
root: {
|
|
101
119
|
border: `solid 1px ${color.primaryLight()}`,
|
|
102
120
|
color: color.text(),
|
|
@@ -106,6 +124,15 @@ const styles = () => ({
|
|
|
106
124
|
graphBox: {
|
|
107
125
|
cursor: 'pointer',
|
|
108
126
|
userSelect: 'none'
|
|
127
|
+
},
|
|
128
|
+
graphTitle: {
|
|
129
|
+
color: color.text(),
|
|
130
|
+
fontSize: theme.typography.fontSize + 2,
|
|
131
|
+
padding: '8px 50px 0',
|
|
132
|
+
textAlign: 'center'
|
|
133
|
+
},
|
|
134
|
+
disabledTitle: {
|
|
135
|
+
pointerEvents: 'none'
|
|
109
136
|
}
|
|
110
137
|
});
|
|
111
138
|
|
package/src/utils.js
CHANGED
|
@@ -139,7 +139,7 @@ export const isDomainRangeEqual = (graphProps, nextGraphProps) => {
|
|
|
139
139
|
);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
// findLongestWord is also used in
|
|
142
|
+
// findLongestWord is also used in graphing
|
|
143
143
|
export const findLongestWord = label => {
|
|
144
144
|
let longestWord = (label || '')
|
|
145
145
|
.replace(/<[^>]+>/g, '')
|
|
@@ -149,7 +149,7 @@ export const findLongestWord = label => {
|
|
|
149
149
|
return longestWord[0].length;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
// amountToIncreaseWidth is also used in
|
|
152
|
+
// amountToIncreaseWidth is also used in graphing
|
|
153
153
|
export const amountToIncreaseWidth = longestWord => {
|
|
154
154
|
if (!longestWord) {
|
|
155
155
|
return 0;
|