@pie-lib/plot 2.25.0 → 2.27.0-mui-update.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 +12 -6
- package/lib/draggable.js +12 -33
- package/lib/draggable.js.map +1 -1
- package/lib/graph-props.js +4 -11
- package/lib/graph-props.js.map +1 -1
- package/lib/grid-draggable.js +58 -133
- package/lib/grid-draggable.js.map +1 -1
- package/lib/index.js +1 -16
- package/lib/index.js.map +1 -1
- package/lib/label.js +74 -102
- package/lib/label.js.map +1 -1
- package/lib/root.js +192 -212
- package/lib/root.js.map +1 -1
- package/lib/trig.js +14 -61
- package/lib/trig.js.map +1 -1
- package/lib/types.js +9 -37
- package/lib/types.js.map +1 -1
- package/lib/utils.js +22 -86
- package/lib/utils.js.map +1 -1
- package/package.json +10 -7
- package/src/label.jsx +47 -61
- package/src/root.jsx +174 -127
package/src/root.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { select, mouse } from 'd3-selection';
|
|
5
5
|
import cn from 'classnames';
|
|
@@ -11,6 +11,91 @@ import { GraphPropsType } from './types';
|
|
|
11
11
|
import Label from './label';
|
|
12
12
|
import { extractTextFromHTML, isEmptyObject, isEmptyString } from './utils';
|
|
13
13
|
|
|
14
|
+
const StyledRoot = styled('div')(({ theme }) => ({
|
|
15
|
+
border: `solid 1px ${color.primaryLight()}`,
|
|
16
|
+
color: color.defaults.TEXT,
|
|
17
|
+
backgroundColor: theme.palette.common.white,
|
|
18
|
+
touchAction: 'none',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
boxSizing: 'unset', // to override the default border-box in IBX that breaks the component width layout
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const Wrapper = styled('div')({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
position: 'relative',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const DefineChartSvg = styled('svg')({
|
|
29
|
+
paddingLeft: '50px',
|
|
30
|
+
overflow: 'visible',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const ChartSvg = styled('svg')({
|
|
34
|
+
overflow: 'visible',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const GraphBox = styled('g')({
|
|
38
|
+
cursor: 'pointer',
|
|
39
|
+
userSelect: 'none',
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const GraphTitle = styled('div')(({ theme }) => ({
|
|
43
|
+
color: color.defaults.TEXT,
|
|
44
|
+
fontSize: theme.typography.fontSize + 2,
|
|
45
|
+
padding: `${theme.spacing(1.5)} ${theme.spacing(0.5)} 0`,
|
|
46
|
+
textAlign: 'center',
|
|
47
|
+
'&.disabled': {
|
|
48
|
+
pointerEvents: 'none',
|
|
49
|
+
},
|
|
50
|
+
'&.rightMargin': {
|
|
51
|
+
marginRight: '74px',
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
const ChartTitle = styled('div')(({ theme }) => ({
|
|
56
|
+
color: color.defaults.TEXT,
|
|
57
|
+
fontSize: theme.typography.fontSize + 4,
|
|
58
|
+
padding: `${theme.spacing(1.5)} ${theme.spacing(0.5)} 0`,
|
|
59
|
+
textAlign: 'center',
|
|
60
|
+
'&.disabled': {
|
|
61
|
+
pointerEvents: 'none',
|
|
62
|
+
},
|
|
63
|
+
'&.rightMargin': {
|
|
64
|
+
marginRight: '74px',
|
|
65
|
+
},
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
const TopPixelGuides = styled('div')({
|
|
69
|
+
display: 'flex',
|
|
70
|
+
paddingTop: '6px',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const TopPixelIndicator = styled('div')({
|
|
74
|
+
display: 'flex',
|
|
75
|
+
flexDirection: 'column',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
width: '100px',
|
|
78
|
+
pointerEvents: 'none',
|
|
79
|
+
userSelect: 'none',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const SidePixelGuides = styled('div')({
|
|
83
|
+
width: '70px',
|
|
84
|
+
display: 'flex',
|
|
85
|
+
flexDirection: 'column',
|
|
86
|
+
marginRight: '6px',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const SidePixelIndicator = styled('div')({
|
|
90
|
+
textAlign: 'right',
|
|
91
|
+
height: '20px',
|
|
92
|
+
pointerEvents: 'none',
|
|
93
|
+
userSelect: 'none',
|
|
94
|
+
'&:not(:last-child)': {
|
|
95
|
+
marginBottom: '80px',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
14
99
|
export class Root extends React.Component {
|
|
15
100
|
constructor(props) {
|
|
16
101
|
super(props);
|
|
@@ -32,7 +117,6 @@ export class Root extends React.Component {
|
|
|
32
117
|
labelsPlaceholders: PropTypes.object,
|
|
33
118
|
onChangeTitle: PropTypes.func,
|
|
34
119
|
onMouseMove: PropTypes.func,
|
|
35
|
-
classes: PropTypes.object.isRequired,
|
|
36
120
|
showLabels: PropTypes.bool,
|
|
37
121
|
showTitle: PropTypes.bool,
|
|
38
122
|
showPixelGuides: PropTypes.bool,
|
|
@@ -159,7 +243,6 @@ export class Root extends React.Component {
|
|
|
159
243
|
titlePlaceholder,
|
|
160
244
|
graphProps,
|
|
161
245
|
children,
|
|
162
|
-
classes,
|
|
163
246
|
defineChart,
|
|
164
247
|
onChangeTitle,
|
|
165
248
|
isChart,
|
|
@@ -200,19 +283,20 @@ export class Root extends React.Component {
|
|
|
200
283
|
const nbOfHorizontalLines = parseInt(actualHeight / 100);
|
|
201
284
|
const sideGridlinesPadding = parseInt(actualHeight % 100);
|
|
202
285
|
const { titleHeight } = this.state;
|
|
286
|
+
|
|
203
287
|
return (
|
|
204
|
-
<
|
|
288
|
+
<StyledRoot>
|
|
205
289
|
{showPixelGuides && (
|
|
206
|
-
<
|
|
290
|
+
<TopPixelGuides style={{ marginLeft: isChart ? 80 : showLabels ? 30 : 10 }}>
|
|
207
291
|
{[...Array(nbOfVerticalLines + 1).keys()].map((value) => (
|
|
208
292
|
<Readable false key={`top-guide-${value}`}>
|
|
209
|
-
<
|
|
293
|
+
<TopPixelIndicator>
|
|
210
294
|
<div>{value * 100}px</div>
|
|
211
295
|
<div>|</div>
|
|
212
|
-
</
|
|
296
|
+
</TopPixelIndicator>
|
|
213
297
|
</Readable>
|
|
214
298
|
))}
|
|
215
|
-
</
|
|
299
|
+
</TopPixelGuides>
|
|
216
300
|
)}
|
|
217
301
|
{showTitle &&
|
|
218
302
|
(disabledTitle ? (
|
|
@@ -222,31 +306,54 @@ export class Root extends React.Component {
|
|
|
222
306
|
...(isChart && { width: finalWidth }),
|
|
223
307
|
...(isEmptyString(extractTextFromHTML(title)) && { display: 'none' }),
|
|
224
308
|
}}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
309
|
+
>
|
|
310
|
+
{isChart ? (
|
|
311
|
+
<ChartTitle className="disabled" dangerouslySetInnerHTML={{ __html: title || '' }} />
|
|
312
|
+
) : (
|
|
313
|
+
<GraphTitle className="disabled" dangerouslySetInnerHTML={{ __html: title || '' }} />
|
|
314
|
+
)}
|
|
315
|
+
</div>
|
|
228
316
|
) : (
|
|
229
317
|
<div ref={(r) => (this.titleRef = r)}>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
318
|
+
{isChart ? (
|
|
319
|
+
<ChartTitle className={cn({ rightMargin: showPixelGuides })}>
|
|
320
|
+
<EditableHtml
|
|
321
|
+
style={
|
|
322
|
+
isChart && {
|
|
323
|
+
width: finalWidth,
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
markup={title || ''}
|
|
327
|
+
onChange={onChangeTitle}
|
|
328
|
+
placeholder={
|
|
329
|
+
(defineChart && titlePlaceholder) || (!disabledTitle && 'Click here to add a title for this graph')
|
|
330
|
+
}
|
|
331
|
+
toolbarOpts={{ noPadding: true, noBorder: true }}
|
|
332
|
+
activePlugins={activeTitlePlugins}
|
|
333
|
+
disableScrollbar
|
|
334
|
+
onKeyDown={this.handleKeyDown}
|
|
335
|
+
/>
|
|
336
|
+
</ChartTitle>
|
|
337
|
+
) : (
|
|
338
|
+
<GraphTitle className={cn({ rightMargin: showPixelGuides })}>
|
|
339
|
+
<EditableHtml
|
|
340
|
+
style={
|
|
341
|
+
isChart && {
|
|
342
|
+
width: finalWidth,
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
markup={title || ''}
|
|
346
|
+
onChange={onChangeTitle}
|
|
347
|
+
placeholder={
|
|
348
|
+
(defineChart && titlePlaceholder) || (!disabledTitle && 'Click here to add a title for this graph')
|
|
349
|
+
}
|
|
350
|
+
toolbarOpts={{ noPadding: true, noBorder: true }}
|
|
351
|
+
activePlugins={activeTitlePlugins}
|
|
352
|
+
disableScrollbar
|
|
353
|
+
onKeyDown={this.handleKeyDown}
|
|
354
|
+
/>
|
|
355
|
+
</GraphTitle>
|
|
356
|
+
)}
|
|
250
357
|
</div>
|
|
251
358
|
))}
|
|
252
359
|
{showLabels && !isChart && (
|
|
@@ -262,7 +369,7 @@ export class Root extends React.Component {
|
|
|
262
369
|
charactersLimit={labelsCharactersLimit}
|
|
263
370
|
/>
|
|
264
371
|
)}
|
|
265
|
-
<
|
|
372
|
+
<Wrapper>
|
|
266
373
|
{showLabels && (
|
|
267
374
|
<Label
|
|
268
375
|
side="left"
|
|
@@ -278,20 +385,35 @@ export class Root extends React.Component {
|
|
|
278
385
|
charactersLimit={labelsCharactersLimit}
|
|
279
386
|
/>
|
|
280
387
|
)}
|
|
281
|
-
|
|
282
|
-
<
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
rootRef
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
388
|
+
{defineChart ? (
|
|
389
|
+
<DefineChartSvg width={finalWidth} height={finalHeight}>
|
|
390
|
+
<GraphBox
|
|
391
|
+
ref={(r) => {
|
|
392
|
+
this.g = r;
|
|
393
|
+
if (rootRef) {
|
|
394
|
+
rootRef(r);
|
|
395
|
+
}
|
|
396
|
+
}}
|
|
397
|
+
transform={`translate(${leftPadding + (domain.padding || 0)}, ${topPadding + (range.padding || 0)})`}
|
|
398
|
+
>
|
|
399
|
+
{children}
|
|
400
|
+
</GraphBox>
|
|
401
|
+
</DefineChartSvg>
|
|
402
|
+
) : (
|
|
403
|
+
<ChartSvg width={finalWidth} height={finalHeight}>
|
|
404
|
+
<GraphBox
|
|
405
|
+
ref={(r) => {
|
|
406
|
+
this.g = r;
|
|
407
|
+
if (rootRef) {
|
|
408
|
+
rootRef(r);
|
|
409
|
+
}
|
|
410
|
+
}}
|
|
411
|
+
transform={`translate(${leftPadding + (domain.padding || 0)}, ${topPadding + (range.padding || 0)})`}
|
|
412
|
+
>
|
|
413
|
+
{children}
|
|
414
|
+
</GraphBox>
|
|
415
|
+
</ChartSvg>
|
|
416
|
+
)}
|
|
295
417
|
{showLabels && !isChart && (
|
|
296
418
|
<Label
|
|
297
419
|
side="right"
|
|
@@ -306,8 +428,7 @@ export class Root extends React.Component {
|
|
|
306
428
|
/>
|
|
307
429
|
)}
|
|
308
430
|
{showPixelGuides && (
|
|
309
|
-
<
|
|
310
|
-
className={classes.sidePixelGuides}
|
|
431
|
+
<SidePixelGuides
|
|
311
432
|
style={{
|
|
312
433
|
paddingTop: sideGridlinesPadding,
|
|
313
434
|
marginTop: 31,
|
|
@@ -315,12 +436,12 @@ export class Root extends React.Component {
|
|
|
315
436
|
>
|
|
316
437
|
{[...Array(nbOfHorizontalLines + 1).keys()].reverse().map((value) => (
|
|
317
438
|
<Readable false key={`top-guide-${value}`}>
|
|
318
|
-
<
|
|
439
|
+
<SidePixelIndicator>━ {value * 100}px</SidePixelIndicator>
|
|
319
440
|
</Readable>
|
|
320
441
|
))}
|
|
321
|
-
</
|
|
442
|
+
</SidePixelGuides>
|
|
322
443
|
)}
|
|
323
|
-
</
|
|
444
|
+
</Wrapper>
|
|
324
445
|
{showLabels && (
|
|
325
446
|
<Label
|
|
326
447
|
side="bottom"
|
|
@@ -337,83 +458,9 @@ export class Root extends React.Component {
|
|
|
337
458
|
charactersLimit={labelsCharactersLimit}
|
|
338
459
|
/>
|
|
339
460
|
)}
|
|
340
|
-
</
|
|
461
|
+
</StyledRoot>
|
|
341
462
|
);
|
|
342
463
|
}
|
|
343
464
|
}
|
|
344
465
|
|
|
345
|
-
|
|
346
|
-
const styles = (theme) => ({
|
|
347
|
-
root: {
|
|
348
|
-
border: `solid 1px ${color.primaryLight()}`,
|
|
349
|
-
color: color.defaults.TEXT,
|
|
350
|
-
backgroundColor: theme.palette.common.white,
|
|
351
|
-
touchAction: 'none',
|
|
352
|
-
position: 'relative',
|
|
353
|
-
boxSizing: 'unset', // to override the default border-box in IBX that breaks the component width layout
|
|
354
|
-
},
|
|
355
|
-
wrapper: {
|
|
356
|
-
display: 'flex',
|
|
357
|
-
position: 'relative',
|
|
358
|
-
},
|
|
359
|
-
svg: {},
|
|
360
|
-
defineChart: {
|
|
361
|
-
paddingLeft: '50px',
|
|
362
|
-
overflow: 'visible',
|
|
363
|
-
},
|
|
364
|
-
chart: {
|
|
365
|
-
overflow: 'visible',
|
|
366
|
-
},
|
|
367
|
-
graphBox: {
|
|
368
|
-
cursor: 'pointer',
|
|
369
|
-
userSelect: 'none',
|
|
370
|
-
},
|
|
371
|
-
graphTitle: {
|
|
372
|
-
color: color.defaults.TEXT,
|
|
373
|
-
fontSize: theme.typography.fontSize + 2,
|
|
374
|
-
padding: `${theme.spacing.unit * 1.5}px ${theme.spacing.unit / 2}px 0`,
|
|
375
|
-
textAlign: 'center',
|
|
376
|
-
},
|
|
377
|
-
chartTitle: {
|
|
378
|
-
color: color.defaults.TEXT,
|
|
379
|
-
fontSize: theme.typography.fontSize + 4,
|
|
380
|
-
padding: `${theme.spacing.unit * 1.5}px ${theme.spacing.unit / 2}px 0`,
|
|
381
|
-
textAlign: 'center',
|
|
382
|
-
},
|
|
383
|
-
disabledTitle: {
|
|
384
|
-
pointerEvents: 'none',
|
|
385
|
-
},
|
|
386
|
-
rightMargin: {
|
|
387
|
-
marginRight: '74px',
|
|
388
|
-
},
|
|
389
|
-
topPixelGuides: {
|
|
390
|
-
display: 'flex',
|
|
391
|
-
paddingTop: '6px',
|
|
392
|
-
},
|
|
393
|
-
topPixelIndicator: {
|
|
394
|
-
display: 'flex',
|
|
395
|
-
flexDirection: 'column',
|
|
396
|
-
alignItems: 'center',
|
|
397
|
-
width: '100px',
|
|
398
|
-
pointerEvents: 'none',
|
|
399
|
-
userSelect: 'none',
|
|
400
|
-
},
|
|
401
|
-
sidePixelGuides: {
|
|
402
|
-
width: '70px',
|
|
403
|
-
display: 'flex',
|
|
404
|
-
flexDirection: 'column',
|
|
405
|
-
marginRight: '6px',
|
|
406
|
-
},
|
|
407
|
-
sidePixelIndicator: {
|
|
408
|
-
textAlign: 'right',
|
|
409
|
-
height: '20px',
|
|
410
|
-
pointerEvents: 'none',
|
|
411
|
-
userSelect: 'none',
|
|
412
|
-
|
|
413
|
-
'&:not(:last-child)': {
|
|
414
|
-
marginBottom: '80px',
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
export default withStyles(styles)(Root);
|
|
466
|
+
export default Root;
|