@pie-lib/graphing 2.8.1 → 2.10.0
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 +30 -0
- package/lib/axis/axes.js +4 -4
- package/lib/axis/axes.js.map +1 -1
- package/lib/graph-with-controls.js +33 -5
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +34 -7
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +16 -1
- package/lib/grid-setup.js.map +1 -1
- package/lib/labels.js +100 -23
- package/lib/labels.js.map +1 -1
- package/package.json +4 -4
- package/src/axis/axes.jsx +4 -4
- package/src/graph-with-controls.jsx +33 -5
- package/src/graph.jsx +40 -4
- package/src/grid-setup.jsx +14 -1
- package/src/labels.jsx +94 -21
package/src/grid-setup.jsx
CHANGED
|
@@ -51,6 +51,17 @@ const GridConfig = props => {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
GridConfig.propTypes = {
|
|
55
|
+
classes: PropTypes.object,
|
|
56
|
+
disabled: PropTypes.bool,
|
|
57
|
+
displayedFields: PropTypes.object,
|
|
58
|
+
labelValue: PropTypes.number,
|
|
59
|
+
labelValues: PropTypes.array,
|
|
60
|
+
gridValue: PropTypes.number,
|
|
61
|
+
gridValues: PropTypes.array,
|
|
62
|
+
onChange: PropTypes.func
|
|
63
|
+
};
|
|
64
|
+
|
|
54
65
|
const AxisConfig = props => {
|
|
55
66
|
const {
|
|
56
67
|
classes,
|
|
@@ -128,6 +139,7 @@ const GridSetup = props => {
|
|
|
128
139
|
includeAxes,
|
|
129
140
|
labelValues = {},
|
|
130
141
|
onChange,
|
|
142
|
+
onChangeView,
|
|
131
143
|
range,
|
|
132
144
|
size,
|
|
133
145
|
sizeConstraints,
|
|
@@ -303,7 +315,7 @@ const GridSetup = props => {
|
|
|
303
315
|
|
|
304
316
|
return (
|
|
305
317
|
<div className={classes.wrapper}>
|
|
306
|
-
<ExpansionPanel>
|
|
318
|
+
<ExpansionPanel onChange={onChangeView}>
|
|
307
319
|
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
|
|
308
320
|
<Typography variant="subtitle1">Customize Grid Setup</Typography>
|
|
309
321
|
</ExpansionPanelSummary>
|
|
@@ -370,6 +382,7 @@ GridSetup.propTypes = {
|
|
|
370
382
|
includeAxes: PropTypes.bool,
|
|
371
383
|
labelValues: PropTypes.object,
|
|
372
384
|
onChange: PropTypes.function,
|
|
385
|
+
onChangeView: PropTypes.function,
|
|
373
386
|
range: PropTypes.object,
|
|
374
387
|
size: PropTypes.object,
|
|
375
388
|
sizeConstraints: PropTypes.object,
|
package/src/labels.jsx
CHANGED
|
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
import { types } from '@pie-lib/plot';
|
|
5
5
|
import { color, Readable } from '@pie-lib/render-ui';
|
|
6
|
+
import EditableHtml from '@pie-lib/editable-html';
|
|
7
|
+
import cn from 'classnames';
|
|
6
8
|
|
|
7
9
|
const rotations = {
|
|
8
10
|
left: -90,
|
|
@@ -33,11 +35,11 @@ const getY = (side, height) => {
|
|
|
33
35
|
case 'left':
|
|
34
36
|
return -height;
|
|
35
37
|
case 'top':
|
|
36
|
-
return -height
|
|
38
|
+
return -height;
|
|
37
39
|
case 'right':
|
|
38
|
-
return -height
|
|
40
|
+
return -height - 10;
|
|
39
41
|
default:
|
|
40
|
-
return
|
|
42
|
+
return -height + 10;
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -46,11 +48,13 @@ class RawLabel extends React.Component {
|
|
|
46
48
|
text: PropTypes.string,
|
|
47
49
|
side: PropTypes.string,
|
|
48
50
|
classes: PropTypes.object,
|
|
51
|
+
disabledLabel: PropTypes.bool,
|
|
52
|
+
placeholder: PropTypes.string,
|
|
49
53
|
graphProps: types.GraphPropsType.isRequired
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
render() {
|
|
53
|
-
const { text, side, graphProps, classes } = this.props;
|
|
57
|
+
const { disabledLabel, placeholder, text, side, graphProps, classes, onChange } = this.props;
|
|
54
58
|
const { size, domain, range } = graphProps;
|
|
55
59
|
const totalHeight = (size.height || 500) + (range.padding || 0) * 2;
|
|
56
60
|
const totalWidth = (size.width || 500) + (domain.padding || 0) * 2;
|
|
@@ -59,18 +63,44 @@ class RawLabel extends React.Component {
|
|
|
59
63
|
const width = side === 'left' || side === 'right' ? totalHeight : totalWidth;
|
|
60
64
|
const height = 36;
|
|
61
65
|
const y = getY(side, height);
|
|
66
|
+
const finalHeight = side === 'bottom' ? height + 22 : height + 18;
|
|
67
|
+
|
|
68
|
+
const activePlugins = [
|
|
69
|
+
'bold',
|
|
70
|
+
'italic',
|
|
71
|
+
'underline',
|
|
72
|
+
'strikethrough',
|
|
73
|
+
'math'
|
|
74
|
+
// 'languageCharacters'
|
|
75
|
+
];
|
|
62
76
|
|
|
63
77
|
return (
|
|
64
78
|
<foreignObject
|
|
65
79
|
x={-(width / 2)}
|
|
66
80
|
y={y}
|
|
67
81
|
width={width}
|
|
68
|
-
height={
|
|
82
|
+
height={finalHeight}
|
|
69
83
|
transform={transform}
|
|
70
84
|
textAnchor="middle"
|
|
71
85
|
>
|
|
72
86
|
<Readable false>
|
|
73
|
-
<
|
|
87
|
+
<EditableHtml
|
|
88
|
+
className={cn(
|
|
89
|
+
{
|
|
90
|
+
[classes.bottomLabel]: side === 'bottom',
|
|
91
|
+
[classes.disabledAxisLabel]: disabledLabel
|
|
92
|
+
},
|
|
93
|
+
classes.axisLabel
|
|
94
|
+
)}
|
|
95
|
+
markup={text || ''}
|
|
96
|
+
onChange={onChange}
|
|
97
|
+
placeholder={!disabledLabel && placeholder}
|
|
98
|
+
toolbarOpts={{
|
|
99
|
+
position: side === 'bottom' ? 'top' : 'bottom',
|
|
100
|
+
noBorder: true
|
|
101
|
+
}}
|
|
102
|
+
activePlugins={activePlugins}
|
|
103
|
+
/>
|
|
74
104
|
</Readable>
|
|
75
105
|
</foreignObject>
|
|
76
106
|
);
|
|
@@ -82,8 +112,15 @@ const Label = withStyles(theme => ({
|
|
|
82
112
|
fill: color.secondary()
|
|
83
113
|
},
|
|
84
114
|
axisLabel: {
|
|
85
|
-
fontSize: theme.typography.fontSize,
|
|
86
|
-
textAlign: 'center'
|
|
115
|
+
fontSize: theme.typography.fontSize - 2,
|
|
116
|
+
textAlign: 'center',
|
|
117
|
+
padding: '0 4px'
|
|
118
|
+
},
|
|
119
|
+
disabledAxisLabel: {
|
|
120
|
+
pointerEvents: 'none'
|
|
121
|
+
},
|
|
122
|
+
bottomLabel: {
|
|
123
|
+
marginTop: '44px'
|
|
87
124
|
}
|
|
88
125
|
}))(RawLabel);
|
|
89
126
|
|
|
@@ -98,29 +135,65 @@ export class Labels extends React.Component {
|
|
|
98
135
|
static propTypes = {
|
|
99
136
|
classes: PropTypes.object,
|
|
100
137
|
className: PropTypes.string,
|
|
138
|
+
disabledLabels: PropTypes.bool,
|
|
139
|
+
placeholders: PropTypes.object,
|
|
101
140
|
value: PropTypes.shape(LabelType),
|
|
102
141
|
graphProps: PropTypes.object
|
|
103
142
|
};
|
|
104
143
|
|
|
105
144
|
static defaultProps = {};
|
|
106
145
|
|
|
146
|
+
onChangeLabel = (newValue, side) => {
|
|
147
|
+
const { value, onChange } = this.props;
|
|
148
|
+
const labels = {
|
|
149
|
+
...value,
|
|
150
|
+
[side]: newValue
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
onChange(labels);
|
|
154
|
+
};
|
|
155
|
+
|
|
107
156
|
render() {
|
|
108
|
-
const { value, graphProps } = this.props;
|
|
157
|
+
const { disabledLabels, placeholders = {}, value = {}, graphProps } = this.props;
|
|
109
158
|
|
|
110
159
|
return (
|
|
111
160
|
<React.Fragment>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
161
|
+
<Label
|
|
162
|
+
key="left"
|
|
163
|
+
side="left"
|
|
164
|
+
text={value.left}
|
|
165
|
+
disabledLabel={disabledLabels}
|
|
166
|
+
placeholder={placeholders.left}
|
|
167
|
+
graphProps={graphProps}
|
|
168
|
+
onChange={value => this.onChangeLabel(value, 'left')}
|
|
169
|
+
/>
|
|
170
|
+
<Label
|
|
171
|
+
key="top"
|
|
172
|
+
side="top"
|
|
173
|
+
text={value.top}
|
|
174
|
+
disabledLabel={disabledLabels}
|
|
175
|
+
placeholder={placeholders.top}
|
|
176
|
+
graphProps={graphProps}
|
|
177
|
+
onChange={value => this.onChangeLabel(value, 'top')}
|
|
178
|
+
/>
|
|
179
|
+
<Label
|
|
180
|
+
key="bottom"
|
|
181
|
+
side="bottom"
|
|
182
|
+
text={value.bottom}
|
|
183
|
+
disabledLabel={disabledLabels}
|
|
184
|
+
placeholder={placeholders.bottom}
|
|
185
|
+
graphProps={graphProps}
|
|
186
|
+
onChange={value => this.onChangeLabel(value, 'bottom')}
|
|
187
|
+
/>
|
|
188
|
+
<Label
|
|
189
|
+
key="right"
|
|
190
|
+
side="right"
|
|
191
|
+
text={value.right}
|
|
192
|
+
disabledLabel={disabledLabels}
|
|
193
|
+
placeholder={placeholders.right}
|
|
194
|
+
graphProps={graphProps}
|
|
195
|
+
onChange={value => this.onChangeLabel(value, 'right')}
|
|
196
|
+
/>
|
|
124
197
|
</React.Fragment>
|
|
125
198
|
);
|
|
126
199
|
}
|