@pie-lib/charting 5.24.0 → 5.25.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 +29 -1
- package/lib/actions-button.js +4 -3
- package/lib/actions-button.js.map +1 -1
- package/lib/axes.js +44 -10
- package/lib/axes.js.map +1 -1
- package/lib/bars/common/bars.js +63 -9
- package/lib/bars/common/bars.js.map +1 -1
- package/lib/bars/common/correct-check-icon.js +55 -0
- package/lib/bars/common/correct-check-icon.js.map +1 -0
- package/lib/chart.js +17 -10
- package/lib/chart.js.map +1 -1
- package/lib/common/correctness-indicators.js +99 -0
- package/lib/common/correctness-indicators.js.map +1 -0
- package/lib/common/drag-handle.js +36 -8
- package/lib/common/drag-handle.js.map +1 -1
- package/lib/line/common/drag-handle.js +32 -9
- package/lib/line/common/drag-handle.js.map +1 -1
- package/lib/line/common/line.js +5 -2
- package/lib/line/common/line.js.map +1 -1
- package/lib/line/line-cross.js +26 -5
- package/lib/line/line-cross.js.map +1 -1
- package/lib/line/line-dot.js +24 -4
- package/lib/line/line-dot.js.map +1 -1
- package/lib/mark-label.js +18 -7
- package/lib/mark-label.js.map +1 -1
- package/lib/plot/common/plot.js +119 -9
- package/lib/plot/common/plot.js.map +1 -1
- package/lib/plot/dot.js +17 -4
- package/lib/plot/dot.js.map +1 -1
- package/lib/plot/line.js +19 -6
- package/lib/plot/line.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/__snapshots__/axes.test.jsx.snap +5 -1
- package/src/__tests__/__snapshots__/chart.test.jsx.snap +6 -3
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +62 -56
- package/src/actions-button.jsx +3 -2
- package/src/axes.jsx +37 -3
- package/src/bars/common/bars.jsx +57 -4
- package/src/bars/common/correct-check-icon.jsx +20 -0
- package/src/chart.jsx +12 -3
- package/src/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +3 -0
- package/src/common/correctness-indicators.jsx +55 -0
- package/src/common/drag-handle.jsx +28 -14
- package/src/line/common/__tests__/__snapshots__/drag-handle.test.jsx.snap +5 -0
- package/src/line/common/__tests__/__snapshots__/line.test.jsx.snap +2 -0
- package/src/line/common/drag-handle.jsx +31 -8
- package/src/line/common/line.jsx +3 -1
- package/src/line/line-cross.js +25 -3
- package/src/line/line-dot.js +40 -3
- package/src/mark-label.jsx +73 -58
- package/src/plot/common/__tests__/__snapshots__/plot.test.jsx.snap +1 -0
- package/src/plot/common/plot.jsx +114 -5
- package/src/plot/dot.js +19 -3
- package/src/plot/line.js +18 -4
|
@@ -1,67 +1,73 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`MarkLabel snapshot renders 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
<div>
|
|
5
|
+
<AutosizeInput
|
|
6
|
+
injectStyles={true}
|
|
7
|
+
inputClassName=""
|
|
8
|
+
inputRef={[Function]}
|
|
9
|
+
inputStyle={
|
|
10
|
+
Object {
|
|
11
|
+
"background": "transparent",
|
|
12
|
+
"boxSizing": "border-box",
|
|
13
|
+
"minWidth": undefined,
|
|
14
|
+
"paddingLeft": 0,
|
|
15
|
+
"paddingRight": 0,
|
|
16
|
+
"textAlign": "center",
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
minWidth={1}
|
|
20
|
+
onBlur={[Function]}
|
|
21
|
+
onChange={[Function]}
|
|
22
|
+
style={
|
|
23
|
+
Object {
|
|
24
|
+
"left": 0,
|
|
25
|
+
"marginTop": "0",
|
|
26
|
+
"minWidth": undefined,
|
|
27
|
+
"pointerEvents": "auto",
|
|
28
|
+
"position": "fixed",
|
|
29
|
+
"top": 0,
|
|
30
|
+
"transform": "rotate(undefineddeg)",
|
|
31
|
+
"transformOrigin": "left",
|
|
32
|
+
"visibility": "unset",
|
|
33
|
+
}
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
34
37
|
`;
|
|
35
38
|
|
|
36
39
|
exports[`MarkLabel snapshot renders 2`] = `
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
<div>
|
|
41
|
+
<AutosizeInput
|
|
42
|
+
injectStyles={true}
|
|
43
|
+
inputClassName=""
|
|
44
|
+
inputRef={[Function]}
|
|
45
|
+
inputStyle={
|
|
46
|
+
Object {
|
|
47
|
+
"background": "transparent",
|
|
48
|
+
"boxSizing": "border-box",
|
|
49
|
+
"minWidth": undefined,
|
|
50
|
+
"paddingLeft": 0,
|
|
51
|
+
"paddingRight": 0,
|
|
52
|
+
"textAlign": "center",
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
minWidth={1}
|
|
56
|
+
onBlur={[Function]}
|
|
57
|
+
onChange={[Function]}
|
|
58
|
+
style={
|
|
59
|
+
Object {
|
|
60
|
+
"left": 0,
|
|
61
|
+
"marginTop": "0",
|
|
62
|
+
"minWidth": undefined,
|
|
63
|
+
"pointerEvents": "auto",
|
|
64
|
+
"position": "fixed",
|
|
65
|
+
"top": 0,
|
|
66
|
+
"transform": "rotate(undefineddeg)",
|
|
67
|
+
"transformOrigin": "left",
|
|
68
|
+
"visibility": "unset",
|
|
69
|
+
}
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
67
73
|
`;
|
package/src/actions-button.jsx
CHANGED
|
@@ -20,10 +20,10 @@ export class ActionsButton extends React.Component {
|
|
|
20
20
|
|
|
21
21
|
static propTypes = {
|
|
22
22
|
classes: PropTypes.object.isRequired,
|
|
23
|
-
categories: PropTypes.array,
|
|
24
23
|
addCategory: PropTypes.func.isRequired,
|
|
25
24
|
deleteCategory: PropTypes.func.isRequired,
|
|
26
|
-
language: PropTypes.string
|
|
25
|
+
language: PropTypes.string,
|
|
26
|
+
categories: PropTypes.array,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
handleActionsClick = (event) => {
|
|
@@ -91,6 +91,7 @@ const styles = (theme) => ({
|
|
|
91
91
|
cursor: 'pointer',
|
|
92
92
|
fontSize: theme.typography.fontSize,
|
|
93
93
|
color: color.tertiary(),
|
|
94
|
+
padding: theme.spacing.unit,
|
|
94
95
|
},
|
|
95
96
|
actionsPaper: {
|
|
96
97
|
padding: theme.spacing.unit,
|
package/src/axes.jsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import { AxisLeft, AxisBottom } from '@vx/axis';
|
|
5
|
+
import Checkbox from '@material-ui/core/Checkbox';
|
|
6
|
+
|
|
4
7
|
import { types } from '@pie-lib/plot';
|
|
5
8
|
import { color } from '@pie-lib/render-ui';
|
|
6
9
|
import { AlertDialog } from '@pie-lib/config-ui';
|
|
7
|
-
import {
|
|
10
|
+
import { TickCorrectnessIndicator } from './common/correctness-indicators';
|
|
8
11
|
import { bandKey, getTickValues, getRotateAngle } from './utils';
|
|
9
12
|
import MarkLabel from './mark-label';
|
|
10
|
-
import Checkbox from '@material-ui/core/Checkbox';
|
|
11
13
|
|
|
12
14
|
export class TickComponent extends React.Component {
|
|
13
15
|
static propTypes = {
|
|
@@ -126,6 +128,7 @@ export class TickComponent extends React.Component {
|
|
|
126
128
|
error,
|
|
127
129
|
autoFocus,
|
|
128
130
|
hiddenLabelRef,
|
|
131
|
+
showCorrectness,
|
|
129
132
|
} = this.props;
|
|
130
133
|
|
|
131
134
|
if (!formattedValue) {
|
|
@@ -150,7 +153,7 @@ export class TickComponent extends React.Component {
|
|
|
150
153
|
<g>
|
|
151
154
|
<foreignObject
|
|
152
155
|
x={bandWidth ? barX : x - barWidth / 2}
|
|
153
|
-
y={
|
|
156
|
+
y={18}
|
|
154
157
|
width={barWidth}
|
|
155
158
|
height={4}
|
|
156
159
|
style={{ pointerEvents: 'none', overflow: 'visible' }}
|
|
@@ -178,6 +181,12 @@ export class TickComponent extends React.Component {
|
|
|
178
181
|
correctness={correctness}
|
|
179
182
|
error={error && error[index]}
|
|
180
183
|
limitCharacters
|
|
184
|
+
correctnessIndicator={
|
|
185
|
+
showCorrectness &&
|
|
186
|
+
correctness && (
|
|
187
|
+
<TickCorrectnessIndicator correctness={correctness} interactive={interactive} classes={classes} />
|
|
188
|
+
)
|
|
189
|
+
}
|
|
181
190
|
/>
|
|
182
191
|
</foreignObject>
|
|
183
192
|
|
|
@@ -313,6 +322,7 @@ TickComponent.propTypes = {
|
|
|
313
322
|
changeEditableEnabled: PropTypes.bool,
|
|
314
323
|
autoFocus: PropTypes.bool,
|
|
315
324
|
onAutoFocusUsed: PropTypes.func,
|
|
325
|
+
showCorrectness: PropTypes.bool,
|
|
316
326
|
};
|
|
317
327
|
|
|
318
328
|
export class RawChartAxes extends React.Component {
|
|
@@ -334,6 +344,7 @@ export class RawChartAxes extends React.Component {
|
|
|
334
344
|
changeEditableEnabled: PropTypes.bool,
|
|
335
345
|
autoFocus: PropTypes.bool,
|
|
336
346
|
onAutoFocusUsed: PropTypes.func,
|
|
347
|
+
showCorrectness: PropTypes.bool,
|
|
337
348
|
};
|
|
338
349
|
|
|
339
350
|
state = { height: 0, width: 0 };
|
|
@@ -376,6 +387,7 @@ export class RawChartAxes extends React.Component {
|
|
|
376
387
|
autoFocus,
|
|
377
388
|
onAutoFocusUsed,
|
|
378
389
|
error,
|
|
390
|
+
showCorrectness,
|
|
379
391
|
} = this.props;
|
|
380
392
|
|
|
381
393
|
const { axis, axisLine, tick } = classes;
|
|
@@ -425,6 +437,7 @@ export class RawChartAxes extends React.Component {
|
|
|
425
437
|
x: props.x,
|
|
426
438
|
y: props.y,
|
|
427
439
|
formattedValue: props.formattedValue,
|
|
440
|
+
showCorrectness,
|
|
428
441
|
};
|
|
429
442
|
|
|
430
443
|
return <TickComponent {...properties} />;
|
|
@@ -491,6 +504,27 @@ const ChartAxes = withStyles(
|
|
|
491
504
|
customColor: {
|
|
492
505
|
color: `${color.tertiary()} !important`,
|
|
493
506
|
},
|
|
507
|
+
correctnessIcon: {
|
|
508
|
+
borderRadius: theme.spacing.unit * 2,
|
|
509
|
+
color: color.defaults.WHITE,
|
|
510
|
+
fontSize: '16px',
|
|
511
|
+
width: '16px',
|
|
512
|
+
height: '16px',
|
|
513
|
+
padding: '2px',
|
|
514
|
+
border: `1px solid ${color.defaults.WHITE}`,
|
|
515
|
+
boxSizing: 'unset', // to override the default border-box in IBX
|
|
516
|
+
},
|
|
517
|
+
incorrectIcon: {
|
|
518
|
+
backgroundColor: color.incorrectWithIcon(),
|
|
519
|
+
},
|
|
520
|
+
correctIcon: {
|
|
521
|
+
backgroundColor: color.correct(),
|
|
522
|
+
},
|
|
523
|
+
tickContainer: {
|
|
524
|
+
display: 'flex',
|
|
525
|
+
flexDirection: 'column',
|
|
526
|
+
alignItems: 'center',
|
|
527
|
+
},
|
|
494
528
|
}),
|
|
495
529
|
{ withTheme: true },
|
|
496
530
|
)(RawChartAxes);
|
package/src/bars/common/bars.jsx
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { types } from '@pie-lib/plot';
|
|
4
3
|
import { Group } from '@vx/group';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
4
|
import { Bar as VxBar } from '@vx/shape';
|
|
7
5
|
import { withStyles } from '@material-ui/core/styles/index';
|
|
8
6
|
import debug from 'debug';
|
|
7
|
+
|
|
8
|
+
import { color } from '@pie-lib/render-ui';
|
|
9
|
+
import { types } from '@pie-lib/plot';
|
|
9
10
|
import { bandKey } from '../../utils';
|
|
10
11
|
import DraggableHandle, { DragHandle } from '../../common/drag-handle';
|
|
12
|
+
import { CorrectCheckIcon } from './correct-check-icon';
|
|
11
13
|
|
|
12
14
|
const log = debug('pie-lib:chart:bars');
|
|
13
15
|
const histogramColors = [
|
|
@@ -64,6 +66,7 @@ export class RawBar extends React.Component {
|
|
|
64
66
|
value: PropTypes.string,
|
|
65
67
|
label: PropTypes.string,
|
|
66
68
|
}),
|
|
69
|
+
correctData: PropTypes.array,
|
|
67
70
|
};
|
|
68
71
|
|
|
69
72
|
constructor(props) {
|
|
@@ -144,6 +147,7 @@ export class RawBar extends React.Component {
|
|
|
144
147
|
correctness,
|
|
145
148
|
barColor,
|
|
146
149
|
defineChart,
|
|
150
|
+
correctData,
|
|
147
151
|
} = this.props;
|
|
148
152
|
const { scale, range } = graphProps;
|
|
149
153
|
const { dragValue, isHovered } = this.state;
|
|
@@ -156,9 +160,11 @@ export class RawBar extends React.Component {
|
|
|
156
160
|
const barX = xBand(bandKey({ label }, index));
|
|
157
161
|
const rawY = range.max - v;
|
|
158
162
|
const yy = range.max - rawY;
|
|
163
|
+
const correctValue = correctData ? correctData.find((d) => d.label === label) : null;
|
|
159
164
|
log('label:', label, 'barX:', barX, 'v: ', v, 'barHeight:', barHeight, 'barWidth: ', barWidth);
|
|
160
165
|
|
|
161
166
|
const Component = interactive ? DraggableHandle : DragHandle;
|
|
167
|
+
const isHistogram = !!barColor;
|
|
162
168
|
|
|
163
169
|
return (
|
|
164
170
|
<g
|
|
@@ -176,6 +182,40 @@ export class RawBar extends React.Component {
|
|
|
176
182
|
className={classes.bar}
|
|
177
183
|
style={{ fill: fillColor }}
|
|
178
184
|
/>
|
|
185
|
+
{correctness &&
|
|
186
|
+
correctness.value === 'incorrect' &&
|
|
187
|
+
(() => {
|
|
188
|
+
const correctVal = parseFloat(correctValue && correctValue.value);
|
|
189
|
+
if (isNaN(correctVal)) return null;
|
|
190
|
+
const correctPxHeight = scale.y(range.max - correctVal);
|
|
191
|
+
const actualPxHeight = barHeight;
|
|
192
|
+
const diffPx = Math.abs(correctPxHeight - actualPxHeight);
|
|
193
|
+
const yDiff = scale.y(correctVal);
|
|
194
|
+
const indicatorBarColor = correctPxHeight > actualPxHeight ? color.borderGray() : color.defaults.WHITE;
|
|
195
|
+
const yToRender = correctPxHeight > actualPxHeight ? yDiff : yDiff - diffPx;
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<>
|
|
199
|
+
<VxBar
|
|
200
|
+
x={barX + 2} // add 2px for the stroke (the dashed border)
|
|
201
|
+
y={yToRender}
|
|
202
|
+
width={barWidth - 4} // substract 4px for the total stroke
|
|
203
|
+
height={diffPx}
|
|
204
|
+
className={classes.bar}
|
|
205
|
+
style={{
|
|
206
|
+
stroke: indicatorBarColor,
|
|
207
|
+
strokeWidth: 2,
|
|
208
|
+
strokeDasharray: '5,2',
|
|
209
|
+
fill: 'none',
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
{/* adjust the position based on whether it's a histogram or not, because the histogram does not have space for the icon on the side */}
|
|
213
|
+
<foreignObject x={barX + barWidth - (isHistogram ? 24 : 14)} y={yDiff - 12} width={24} height={24}>
|
|
214
|
+
<CorrectCheckIcon dashColor={indicatorBarColor} />
|
|
215
|
+
</foreignObject>
|
|
216
|
+
</>
|
|
217
|
+
);
|
|
218
|
+
})()}
|
|
179
219
|
<Component
|
|
180
220
|
x={barX}
|
|
181
221
|
y={v}
|
|
@@ -194,15 +234,27 @@ export class RawBar extends React.Component {
|
|
|
194
234
|
}
|
|
195
235
|
}
|
|
196
236
|
|
|
197
|
-
const Bar = withStyles(() => ({
|
|
237
|
+
const Bar = withStyles((theme) => ({
|
|
198
238
|
bar: {
|
|
199
239
|
fill: color.defaults.TERTIARY,
|
|
200
240
|
},
|
|
241
|
+
correctIcon: {
|
|
242
|
+
backgroundColor: color.correct(),
|
|
243
|
+
borderRadius: theme.spacing.unit * 2,
|
|
244
|
+
color: color.defaults.WHITE,
|
|
245
|
+
fontSize: '10px',
|
|
246
|
+
width: '10px',
|
|
247
|
+
height: '10px',
|
|
248
|
+
padding: '2px',
|
|
249
|
+
border: `1px solid ${color.defaults.WHITE}`,
|
|
250
|
+
boxSizing: 'unset', // to override the default border-box in IBX
|
|
251
|
+
},
|
|
201
252
|
}))(RawBar);
|
|
202
253
|
|
|
203
254
|
export class Bars extends React.Component {
|
|
204
255
|
static propTypes = {
|
|
205
256
|
data: PropTypes.array,
|
|
257
|
+
correctData: PropTypes.array,
|
|
206
258
|
onChangeCategory: PropTypes.func,
|
|
207
259
|
defineChart: PropTypes.bool,
|
|
208
260
|
xBand: PropTypes.func,
|
|
@@ -211,7 +263,7 @@ export class Bars extends React.Component {
|
|
|
211
263
|
};
|
|
212
264
|
|
|
213
265
|
render() {
|
|
214
|
-
const { data, graphProps, xBand, onChangeCategory, defineChart, histogram } = this.props;
|
|
266
|
+
const { data, graphProps, xBand, onChangeCategory, defineChart, histogram, correctData } = this.props;
|
|
215
267
|
|
|
216
268
|
return (
|
|
217
269
|
<Group>
|
|
@@ -227,6 +279,7 @@ export class Bars extends React.Component {
|
|
|
227
279
|
onChangeCategory={(category) => onChangeCategory(index, category)}
|
|
228
280
|
graphProps={graphProps}
|
|
229
281
|
correctness={d.correctness}
|
|
282
|
+
correctData={correctData}
|
|
230
283
|
barColor={
|
|
231
284
|
histogram &&
|
|
232
285
|
(histogramColors[index] ? histogramColors[index] : histogramColors[index % histogramColors.length])
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const CorrectCheckIcon = ({ dashColor }) => (
|
|
4
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5
|
+
<circle cx="12" cy="12" r="11" fill="white" stroke={dashColor || '#7E8494'} strokeWidth="2" strokeDasharray="5 5" />
|
|
6
|
+
<mask id="path-2-outside-1_3089_3799" maskUnits="userSpaceOnUse" x="2" y="3" width="19" height="18" fill="black">
|
|
7
|
+
<rect fill="white" x="2" y="3" width="19" height="18" />
|
|
8
|
+
<path d="M12 20C9.125 20 6.5 18.5 5.0625 16C3.625 13.5312 3.625 10.5 5.0625 8C6.5 5.53125 9.125 4 12 4C14.8438 4 17.4688 5.53125 18.9062 8C20.3438 10.5 20.3438 13.5312 18.9062 16C17.4688 18.5 14.8438 20 12 20ZM15.5312 10.5312H15.5C15.8125 10.25 15.8125 9.78125 15.5 9.46875C15.2188 9.1875 14.75 9.1875 14.4688 9.46875L11 12.9688L9.53125 11.5C9.21875 11.1875 8.75 11.1875 8.46875 11.5C8.15625 11.7812 8.15625 12.25 8.46875 12.5312L10.4688 14.5312C10.75 14.8438 11.2188 14.8438 11.5312 14.5312L15.5312 10.5312Z" />
|
|
9
|
+
</mask>
|
|
10
|
+
<path
|
|
11
|
+
d="M12 20C9.125 20 6.5 18.5 5.0625 16C3.625 13.5312 3.625 10.5 5.0625 8C6.5 5.53125 9.125 4 12 4C14.8438 4 17.4688 5.53125 18.9062 8C20.3438 10.5 20.3438 13.5312 18.9062 16C17.4688 18.5 14.8438 20 12 20ZM15.5312 10.5312H15.5C15.8125 10.25 15.8125 9.78125 15.5 9.46875C15.2188 9.1875 14.75 9.1875 14.4688 9.46875L11 12.9688L9.53125 11.5C9.21875 11.1875 8.75 11.1875 8.46875 11.5C8.15625 11.7812 8.15625 12.25 8.46875 12.5312L10.4688 14.5312C10.75 14.8438 11.2188 14.8438 11.5312 14.5312L15.5312 10.5312Z"
|
|
12
|
+
fill="#0EA449"
|
|
13
|
+
/>
|
|
14
|
+
<path
|
|
15
|
+
d="M5.0625 16L5.92942 15.5015L5.92668 15.4968L5.0625 16ZM5.0625 8L4.19831 7.4968L4.19559 7.50153L5.0625 8ZM18.9062 8L19.7732 7.50152L19.7704 7.49681L18.9062 8ZM18.9062 16L18.0421 15.4968L18.0393 15.5015L18.9062 16ZM15.5312 10.5312L16.2384 11.2384L17.9455 9.53125H15.5312V10.5312ZM15.5 10.5312L14.831 9.78796L12.894 11.5312H15.5V10.5312ZM14.4688 9.46875L13.7616 8.76164L13.7585 8.76482L14.4688 9.46875ZM11 12.9688L10.2929 13.6759L11.0032 14.3861L11.7103 13.6727L11 12.9688ZM8.46875 11.5L9.13771 12.2433L9.17684 12.2081L9.21204 12.169L8.46875 11.5ZM8.46875 12.5312L9.17586 11.8241L9.15726 11.8055L9.13771 11.788L8.46875 12.5312ZM10.4688 14.5312L11.212 13.8623L11.1945 13.8427L11.1759 13.8241L10.4688 14.5312ZM12 20V19C9.479 19 7.18657 17.6879 5.92941 15.5015L5.0625 16L4.19559 16.4985C5.81343 19.3121 8.771 21 12 21V20ZM5.0625 16L5.92668 15.4968C4.6714 13.341 4.66824 10.6918 5.92941 8.49847L5.0625 8L4.19559 7.50153C2.58176 10.3082 2.5786 13.7215 4.19832 16.5032L5.0625 16ZM5.0625 8L5.92668 8.50319C7.18712 6.33851 9.48502 5 12 5V4V3C8.76498 3 5.81288 4.72399 4.19832 7.49681L5.0625 8ZM12 4V5C14.4816 5 16.7805 6.33661 18.0421 8.50319L18.9062 8L19.7704 7.49681C18.157 4.72589 15.2059 3 12 3V4ZM18.9062 8L18.0393 8.49847C19.3005 10.6918 19.2973 13.341 18.0421 15.4968L18.9062 16L19.7704 16.5032C21.3902 13.7215 21.387 10.3082 19.7732 7.50153L18.9062 8ZM18.9062 16L18.0393 15.5015C16.7811 17.6898 14.4876 19 12 19V20V21C15.1999 21 18.1564 19.3102 19.7732 16.4985L18.9062 16ZM15.5312 10.5312V9.53125H15.5V10.5312V11.5312H15.5312V10.5312ZM15.5 10.5312L16.169 11.2745C16.9447 10.5764 16.8883 9.44281 16.2071 8.76164L15.5 9.46875L14.7929 10.1759C14.7696 10.1525 14.7344 10.0966 14.7344 10.0117C14.7344 9.92377 14.7735 9.83972 14.831 9.78796L15.5 10.5312ZM15.5 9.46875L16.2071 8.76164C15.5353 8.08987 14.4334 8.08987 13.7616 8.76164L14.4688 9.46875L15.1759 10.1759C15.1167 10.235 15.0442 10.2578 14.9844 10.2578C14.9245 10.2578 14.8521 10.235 14.7929 10.1759L15.5 9.46875ZM14.4688 9.46875L13.7585 8.76482L10.2897 12.2648L11 12.9688L11.7103 13.6727L15.179 10.1727L14.4688 9.46875ZM11 12.9688L11.7071 12.2616L10.2384 10.7929L9.53125 11.5L8.82414 12.2071L10.2929 13.6759L11 12.9688ZM9.53125 11.5L10.2384 10.7929C9.55719 10.1117 8.42362 10.0553 7.72546 10.831L8.46875 11.5L9.21204 12.169C9.16028 12.2265 9.07623 12.2656 8.98828 12.2656C8.90344 12.2656 8.84748 12.2304 8.82414 12.2071L9.53125 11.5ZM8.46875 11.5L7.79979 10.7567C7.04591 11.4352 7.04591 12.5961 7.79979 13.2745L8.46875 12.5312L9.13771 11.788C9.19301 11.8377 9.23438 11.9208 9.23438 12.0156C9.23438 12.1105 9.19301 12.1935 9.13771 12.2433L8.46875 11.5ZM8.46875 12.5312L7.76164 13.2384L9.76164 15.2384L10.4688 14.5312L11.1759 13.8241L9.17586 11.8241L8.46875 12.5312ZM10.4688 14.5312L9.72546 15.2002C10.4236 15.976 11.5572 15.9195 12.2384 15.2384L11.5312 14.5312L10.8241 13.8241C10.8475 13.8008 10.9034 13.7656 10.9883 13.7656C11.0762 13.7656 11.1603 13.8048 11.212 13.8623L10.4688 14.5312ZM11.5312 14.5312L12.2384 15.2384L16.2384 11.2384L15.5312 10.5312L14.8241 9.82414L10.8241 13.8241L11.5312 14.5312Z"
|
|
16
|
+
fill="white"
|
|
17
|
+
mask="url(#path-2-outside-1_3089_3799)"
|
|
18
|
+
/>
|
|
19
|
+
</svg>
|
|
20
|
+
);
|
package/src/chart.jsx
CHANGED
|
@@ -73,6 +73,12 @@ export class Chart extends React.Component {
|
|
|
73
73
|
language: PropTypes.string,
|
|
74
74
|
mathMlOptions: PropTypes.object,
|
|
75
75
|
labelsCharactersLimit: PropTypes.number,
|
|
76
|
+
correctData: PropTypes.arrayOf(
|
|
77
|
+
PropTypes.shape({
|
|
78
|
+
label: PropTypes.string,
|
|
79
|
+
value: PropTypes.number,
|
|
80
|
+
}),
|
|
81
|
+
),
|
|
76
82
|
};
|
|
77
83
|
|
|
78
84
|
static defaultProps = {
|
|
@@ -223,6 +229,7 @@ export class Chart extends React.Component {
|
|
|
223
229
|
mathMlOptions = {},
|
|
224
230
|
language,
|
|
225
231
|
labelsCharactersLimit,
|
|
232
|
+
correctData,
|
|
226
233
|
} = this.props;
|
|
227
234
|
let { chartType } = this.props;
|
|
228
235
|
|
|
@@ -244,7 +251,7 @@ export class Chart extends React.Component {
|
|
|
244
251
|
|
|
245
252
|
log('[render] common:', common);
|
|
246
253
|
|
|
247
|
-
const maskSize = { x: -10, y: -75, width: width + 20, height: height +
|
|
254
|
+
const maskSize = { x: -10, y: -75, width: width + 20, height: height + 130 };
|
|
248
255
|
const { scale } = common.graphProps;
|
|
249
256
|
const xBand = dataToXBand(scale.x, categories, width, chartType);
|
|
250
257
|
|
|
@@ -300,10 +307,11 @@ export class Chart extends React.Component {
|
|
|
300
307
|
changeEditableEnabled={changeEditableEnabled}
|
|
301
308
|
top={top}
|
|
302
309
|
error={error}
|
|
310
|
+
showCorrectness={chartType === 'linePlot' || chartType === 'dotPlot'}
|
|
303
311
|
/>
|
|
304
312
|
{addCategoryEnabled ? (
|
|
305
|
-
<foreignObject x={width
|
|
306
|
-
<div xmlns="http://www.w3.org/1999/xhtml" style={{ display: 'flex', justifyContent: '
|
|
313
|
+
<foreignObject x={width} y={height - 16} width={width} height={height}>
|
|
314
|
+
<div xmlns="http://www.w3.org/1999/xhtml" style={{ display: 'flex', justifyContent: 'flex-start' }}>
|
|
307
315
|
<ActionsButton
|
|
308
316
|
categories={categories}
|
|
309
317
|
addCategory={this.addCategory}
|
|
@@ -324,6 +332,7 @@ export class Chart extends React.Component {
|
|
|
324
332
|
defineChart={defineChart}
|
|
325
333
|
onChange={this.changeData}
|
|
326
334
|
onChangeCategory={this.changeCategory}
|
|
335
|
+
correctData={correctData}
|
|
327
336
|
/>
|
|
328
337
|
</g>
|
|
329
338
|
</Root>
|
|
@@ -5,8 +5,11 @@ exports[`BasePoint snapshot renders 1`] = `
|
|
|
5
5
|
className="className"
|
|
6
6
|
classes={
|
|
7
7
|
Object {
|
|
8
|
+
"correctIcon": "RawDragHandle-correctIcon-5",
|
|
9
|
+
"correctnessIcon": "RawDragHandle-correctnessIcon-7",
|
|
8
10
|
"handle": "RawDragHandle-handle-1",
|
|
9
11
|
"handleContainer": "RawDragHandle-handleContainer-3",
|
|
12
|
+
"incorrectIcon": "RawDragHandle-incorrectIcon-6",
|
|
10
13
|
"svgOverflowVisible": "RawDragHandle-svgOverflowVisible-4",
|
|
11
14
|
"transparentHandle": "RawDragHandle-transparentHandle-2",
|
|
12
15
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import Check from '@material-ui/icons/Check';
|
|
4
|
+
import Close from '@material-ui/icons/Close';
|
|
5
|
+
|
|
6
|
+
export const CorrectnessIndicator = ({ scale, x, y, classes, r, correctness, interactive }) => {
|
|
7
|
+
if (!correctness || !interactive) return null;
|
|
8
|
+
const cx = scale ? scale.x(x) : x;
|
|
9
|
+
const cy = scale ? scale.y(y) : y;
|
|
10
|
+
const isCorrect = correctness.value === 'correct';
|
|
11
|
+
const iconClass = isCorrect ? classes.correctIcon : classes.incorrectIcon;
|
|
12
|
+
|
|
13
|
+
// the icon is 16px + 2px padding + 1px border, so total size is 22px
|
|
14
|
+
return (
|
|
15
|
+
<foreignObject x={cx - 11} y={cy - 11} width={22} height={22}>
|
|
16
|
+
{isCorrect ? (
|
|
17
|
+
<Check className={classNames(classes.correctnessIcon, iconClass)} title={correctness.label} />
|
|
18
|
+
) : (
|
|
19
|
+
<Close className={classNames(classes.correctnessIcon, iconClass)} title={correctness.label} />
|
|
20
|
+
)}
|
|
21
|
+
</foreignObject>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const SmallCorrectPointIndicator = ({ scale, x, r, correctness, classes, correctData, label }) => {
|
|
26
|
+
if (correctness && correctness.value === 'incorrect') {
|
|
27
|
+
const correctVal = parseFloat(correctData.find((d) => d.label === label)?.value);
|
|
28
|
+
if (isNaN(correctVal)) return null;
|
|
29
|
+
const correctPxY = scale.y(correctVal);
|
|
30
|
+
const yToRender = correctPxY - 7.5;
|
|
31
|
+
const xToRender = scale.x(x) - 7.5;
|
|
32
|
+
|
|
33
|
+
// small circle has 10px font + 2px padding + 1px border, so total size is 15px
|
|
34
|
+
return (
|
|
35
|
+
<foreignObject x={xToRender} y={yToRender} width={15} height={15}>
|
|
36
|
+
<Check
|
|
37
|
+
className={classNames(classes.correctnessIcon, classes.correctIcon, classes.smallIcon)}
|
|
38
|
+
title={correctness.label}
|
|
39
|
+
/>
|
|
40
|
+
</foreignObject>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const TickCorrectnessIndicator = ({ classes, correctness, interactive }) => {
|
|
48
|
+
if (!correctness || !interactive) return null;
|
|
49
|
+
|
|
50
|
+
return correctness.value === 'correct' ? (
|
|
51
|
+
<Check className={classNames(classes.correctnessIcon, classes.correctIcon)} title={correctness.label} />
|
|
52
|
+
) : (
|
|
53
|
+
<Close className={classNames(classes.correctnessIcon, classes.incorrectIcon)} title={correctness.label} />
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -2,6 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
+
import Check from '@material-ui/icons/Check';
|
|
6
|
+
import Close from '@material-ui/icons/Close';
|
|
7
|
+
|
|
5
8
|
import { gridDraggable, utils, types } from '@pie-lib/plot';
|
|
6
9
|
import { color as enumColor } from '@pie-lib/render-ui';
|
|
7
10
|
import { correct, incorrect, disabled } from './styles';
|
|
@@ -20,6 +23,7 @@ const RawDragHandle = ({
|
|
|
20
23
|
isHovered,
|
|
21
24
|
correctness,
|
|
22
25
|
color,
|
|
26
|
+
isPlot,
|
|
23
27
|
...rest
|
|
24
28
|
}) => {
|
|
25
29
|
const { scale } = graphProps;
|
|
@@ -55,20 +59,14 @@ const RawDragHandle = ({
|
|
|
55
59
|
</filter>
|
|
56
60
|
</defs>
|
|
57
61
|
|
|
58
|
-
{correctness && (
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
classes.handle,
|
|
65
|
-
'handle',
|
|
66
|
-
className,
|
|
67
|
-
!interactive && 'non-interactive',
|
|
68
|
-
interactive && correctness && correctness.value,
|
|
62
|
+
{correctness && interactive && !isPlot && (
|
|
63
|
+
<foreignObject x={width / 2 - 14} y={0} width={40} height={40}>
|
|
64
|
+
{correctness.value === 'correct' ? (
|
|
65
|
+
<Check className={classNames(classes.correctnessIcon, classes.correctIcon)} title={correctness.label} />
|
|
66
|
+
) : (
|
|
67
|
+
<Close className={classNames(classes.correctnessIcon, classes.incorrectIcon)} title={correctness.label} />
|
|
69
68
|
)}
|
|
70
|
-
|
|
71
|
-
/>
|
|
69
|
+
</foreignObject>
|
|
72
70
|
)}
|
|
73
71
|
</svg>
|
|
74
72
|
);
|
|
@@ -90,7 +88,7 @@ RawDragHandle.propTypes = {
|
|
|
90
88
|
color: PropTypes.string,
|
|
91
89
|
};
|
|
92
90
|
|
|
93
|
-
export const DragHandle = withStyles(() => ({
|
|
91
|
+
export const DragHandle = withStyles((theme) => ({
|
|
94
92
|
handle: {
|
|
95
93
|
height: '10px',
|
|
96
94
|
fill: 'transparent',
|
|
@@ -118,6 +116,22 @@ export const DragHandle = withStyles(() => ({
|
|
|
118
116
|
svgOverflowVisible: {
|
|
119
117
|
overflow: 'visible !important',
|
|
120
118
|
},
|
|
119
|
+
correctIcon: {
|
|
120
|
+
backgroundColor: enumColor.correct(),
|
|
121
|
+
},
|
|
122
|
+
incorrectIcon: {
|
|
123
|
+
backgroundColor: enumColor.incorrectWithIcon(),
|
|
124
|
+
},
|
|
125
|
+
correctnessIcon: {
|
|
126
|
+
borderRadius: theme.spacing.unit * 2,
|
|
127
|
+
color: enumColor.defaults.WHITE,
|
|
128
|
+
fontSize: '16px',
|
|
129
|
+
padding: '2px',
|
|
130
|
+
border: `4px solid ${enumColor.defaults.WHITE}`,
|
|
131
|
+
width: '16px',
|
|
132
|
+
height: '16px',
|
|
133
|
+
boxSizing: 'unset', // to override the default border-box in IBX
|
|
134
|
+
},
|
|
121
135
|
}))(RawDragHandle);
|
|
122
136
|
|
|
123
137
|
export const D = gridDraggable({
|
|
@@ -5,8 +5,13 @@ exports[`BasePoint snapshot renders 1`] = `
|
|
|
5
5
|
className="className"
|
|
6
6
|
classes={
|
|
7
7
|
Object {
|
|
8
|
+
"correctIcon": "RawDragHandle-correctIcon-5",
|
|
9
|
+
"correctnessIcon": "RawDragHandle-correctnessIcon-7",
|
|
10
|
+
"disabledPoint": "RawDragHandle-disabledPoint-4",
|
|
8
11
|
"handle": "RawDragHandle-handle-1",
|
|
12
|
+
"incorrectIcon": "RawDragHandle-incorrectIcon-6",
|
|
9
13
|
"line": "RawDragHandle-line-3",
|
|
14
|
+
"smallIcon": "RawDragHandle-smallIcon-8",
|
|
10
15
|
"transparentHandle": "RawDragHandle-transparentHandle-2",
|
|
11
16
|
}
|
|
12
17
|
}
|
|
@@ -95,6 +95,7 @@ exports[`RawLine snapshot renders 1`] = `
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
key="point-0-0"
|
|
98
|
+
label="A"
|
|
98
99
|
onDrag={[Function]}
|
|
99
100
|
onDragStart={[Function]}
|
|
100
101
|
onDragStop={[Function]}
|
|
@@ -130,6 +131,7 @@ exports[`RawLine snapshot renders 1`] = `
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
key="point-1-1"
|
|
134
|
+
label="B"
|
|
133
135
|
onDrag={[Function]}
|
|
134
136
|
onDragStart={[Function]}
|
|
135
137
|
onDragStop={[Function]}
|