@pie-lib/charting 5.16.1-beta.0 → 5.18.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.json +1 -581
- package/CHANGELOG.md +145 -1
- package/lib/actions-button.js +174 -0
- package/lib/actions-button.js.map +1 -0
- package/lib/axes.js +614 -0
- package/lib/axes.js.map +1 -0
- package/lib/bars/bar.js +86 -0
- package/lib/bars/bar.js.map +1 -0
- package/lib/bars/common/bars.js +299 -0
- package/lib/bars/common/bars.js.map +1 -0
- package/lib/bars/histogram.js +87 -0
- package/lib/bars/histogram.js.map +1 -0
- package/lib/chart-setup.js +458 -0
- package/lib/chart-setup.js.map +1 -0
- package/lib/chart-type.js +71 -0
- package/lib/chart-type.js.map +1 -0
- package/lib/chart-types.js +31 -0
- package/lib/chart-types.js.map +1 -0
- package/lib/chart.js +447 -0
- package/lib/chart.js.map +1 -0
- package/lib/common/drag-handle.js +175 -0
- package/lib/common/drag-handle.js.map +1 -0
- package/lib/common/drag-icon.js +52 -0
- package/lib/common/drag-icon.js.map +1 -0
- package/lib/common/styles.js +40 -0
- package/lib/common/styles.js.map +1 -0
- package/lib/grid.js +141 -0
- package/lib/grid.js.map +1 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/key-legend.js +111 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/line/common/drag-handle.js +151 -0
- package/lib/line/common/drag-handle.js.map +1 -0
- package/lib/line/common/line.js +257 -0
- package/lib/line/common/line.js.map +1 -0
- package/lib/line/line-cross.js +203 -0
- package/lib/line/line-cross.js.map +1 -0
- package/lib/line/line-dot.js +156 -0
- package/lib/line/line-dot.js.map +1 -0
- package/lib/mark-label.js +260 -0
- package/lib/mark-label.js.map +1 -0
- package/lib/plot/common/plot.js +281 -0
- package/lib/plot/common/plot.js.map +1 -0
- package/lib/plot/dot.js +123 -0
- package/lib/plot/dot.js.map +1 -0
- package/lib/plot/line.js +152 -0
- package/lib/plot/line.js.map +1 -0
- package/lib/shared/index.js +136 -0
- package/lib/tool-menu.js +142 -0
- package/lib/tool-menu.js.map +1 -0
- package/lib/utils.js +244 -0
- package/lib/utils.js.map +1 -0
- package/package.json +5 -38
- package/src/__tests__/__snapshots__/axes.test.jsx.snap +1 -0
- package/src/__tests__/__snapshots__/chart.test.jsx.snap +0 -18
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +61 -17
- package/src/__tests__/axes.test.jsx +0 -5
- package/src/__tests__/chart.test.jsx +8 -0
- package/src/actions-button.jsx +109 -0
- package/src/axes.jsx +4 -30
- package/src/bars/common/bars.jsx +8 -10
- package/src/chart-setup.jsx +1 -1
- package/src/chart.jsx +31 -26
- package/src/common/drag-handle.jsx +3 -3
- package/src/common/styles.js +1 -1
- package/src/grid.jsx +38 -13
- package/src/index.js +2 -1
- package/src/key-legend.jsx +75 -0
- package/src/line/common/drag-handle.jsx +3 -9
- package/src/line/common/line.jsx +2 -6
- package/src/line/line-cross.js +29 -2
- package/src/line/line-dot.js +36 -19
- package/src/mark-label.jsx +7 -2
- package/src/plot/common/plot.jsx +8 -5
- package/src/tool-menu.jsx +1 -1
package/src/bars/common/bars.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { types } from '@pie-lib/plot';
|
|
4
4
|
import { Group } from '@vx/group';
|
|
5
|
-
import { color } from '
|
|
5
|
+
import { color } from '../../../render-ui/src/index';
|
|
6
6
|
import { Bar as VxBar } from '@vx/shape';
|
|
7
7
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
8
8
|
import debug from 'debug';
|
|
@@ -39,12 +39,12 @@ const hoverHistogramColors = [
|
|
|
39
39
|
'#894A65',
|
|
40
40
|
];
|
|
41
41
|
|
|
42
|
-
const calculateFillColor = (isHovered, barColor, index, hoverHistogramColors) => {
|
|
43
|
-
if (isHovered && barColor) {
|
|
42
|
+
const calculateFillColor = (isHovered, barColor, index, hoverHistogramColors, allowRolloverEvent) => {
|
|
43
|
+
if (isHovered && barColor && allowRolloverEvent) {
|
|
44
44
|
return hoverHistogramColors[index % hoverHistogramColors.length];
|
|
45
45
|
}
|
|
46
|
-
if (isHovered) {
|
|
47
|
-
return color.
|
|
46
|
+
if (isHovered && allowRolloverEvent) {
|
|
47
|
+
return color.visualElementsColors.ROLLOVER_FILL_BAR_COLOR;
|
|
48
48
|
}
|
|
49
49
|
return barColor || null;
|
|
50
50
|
};
|
|
@@ -148,7 +148,8 @@ export class RawBar extends React.Component {
|
|
|
148
148
|
const { scale, range } = graphProps;
|
|
149
149
|
const { dragValue, isHovered } = this.state;
|
|
150
150
|
|
|
151
|
-
const
|
|
151
|
+
const allowRolloverEvent = interactive && !correctness;
|
|
152
|
+
const fillColor = calculateFillColor(isHovered, barColor, index, hoverHistogramColors, allowRolloverEvent);
|
|
152
153
|
const v = Number.isFinite(dragValue) ? dragValue : value;
|
|
153
154
|
const barWidth = xBand.bandwidth();
|
|
154
155
|
const barHeight = scale.y(range.max - v);
|
|
@@ -195,10 +196,7 @@ export class RawBar extends React.Component {
|
|
|
195
196
|
|
|
196
197
|
const Bar = withStyles(() => ({
|
|
197
198
|
bar: {
|
|
198
|
-
fill: color.
|
|
199
|
-
'&:hover': {
|
|
200
|
-
fill: color.primaryDark(),
|
|
201
|
-
},
|
|
199
|
+
fill: color.defaults.TERTIARY,
|
|
202
200
|
},
|
|
203
201
|
}))(RawBar);
|
|
204
202
|
|
package/src/chart-setup.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { color } from '
|
|
3
|
+
import { color } from '../../render-ui/src/index';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import Typography from '@material-ui/core/Typography';
|
|
6
6
|
import ChartType from './chart-type';
|
package/src/chart.jsx
CHANGED
|
@@ -2,16 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import debug from 'debug';
|
|
6
6
|
import cloneDeep from 'lodash/cloneDeep';
|
|
7
|
+
|
|
8
|
+
import { Root, createGraphProps } from '@pie-lib/plot';
|
|
9
|
+
import { AlertDialog } from '@pie-lib/config-ui';
|
|
7
10
|
import ChartGrid from './grid';
|
|
8
11
|
import ChartAxes from './axes';
|
|
9
|
-
import debug from 'debug';
|
|
10
|
-
import { color } from '@pie-lib/render-ui';
|
|
11
12
|
import { dataToXBand, getDomainAndRangeByChartType, getGridLinesAndAxisByChartType, getTopPadding } from './utils';
|
|
12
|
-
import ToolMenu from './tool-menu';
|
|
13
13
|
import chartTypes from './chart-types';
|
|
14
|
-
import
|
|
14
|
+
import ActionsButton from './actions-button';
|
|
15
15
|
import Translator from '@pie-lib/translator';
|
|
16
16
|
|
|
17
17
|
const { translator } = Translator;
|
|
@@ -25,6 +25,7 @@ export class Chart extends React.Component {
|
|
|
25
25
|
dialog: {
|
|
26
26
|
open: false,
|
|
27
27
|
},
|
|
28
|
+
actionsAnchorEl: null,
|
|
28
29
|
};
|
|
29
30
|
this.maskUid = this.generateMaskId();
|
|
30
31
|
}
|
|
@@ -174,6 +175,18 @@ export class Chart extends React.Component {
|
|
|
174
175
|
}
|
|
175
176
|
};
|
|
176
177
|
|
|
178
|
+
deleteCategory = (index) => {
|
|
179
|
+
const { data, onDataChange } = this.props;
|
|
180
|
+
|
|
181
|
+
if (typeof index !== 'number' || index < 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (data && data.length > 0) {
|
|
186
|
+
onDataChange(data.filter((_, i) => i !== index));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
177
190
|
getFilteredCategories = () => {
|
|
178
191
|
const { data, defineChart } = this.props;
|
|
179
192
|
|
|
@@ -252,15 +265,6 @@ export class Chart extends React.Component {
|
|
|
252
265
|
|
|
253
266
|
return (
|
|
254
267
|
<div className={classNames(classes.chart, classes.chartBox, className)}>
|
|
255
|
-
<div className={classes.controls}>
|
|
256
|
-
<ToolMenu
|
|
257
|
-
className={classes.toolMenu}
|
|
258
|
-
disabled={!addCategoryEnabled}
|
|
259
|
-
addCategory={() => this.addCategory()}
|
|
260
|
-
language={language}
|
|
261
|
-
/>
|
|
262
|
-
</div>
|
|
263
|
-
|
|
264
268
|
<Root
|
|
265
269
|
title={title}
|
|
266
270
|
onChangeTitle={onChangeTitle}
|
|
@@ -297,6 +301,18 @@ export class Chart extends React.Component {
|
|
|
297
301
|
top={top}
|
|
298
302
|
error={error}
|
|
299
303
|
/>
|
|
304
|
+
{addCategoryEnabled ? (
|
|
305
|
+
<foreignObject x={width - 8} y={height - 8} width={100} height={40}>
|
|
306
|
+
<div xmlns="http://www.w3.org/1999/xhtml" style={{ display: 'flex', justifyContent: 'center' }}>
|
|
307
|
+
<ActionsButton
|
|
308
|
+
categories={categories}
|
|
309
|
+
addCategory={this.addCategory}
|
|
310
|
+
deleteCategory={this.deleteCategory}
|
|
311
|
+
language={language}
|
|
312
|
+
/>
|
|
313
|
+
</div>
|
|
314
|
+
</foreignObject>
|
|
315
|
+
) : null}
|
|
300
316
|
<mask id={`${this.maskUid}`}>
|
|
301
317
|
<rect {...maskSize} fill="white" />
|
|
302
318
|
</mask>
|
|
@@ -327,21 +343,10 @@ const styles = (theme) => ({
|
|
|
327
343
|
graphBox: {
|
|
328
344
|
transform: 'translate(60px, 35px)',
|
|
329
345
|
},
|
|
330
|
-
controls: {
|
|
331
|
-
display: 'flex',
|
|
332
|
-
justifyContent: 'space-between',
|
|
333
|
-
padding: theme.spacing.unit,
|
|
334
|
-
backgroundColor: color.primaryLight(),
|
|
335
|
-
'& button': {
|
|
336
|
-
fontSize: theme.typography.fontSize,
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
346
|
svg: {
|
|
340
347
|
overflow: 'visible',
|
|
341
348
|
},
|
|
342
|
-
|
|
343
|
-
minHeight: '36px',
|
|
344
|
-
},
|
|
349
|
+
|
|
345
350
|
chartBox: {
|
|
346
351
|
width: 'min-content',
|
|
347
352
|
},
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import { gridDraggable, utils, types } from '@pie-lib/plot';
|
|
6
|
-
import { color } from '
|
|
6
|
+
import { color as enumColor } from '../../../render-ui/src/index';
|
|
7
7
|
import { correct, incorrect, disabled } from './styles';
|
|
8
8
|
import { getScale } from '../utils';
|
|
9
9
|
import DragIcon from './drag-icon';
|
|
@@ -28,7 +28,7 @@ const RawDragHandle = ({
|
|
|
28
28
|
return (
|
|
29
29
|
<svg x={x} y={scale.y(y) - 10} width={width} overflow="visible" className={classes.svgOverflowVisible}>
|
|
30
30
|
{isHovered && !correctness && interactive && (
|
|
31
|
-
<DragIcon width={width} scaleValue={scaleValue} color={
|
|
31
|
+
<DragIcon width={width} scaleValue={scaleValue} color={enumColor.defaults.BORDER_GRAY} classes={classes} />
|
|
32
32
|
)}
|
|
33
33
|
{interactive && !correctness && (
|
|
34
34
|
<ellipse
|
|
@@ -107,7 +107,7 @@ export const DragHandle = withStyles(() => ({
|
|
|
107
107
|
height: 30,
|
|
108
108
|
'&:hover': {
|
|
109
109
|
'& .handle': {
|
|
110
|
-
fill:
|
|
110
|
+
fill: enumColor.secondaryDark(),
|
|
111
111
|
height: '16px',
|
|
112
112
|
},
|
|
113
113
|
},
|
package/src/common/styles.js
CHANGED
package/src/grid.jsx
CHANGED
|
@@ -2,10 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
+
import { GridRows, GridColumns } from '@vx/grid';
|
|
5
6
|
|
|
6
|
-
import { Grid as VxGrid } from '@vx/grid';
|
|
7
7
|
import { types } from '@pie-lib/plot';
|
|
8
|
-
import { color } from '
|
|
8
|
+
import { color } from '../../render-ui/src/index';
|
|
9
9
|
|
|
10
10
|
export class Grid extends React.Component {
|
|
11
11
|
static propTypes = {
|
|
@@ -21,19 +21,44 @@ export class Grid extends React.Component {
|
|
|
21
21
|
|
|
22
22
|
render() {
|
|
23
23
|
const { classes, className, graphProps, xBand, rowTickValues, columnTickValues } = this.props;
|
|
24
|
-
const { scale = {}, size = {} } = graphProps || {};
|
|
24
|
+
const { scale = {}, size = {}, range = {} } = graphProps || {};
|
|
25
|
+
const { step = 0, labelStep = 0 } = range;
|
|
26
|
+
const highlightNonLabel = step && labelStep && step < labelStep;
|
|
27
|
+
// if highlightNonLabel is true, we need to separate the unlabled lines in order to render them in a different color
|
|
28
|
+
const { unlabeledLines, labeledLines } = (rowTickValues || []).reduce(
|
|
29
|
+
(acc, value) => {
|
|
30
|
+
if (highlightNonLabel && value % labelStep !== 0) {
|
|
31
|
+
acc.unlabeledLines.push(value);
|
|
32
|
+
} else {
|
|
33
|
+
acc.labeledLines.push(value);
|
|
34
|
+
}
|
|
35
|
+
return acc;
|
|
36
|
+
},
|
|
37
|
+
{ unlabeledLines: [], labeledLines: [] },
|
|
38
|
+
);
|
|
25
39
|
|
|
26
40
|
return (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
<g className={classNames(classes.grid, className)}>
|
|
42
|
+
<GridRows
|
|
43
|
+
scale={scale.y}
|
|
44
|
+
width={size.width}
|
|
45
|
+
tickValues={unlabeledLines}
|
|
46
|
+
lineStyle={{
|
|
47
|
+
stroke: color.fadedPrimary(),
|
|
48
|
+
strokeWidth: 1,
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
<GridRows
|
|
52
|
+
scale={scale.y}
|
|
53
|
+
width={size.width}
|
|
54
|
+
tickValues={labeledLines}
|
|
55
|
+
lineStyle={{
|
|
56
|
+
stroke: color.visualElementsColors.GRIDLINES_COLOR,
|
|
57
|
+
strokeWidth: 1,
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
<GridColumns scale={xBand} height={size.height} offset={xBand.bandwidth() / 2} tickValues={columnTickValues} />
|
|
61
|
+
</g>
|
|
37
62
|
);
|
|
38
63
|
}
|
|
39
64
|
}
|
package/src/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import Chart from './chart';
|
|
|
2
2
|
import chartTypes from './chart-types';
|
|
3
3
|
import ConfigureChartPanel from './chart-setup';
|
|
4
4
|
import ChartType from './chart-type';
|
|
5
|
+
import KeyLegend from './key-legend';
|
|
5
6
|
|
|
6
|
-
export { Chart, chartTypes, ChartType, ConfigureChartPanel };
|
|
7
|
+
export { Chart, chartTypes, ChartType, ConfigureChartPanel, KeyLegend };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import Check from '@material-ui/icons/Check';
|
|
5
|
+
import Close from '@material-ui/icons/Close';
|
|
6
|
+
import { color } from '../../render-ui/src/index';
|
|
7
|
+
import Translator from '@pie-lib/translator';
|
|
8
|
+
|
|
9
|
+
const styles = (theme) => ({
|
|
10
|
+
container: {
|
|
11
|
+
backgroundColor: color.defaults.WHITE,
|
|
12
|
+
padding: theme.spacing.unit * 2,
|
|
13
|
+
width: '355px',
|
|
14
|
+
boxShadow: 'inset 0px 1px 5px 0px #9297A6',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
gap: '16px',
|
|
18
|
+
},
|
|
19
|
+
row: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: '12px',
|
|
23
|
+
},
|
|
24
|
+
title: {
|
|
25
|
+
fontSize: theme.typography.h6.fontSize,
|
|
26
|
+
fontWeight: '700',
|
|
27
|
+
},
|
|
28
|
+
smallText: {
|
|
29
|
+
marginLeft: '2px',
|
|
30
|
+
},
|
|
31
|
+
correctIcon: {
|
|
32
|
+
backgroundColor: color.correct(),
|
|
33
|
+
borderRadius: theme.spacing.unit * 2,
|
|
34
|
+
color: color.defaults.WHITE,
|
|
35
|
+
},
|
|
36
|
+
incorrectIcon: {
|
|
37
|
+
backgroundColor: color.incorrectWithIcon(),
|
|
38
|
+
borderRadius: theme.spacing.unit * 2,
|
|
39
|
+
color: color.defaults.WHITE,
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
lastRow: {
|
|
43
|
+
marginLeft: '3px',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
gap: '12px',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const { translator } = Translator;
|
|
51
|
+
|
|
52
|
+
const KeyLegend = ({ classes, language }) => (
|
|
53
|
+
<div className={classes.container}>
|
|
54
|
+
<div className={classes.title}>Key</div>
|
|
55
|
+
<div className={classes.row}>
|
|
56
|
+
<Close className={classes.incorrectIcon} />
|
|
57
|
+
<div className={classes.text}>{translator.t('charting.keyLegend.incorrectAnswer', { lng: language })}</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div className={classes.row}>
|
|
60
|
+
<Check className={classes.correctIcon} />
|
|
61
|
+
<div className={classes.text}>{translator.t('charting.keyLegend.correctAnswer', { lng: language })}</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div className={classes.lastRow}>
|
|
64
|
+
<Check className={classes.correctIcon} fontSize={'small'} />
|
|
65
|
+
<div className={classes.smallText}>{translator.t('charting.keyLegend.correctKeyAnswer', { lng: language })}</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
KeyLegend.propTypes = {
|
|
71
|
+
classes: PropTypes.object.isRequired,
|
|
72
|
+
language: PropTypes.string,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default withStyles(styles)(KeyLegend);
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { gridDraggable, utils, types } from '@pie-lib/plot';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
5
|
-
import { color } from '
|
|
5
|
+
import { color } from '../../../../render-ui/src/index';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { correct, incorrect, disabled } from '../../common/styles';
|
|
8
8
|
|
|
@@ -44,6 +44,7 @@ class RawDragHandle extends React.Component {
|
|
|
44
44
|
classes={classes}
|
|
45
45
|
className={classNames(className, !interactive && 'non-interactive')}
|
|
46
46
|
correctness={correctness}
|
|
47
|
+
interactive={interactive}
|
|
47
48
|
{...rest}
|
|
48
49
|
/>
|
|
49
50
|
);
|
|
@@ -52,11 +53,7 @@ class RawDragHandle extends React.Component {
|
|
|
52
53
|
|
|
53
54
|
export const DragHandle = withStyles(() => ({
|
|
54
55
|
handle: {
|
|
55
|
-
fill: color.defaults.SECONDARY,
|
|
56
56
|
transition: 'fill 200ms linear, height 200ms linear',
|
|
57
|
-
'&:hover': {
|
|
58
|
-
fill: color.defaults.SECONDARY_DARK,
|
|
59
|
-
},
|
|
60
57
|
'&.correct': correct('fill'),
|
|
61
58
|
'&.incorrect': incorrect('fill'),
|
|
62
59
|
'&.non-interactive': disabled('fill'),
|
|
@@ -67,11 +64,8 @@ export const DragHandle = withStyles(() => ({
|
|
|
67
64
|
stroke: 'transparent',
|
|
68
65
|
},
|
|
69
66
|
line: {
|
|
70
|
-
stroke: color.defaults.
|
|
67
|
+
stroke: color.defaults.TEXT,
|
|
71
68
|
transition: 'fill 200ms linear, height 200ms linear',
|
|
72
|
-
'&:hover': {
|
|
73
|
-
stroke: color.defaults.SECONDARY_DARK,
|
|
74
|
-
},
|
|
75
69
|
'&.non-interactive': disabled('stroke'),
|
|
76
70
|
'&.correct': correct('stroke'),
|
|
77
71
|
'&.incorrect': incorrect('stroke'),
|
package/src/line/common/line.jsx
CHANGED
|
@@ -6,7 +6,7 @@ import { types } from '@pie-lib/plot';
|
|
|
6
6
|
import DraggableHandle, { DragHandle } from './drag-handle';
|
|
7
7
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
9
|
-
import { color } from '
|
|
9
|
+
import { color } from '../../../../render-ui/src/index';
|
|
10
10
|
|
|
11
11
|
const getData = (data, domain) => {
|
|
12
12
|
const { max } = domain || {};
|
|
@@ -121,13 +121,9 @@ export class RawLine extends React.Component {
|
|
|
121
121
|
const StyledLine = withStyles(() => ({
|
|
122
122
|
line: {
|
|
123
123
|
fill: 'transparent',
|
|
124
|
-
stroke: color.
|
|
124
|
+
stroke: color.defaults.TERTIARY,
|
|
125
125
|
strokeWidth: 3,
|
|
126
126
|
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
127
|
-
'&:hover': {
|
|
128
|
-
strokeWidth: 6,
|
|
129
|
-
stroke: color.primaryDark(),
|
|
130
|
-
},
|
|
131
127
|
},
|
|
132
128
|
}))(RawLine);
|
|
133
129
|
|
package/src/line/line-cross.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { types } from '@pie-lib/plot';
|
|
4
4
|
import { LinePath } from '@vx/shape';
|
|
5
5
|
import { Group } from '@vx/group';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
+
import { color } from '../../../render-ui/src/index';
|
|
7
8
|
import { dataToXBand } from '../utils';
|
|
8
9
|
import RawLine from './common/line';
|
|
9
10
|
|
|
10
11
|
const DraggableComponent = (props) => {
|
|
11
12
|
const { classes = {}, className, scale, x, y, r, correctness, ...rest } = props;
|
|
13
|
+
const [hover, setHover] = useState(false);
|
|
14
|
+
|
|
15
|
+
const squareSize = r * 4;
|
|
16
|
+
const squareHalf = squareSize / 2;
|
|
17
|
+
const cx = scale.x(x);
|
|
18
|
+
const cy = scale.y(y);
|
|
12
19
|
|
|
13
20
|
return (
|
|
14
21
|
<Group className={classNames(className, classes.line, correctness && correctness.value)}>
|
|
@@ -34,7 +41,27 @@ const DraggableComponent = (props) => {
|
|
|
34
41
|
strokeWidth={5}
|
|
35
42
|
style={{ pointerEvents: 'none' }}
|
|
36
43
|
/>
|
|
37
|
-
|
|
44
|
+
{hover && (
|
|
45
|
+
<rect
|
|
46
|
+
x={cx - squareHalf}
|
|
47
|
+
y={cy - squareHalf}
|
|
48
|
+
width={squareSize}
|
|
49
|
+
height={squareSize}
|
|
50
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
51
|
+
fill="none"
|
|
52
|
+
strokeWidth={2}
|
|
53
|
+
pointerEvents="none"
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
<circle
|
|
57
|
+
cx={cx}
|
|
58
|
+
cy={cy}
|
|
59
|
+
r={r * 2}
|
|
60
|
+
className={classNames(classes.transparentHandle)}
|
|
61
|
+
onMouseEnter={() => setHover(true)}
|
|
62
|
+
onMouseLeave={() => setHover(false)}
|
|
63
|
+
{...rest}
|
|
64
|
+
/>
|
|
38
65
|
</Group>
|
|
39
66
|
);
|
|
40
67
|
};
|
package/src/line/line-dot.js
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { types } from '@pie-lib/plot';
|
|
4
|
+
import { color } from '../../../render-ui/src/index';
|
|
4
5
|
import { dataToXBand } from '../utils';
|
|
5
6
|
import RawLine from './common/line';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
|
|
8
|
-
const DraggableComponent = ({ scale, x, y, className, classes, r, correctness, ...rest }) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
9
|
+
const DraggableComponent = ({ scale, x, y, className, classes, r, correctness, interactive, ...rest }) => {
|
|
10
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
11
|
+
const allowRolloverEvent = !correctness && interactive;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<g onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
|
|
15
|
+
<circle
|
|
16
|
+
cx={scale.x(x)}
|
|
17
|
+
cy={scale.y(y)}
|
|
18
|
+
r={r * 3}
|
|
19
|
+
className={classNames(classes.transparentHandle, className)}
|
|
20
|
+
pointerEvents={correctness ? 'none' : ''}
|
|
21
|
+
{...rest}
|
|
22
|
+
/>
|
|
23
|
+
<circle
|
|
24
|
+
cx={scale.x(x)}
|
|
25
|
+
cy={scale.y(y)}
|
|
26
|
+
r={r}
|
|
27
|
+
className={classNames(className, classes.handle, correctness && correctness.value)}
|
|
28
|
+
{...rest}
|
|
29
|
+
/>
|
|
30
|
+
{isHovered && allowRolloverEvent && (
|
|
31
|
+
<rect
|
|
32
|
+
x={scale.x(x) - r * 2}
|
|
33
|
+
y={scale.y(y) - r * 2}
|
|
34
|
+
width={r * 4}
|
|
35
|
+
height={r * 4}
|
|
36
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
37
|
+
strokeWidth="1"
|
|
38
|
+
fill="none"
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
</g>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
27
44
|
|
|
28
45
|
DraggableComponent.propTypes = {
|
|
29
46
|
scale: PropTypes.object,
|
package/src/mark-label.jsx
CHANGED
|
@@ -5,7 +5,7 @@ import AutosizeInput from 'react-input-autosize';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { types } from '@pie-lib/plot';
|
|
7
7
|
import { correct, incorrect, disabled } from './common/styles';
|
|
8
|
-
import { color } from '
|
|
8
|
+
import { color } from '../../render-ui/src/index';
|
|
9
9
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
10
10
|
|
|
11
11
|
const styles = (theme) => ({
|
|
@@ -14,7 +14,6 @@ const styles = (theme) => ({
|
|
|
14
14
|
fontFamily: theme.typography.fontFamily,
|
|
15
15
|
fontSize: theme.typography.fontSize,
|
|
16
16
|
border: 'none',
|
|
17
|
-
color: color.primaryDark(),
|
|
18
17
|
'&.correct': correct('color'),
|
|
19
18
|
'&.incorrect': incorrect('color'),
|
|
20
19
|
'&.disabled': {
|
|
@@ -89,6 +88,7 @@ export const MarkLabel = (props) => {
|
|
|
89
88
|
autoFocus,
|
|
90
89
|
error,
|
|
91
90
|
isHiddenLabel,
|
|
91
|
+
limitCharacters,
|
|
92
92
|
} = props;
|
|
93
93
|
|
|
94
94
|
const [label, setLabel] = useState(mark.label);
|
|
@@ -97,6 +97,10 @@ export const MarkLabel = (props) => {
|
|
|
97
97
|
let root = useRef(null);
|
|
98
98
|
|
|
99
99
|
const onChange = (e) => {
|
|
100
|
+
if (limitCharacters && e.target.value && e.target.value.length > 20) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
setLabel(e.target.value);
|
|
101
105
|
};
|
|
102
106
|
|
|
@@ -205,6 +209,7 @@ MarkLabel.propTypes = {
|
|
|
205
209
|
label: PropTypes.string,
|
|
206
210
|
}),
|
|
207
211
|
isHiddenLabel: PropTypes.bool,
|
|
212
|
+
limitCharacters: PropTypes.bool,
|
|
208
213
|
};
|
|
209
214
|
|
|
210
215
|
export default withStyles(styles)(MarkLabel);
|
package/src/plot/common/plot.jsx
CHANGED
|
@@ -5,7 +5,7 @@ import { Group } from '@vx/group';
|
|
|
5
5
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
6
6
|
import DraggableHandle, { DragHandle } from '../../common/drag-handle';
|
|
7
7
|
import debug from 'debug';
|
|
8
|
-
import { color } from '
|
|
8
|
+
import { color } from '../../../../render-ui/src/index';
|
|
9
9
|
import { bandKey } from '../../utils';
|
|
10
10
|
import { correct, incorrect } from '../../common/styles';
|
|
11
11
|
|
|
@@ -98,6 +98,7 @@ export class RawPlot extends React.Component {
|
|
|
98
98
|
const pointHeight = size.height / max;
|
|
99
99
|
const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
|
|
100
100
|
const Component = interactive ? DraggableHandle : DragHandle;
|
|
101
|
+
const allowRolloverEvent = interactive && !correctness;
|
|
101
102
|
|
|
102
103
|
return (
|
|
103
104
|
<React.Fragment>
|
|
@@ -107,13 +108,15 @@ export class RawPlot extends React.Component {
|
|
|
107
108
|
onTouchStart={this.handleMouseEnter}
|
|
108
109
|
onTouchEnd={this.handleMouseLeave}
|
|
109
110
|
>
|
|
110
|
-
{isHovered && (
|
|
111
|
+
{isHovered && allowRolloverEvent && (
|
|
111
112
|
<rect
|
|
112
113
|
x={barX}
|
|
113
114
|
y={scale.y(v)}
|
|
114
115
|
width={barWidth}
|
|
115
116
|
height={values?.length ? pointHeight * values.length : 0}
|
|
116
|
-
|
|
117
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
118
|
+
strokeWidth={'4px'}
|
|
119
|
+
fill={'transparent'}
|
|
117
120
|
/>
|
|
118
121
|
)}
|
|
119
122
|
{values.map((index) =>
|
|
@@ -150,12 +153,12 @@ export class RawPlot extends React.Component {
|
|
|
150
153
|
|
|
151
154
|
const Bar = withStyles(() => ({
|
|
152
155
|
dot: {
|
|
153
|
-
fill: color.
|
|
156
|
+
fill: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
154
157
|
'&.correct': correct('stroke'),
|
|
155
158
|
'&.incorrect': incorrect('stroke'),
|
|
156
159
|
},
|
|
157
160
|
line: {
|
|
158
|
-
stroke: color.
|
|
161
|
+
stroke: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
159
162
|
'&.correct': correct('stroke'),
|
|
160
163
|
'&.incorrect': incorrect('stroke'),
|
|
161
164
|
},
|
package/src/tool-menu.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { color } from '
|
|
4
|
+
import { color } from '../../render-ui/src/index';
|
|
5
5
|
|
|
6
6
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
7
|
import cn from 'classnames';
|