@pie-lib/charting 5.4.1-next.0 → 5.4.2-next.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 +8 -0
- package/lib/axes.js.map +1 -1
- package/lib/bars/bar.js.map +1 -1
- package/lib/bars/common/bars.js.map +1 -1
- package/lib/bars/histogram.js.map +1 -1
- package/lib/chart-setup.js.map +1 -1
- package/lib/chart-type.js.map +1 -1
- package/lib/chart.js.map +1 -1
- package/lib/common/drag-handle.js.map +1 -1
- package/lib/common/styles.js.map +1 -1
- package/lib/grid.js.map +1 -1
- package/lib/line/common/drag-handle.js.map +1 -1
- package/lib/line/common/line.js.map +1 -1
- package/lib/line/line-cross.js.map +1 -1
- package/lib/line/line-dot.js.map +1 -1
- package/lib/mark-label.js.map +1 -1
- package/lib/plot/common/plot.js.map +1 -1
- package/lib/plot/dot.js.map +1 -1
- package/lib/plot/line.js.map +1 -1
- package/lib/tool-menu.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/axes.jsx +44 -60
- package/src/bars/bar.js +2 -2
- package/src/bars/common/bars.jsx +11 -26
- package/src/bars/histogram.js +2 -2
- package/src/chart-setup.jsx +31 -37
- package/src/chart-type.js +5 -10
- package/src/chart.jsx +35 -53
- package/src/common/drag-handle.jsx +16 -36
- package/src/common/styles.js +3 -3
- package/src/grid.jsx +3 -3
- package/src/line/common/drag-handle.jsx +10 -10
- package/src/line/common/line.jsx +17 -19
- package/src/line/line-cross.js +18 -15
- package/src/line/line-dot.js +4 -4
- package/src/mark-label.jsx +16 -21
- package/src/plot/common/plot.jsx +15 -25
- package/src/plot/dot.js +5 -13
- package/src/plot/line.js +16 -10
- package/src/tool-menu.jsx +13 -13
- package/src/utils.js +14 -14
package/src/chart.jsx
CHANGED
|
@@ -8,12 +8,7 @@ import ChartGrid from './grid';
|
|
|
8
8
|
import ChartAxes from './axes';
|
|
9
9
|
import debug from 'debug';
|
|
10
10
|
import { color } from '@pie-lib/render-ui';
|
|
11
|
-
import {
|
|
12
|
-
dataToXBand,
|
|
13
|
-
getDomainAndRangeByChartType,
|
|
14
|
-
getGridLinesAndAxisByChartType,
|
|
15
|
-
getTopPadding
|
|
16
|
-
} from './utils';
|
|
11
|
+
import { dataToXBand, getDomainAndRangeByChartType, getGridLinesAndAxisByChartType, getTopPadding } from './utils';
|
|
17
12
|
import ToolMenu from './tool-menu';
|
|
18
13
|
import chartTypes from './chart-types';
|
|
19
14
|
import { AlertDialog } from '@pie-lib/config-ui';
|
|
@@ -25,8 +20,8 @@ export class Chart extends React.Component {
|
|
|
25
20
|
super(props);
|
|
26
21
|
this.state = {
|
|
27
22
|
dialog: {
|
|
28
|
-
open: false
|
|
29
|
-
}
|
|
23
|
+
open: false,
|
|
24
|
+
},
|
|
30
25
|
};
|
|
31
26
|
}
|
|
32
27
|
|
|
@@ -36,13 +31,13 @@ export class Chart extends React.Component {
|
|
|
36
31
|
chartType: PropTypes.string.isRequired,
|
|
37
32
|
size: PropTypes.shape({
|
|
38
33
|
width: PropTypes.number,
|
|
39
|
-
height: PropTypes.number
|
|
34
|
+
height: PropTypes.number,
|
|
40
35
|
}),
|
|
41
36
|
domain: PropTypes.shape({
|
|
42
37
|
label: PropTypes.string,
|
|
43
38
|
min: PropTypes.number,
|
|
44
39
|
max: PropTypes.number,
|
|
45
|
-
axisLabel: PropTypes.string
|
|
40
|
+
axisLabel: PropTypes.string,
|
|
46
41
|
}),
|
|
47
42
|
data: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string, value: PropTypes.number })),
|
|
48
43
|
range: PropTypes.shape({
|
|
@@ -51,7 +46,7 @@ export class Chart extends React.Component {
|
|
|
51
46
|
max: PropTypes.number,
|
|
52
47
|
step: PropTypes.number,
|
|
53
48
|
labelStep: PropTypes.number,
|
|
54
|
-
axisLabel: PropTypes.string
|
|
49
|
+
axisLabel: PropTypes.string,
|
|
55
50
|
}),
|
|
56
51
|
charts: PropTypes.array,
|
|
57
52
|
title: PropTypes.string,
|
|
@@ -60,14 +55,14 @@ export class Chart extends React.Component {
|
|
|
60
55
|
showPixelGuides: PropTypes.bool,
|
|
61
56
|
categoryDefaultLabel: PropTypes.string,
|
|
62
57
|
defineChart: PropTypes.bool,
|
|
63
|
-
theme: PropTypes.object
|
|
58
|
+
theme: PropTypes.object,
|
|
64
59
|
};
|
|
65
60
|
|
|
66
61
|
static defaultProps = {
|
|
67
62
|
size: {
|
|
68
63
|
width: 480,
|
|
69
|
-
height: 480
|
|
70
|
-
}
|
|
64
|
+
height: 480,
|
|
65
|
+
},
|
|
71
66
|
};
|
|
72
67
|
|
|
73
68
|
state = {
|
|
@@ -77,16 +72,16 @@ export class Chart extends React.Component {
|
|
|
77
72
|
chartTypes.LineDot(),
|
|
78
73
|
chartTypes.LineCross(),
|
|
79
74
|
chartTypes.DotPlot(),
|
|
80
|
-
chartTypes.LinePlot()
|
|
81
|
-
]
|
|
75
|
+
chartTypes.LinePlot(),
|
|
76
|
+
],
|
|
82
77
|
};
|
|
83
78
|
|
|
84
79
|
handleAlertDialog = (open, callback) =>
|
|
85
80
|
this.setState(
|
|
86
81
|
{
|
|
87
|
-
dialog: { open }
|
|
82
|
+
dialog: { open },
|
|
88
83
|
},
|
|
89
|
-
callback
|
|
84
|
+
callback,
|
|
90
85
|
);
|
|
91
86
|
|
|
92
87
|
getChart = () => {
|
|
@@ -96,7 +91,7 @@ export class Chart extends React.Component {
|
|
|
96
91
|
let chart = null;
|
|
97
92
|
|
|
98
93
|
if (chartType) {
|
|
99
|
-
chart = charts && charts.find(chart => chart.type === chartType);
|
|
94
|
+
chart = charts && charts.find((chart) => chart.type === chartType);
|
|
100
95
|
ChartComponent = chart && chart.Component;
|
|
101
96
|
} else {
|
|
102
97
|
chart = charts && charts[0];
|
|
@@ -106,11 +101,11 @@ export class Chart extends React.Component {
|
|
|
106
101
|
|
|
107
102
|
return {
|
|
108
103
|
type: chartType,
|
|
109
|
-
ChartComponent
|
|
104
|
+
ChartComponent,
|
|
110
105
|
};
|
|
111
106
|
};
|
|
112
107
|
|
|
113
|
-
changeData = data => {
|
|
108
|
+
changeData = (data) => {
|
|
114
109
|
const { onDataChange } = this.props;
|
|
115
110
|
|
|
116
111
|
onDataChange(data);
|
|
@@ -123,14 +118,14 @@ export class Chart extends React.Component {
|
|
|
123
118
|
const { data, onDataChange } = this.props;
|
|
124
119
|
data[integerIndex] = {
|
|
125
120
|
...data[integerIndex],
|
|
126
|
-
...newCategory
|
|
121
|
+
...newCategory,
|
|
127
122
|
};
|
|
128
123
|
|
|
129
124
|
onDataChange(data);
|
|
130
125
|
}
|
|
131
126
|
};
|
|
132
127
|
|
|
133
|
-
addCategory = range => {
|
|
128
|
+
addCategory = (range) => {
|
|
134
129
|
const { onDataChange, data, categoryDefaultLabel, defineChart } = this.props;
|
|
135
130
|
|
|
136
131
|
if (!defineChart && data.length > 19) {
|
|
@@ -139,8 +134,8 @@ export class Chart extends React.Component {
|
|
|
139
134
|
open: true,
|
|
140
135
|
title: 'Warning',
|
|
141
136
|
text: "There can't be more than 20 categories.",
|
|
142
|
-
onConfirm: () => this.handleAlertDialog(false)
|
|
143
|
-
}
|
|
137
|
+
onConfirm: () => this.handleAlertDialog(false),
|
|
138
|
+
},
|
|
144
139
|
});
|
|
145
140
|
} else {
|
|
146
141
|
onDataChange([
|
|
@@ -152,8 +147,8 @@ export class Chart extends React.Component {
|
|
|
152
147
|
value: range.step,
|
|
153
148
|
deletable: true,
|
|
154
149
|
editable: true,
|
|
155
|
-
interactive: true
|
|
156
|
-
}
|
|
150
|
+
interactive: true,
|
|
151
|
+
},
|
|
157
152
|
]);
|
|
158
153
|
}
|
|
159
154
|
};
|
|
@@ -162,9 +157,9 @@ export class Chart extends React.Component {
|
|
|
162
157
|
const { data, defineChart } = this.props;
|
|
163
158
|
|
|
164
159
|
return data
|
|
165
|
-
? data.map(d => ({
|
|
160
|
+
? data.map((d) => ({
|
|
166
161
|
...d,
|
|
167
|
-
deletable: defineChart || d.deletable
|
|
162
|
+
deletable: defineChart || d.deletable,
|
|
168
163
|
}))
|
|
169
164
|
: [];
|
|
170
165
|
};
|
|
@@ -183,7 +178,7 @@ export class Chart extends React.Component {
|
|
|
183
178
|
titlePlaceholder,
|
|
184
179
|
addCategoryEnabled,
|
|
185
180
|
showPixelGuides,
|
|
186
|
-
error
|
|
181
|
+
error,
|
|
187
182
|
} = this.props;
|
|
188
183
|
let { chartType } = this.props;
|
|
189
184
|
|
|
@@ -197,17 +192,9 @@ export class Chart extends React.Component {
|
|
|
197
192
|
|
|
198
193
|
const correctValues = getDomainAndRangeByChartType(domain, range, chartType);
|
|
199
194
|
|
|
200
|
-
const { verticalLines, horizontalLines, leftAxis } = getGridLinesAndAxisByChartType(
|
|
201
|
-
correctValues.range,
|
|
202
|
-
chartType
|
|
203
|
-
);
|
|
195
|
+
const { verticalLines, horizontalLines, leftAxis } = getGridLinesAndAxisByChartType(correctValues.range, chartType);
|
|
204
196
|
const common = {
|
|
205
|
-
graphProps: createGraphProps(
|
|
206
|
-
correctValues.domain,
|
|
207
|
-
correctValues.range,
|
|
208
|
-
size,
|
|
209
|
-
() => this.rootNode
|
|
210
|
-
)
|
|
197
|
+
graphProps: createGraphProps(correctValues.domain, correctValues.range, size, () => this.rootNode),
|
|
211
198
|
};
|
|
212
199
|
|
|
213
200
|
log('[render] common:', common);
|
|
@@ -256,15 +243,10 @@ export class Chart extends React.Component {
|
|
|
256
243
|
isChart={true}
|
|
257
244
|
showPixelGuides={showPixelGuides}
|
|
258
245
|
classes={classes}
|
|
259
|
-
rootRef={r => (this.rootNode = r)}
|
|
246
|
+
rootRef={(r) => (this.rootNode = r)}
|
|
260
247
|
{...rootCommon}
|
|
261
248
|
>
|
|
262
|
-
<ChartGrid
|
|
263
|
-
{...common}
|
|
264
|
-
xBand={xBand}
|
|
265
|
-
rowTickValues={horizontalLines}
|
|
266
|
-
columnTickValues={verticalLines}
|
|
267
|
-
/>
|
|
249
|
+
<ChartGrid {...common} xBand={xBand} rowTickValues={horizontalLines} columnTickValues={verticalLines} />
|
|
268
250
|
<ChartAxes
|
|
269
251
|
{...common}
|
|
270
252
|
defineChart={defineChart}
|
|
@@ -301,9 +283,9 @@ export class Chart extends React.Component {
|
|
|
301
283
|
}
|
|
302
284
|
}
|
|
303
285
|
|
|
304
|
-
const styles = theme => ({
|
|
286
|
+
const styles = (theme) => ({
|
|
305
287
|
graphBox: {
|
|
306
|
-
transform: 'translate(60px, 35px)'
|
|
288
|
+
transform: 'translate(60px, 35px)',
|
|
307
289
|
},
|
|
308
290
|
controls: {
|
|
309
291
|
width: 'inherit',
|
|
@@ -314,14 +296,14 @@ const styles = theme => ({
|
|
|
314
296
|
borderTop: `solid 1px ${color.primaryDark()}`,
|
|
315
297
|
borderBottom: `solid 0px ${color.primaryDark()}`,
|
|
316
298
|
borderLeft: `solid 1px ${color.primaryDark()}`,
|
|
317
|
-
borderRight: `solid 1px ${color.primaryDark()}
|
|
299
|
+
borderRight: `solid 1px ${color.primaryDark()}`,
|
|
318
300
|
},
|
|
319
301
|
svg: {
|
|
320
|
-
overflow: 'visible'
|
|
302
|
+
overflow: 'visible',
|
|
321
303
|
},
|
|
322
304
|
toolMenu: {
|
|
323
|
-
minHeight: '36px'
|
|
324
|
-
}
|
|
305
|
+
minHeight: '36px',
|
|
306
|
+
},
|
|
325
307
|
});
|
|
326
308
|
|
|
327
309
|
export default withStyles(styles, { withTheme: true })(Chart);
|
|
@@ -17,21 +17,11 @@ export class RawDragHandle extends React.Component {
|
|
|
17
17
|
interactive: PropTypes.bool,
|
|
18
18
|
correctness: PropTypes.shape({
|
|
19
19
|
value: PropTypes.string,
|
|
20
|
-
label: PropTypes.string
|
|
21
|
-
})
|
|
20
|
+
label: PropTypes.string,
|
|
21
|
+
}),
|
|
22
22
|
};
|
|
23
23
|
render() {
|
|
24
|
-
const {
|
|
25
|
-
x,
|
|
26
|
-
y,
|
|
27
|
-
width,
|
|
28
|
-
graphProps,
|
|
29
|
-
classes,
|
|
30
|
-
className,
|
|
31
|
-
interactive,
|
|
32
|
-
correctness,
|
|
33
|
-
...rest
|
|
34
|
-
} = this.props;
|
|
24
|
+
const { x, y, width, graphProps, classes, className, interactive, correctness, ...rest } = this.props;
|
|
35
25
|
const { scale } = graphProps;
|
|
36
26
|
|
|
37
27
|
return (
|
|
@@ -44,15 +34,10 @@ export class RawDragHandle extends React.Component {
|
|
|
44
34
|
classes.handleContainer,
|
|
45
35
|
className,
|
|
46
36
|
!interactive && 'non-interactive',
|
|
47
|
-
interactive && correctness && correctness.value
|
|
37
|
+
interactive && correctness && correctness.value,
|
|
48
38
|
)}
|
|
49
39
|
>
|
|
50
|
-
<rect
|
|
51
|
-
y={-10}
|
|
52
|
-
width={width}
|
|
53
|
-
className={classNames(classes.transparentHandle, className)}
|
|
54
|
-
{...rest}
|
|
55
|
-
/>
|
|
40
|
+
<rect y={-10} width={width} className={classNames(classes.transparentHandle, className)} {...rest} />
|
|
56
41
|
<rect
|
|
57
42
|
width={width}
|
|
58
43
|
className={classNames(
|
|
@@ -60,46 +45,41 @@ export class RawDragHandle extends React.Component {
|
|
|
60
45
|
'handle',
|
|
61
46
|
className,
|
|
62
47
|
!interactive && 'non-interactive',
|
|
63
|
-
interactive && correctness && correctness.value
|
|
48
|
+
interactive && correctness && correctness.value,
|
|
64
49
|
)}
|
|
65
50
|
{...rest}
|
|
66
51
|
/>
|
|
67
|
-
<rect
|
|
68
|
-
y={10}
|
|
69
|
-
width={width}
|
|
70
|
-
className={classNames(classes.transparentHandle, className)}
|
|
71
|
-
{...rest}
|
|
72
|
-
/>
|
|
52
|
+
<rect y={10} width={width} className={classNames(classes.transparentHandle, className)} {...rest} />
|
|
73
53
|
</svg>
|
|
74
54
|
);
|
|
75
55
|
}
|
|
76
56
|
}
|
|
77
57
|
|
|
78
|
-
export const DragHandle = withStyles(theme => ({
|
|
58
|
+
export const DragHandle = withStyles((theme) => ({
|
|
79
59
|
handle: {
|
|
80
60
|
height: '10px',
|
|
81
61
|
fill: color.secondary(),
|
|
82
62
|
transition: 'fill 200ms linear, height 200ms linear',
|
|
83
63
|
'&.correct': correct('fill'),
|
|
84
64
|
'&.incorrect': incorrect('fill'),
|
|
85
|
-
'&.non-interactive': disabled('fill')
|
|
65
|
+
'&.non-interactive': disabled('fill'),
|
|
86
66
|
},
|
|
87
67
|
transparentHandle: {
|
|
88
68
|
height: '20px',
|
|
89
|
-
fill: 'transparent'
|
|
69
|
+
fill: 'transparent',
|
|
90
70
|
},
|
|
91
71
|
handleContainer: {
|
|
92
72
|
height: 30,
|
|
93
73
|
'&:hover': {
|
|
94
74
|
'& .handle': {
|
|
95
75
|
fill: color.secondaryDark(),
|
|
96
|
-
height: '16px'
|
|
97
|
-
}
|
|
76
|
+
height: '16px',
|
|
77
|
+
},
|
|
98
78
|
},
|
|
99
79
|
'&.non-interactive': disabled('fill'),
|
|
100
80
|
'&.incorrect': incorrect('fill'),
|
|
101
|
-
'&.correct': correct('fill')
|
|
102
|
-
}
|
|
81
|
+
'&.correct': correct('fill'),
|
|
82
|
+
},
|
|
103
83
|
}))(RawDragHandle);
|
|
104
84
|
|
|
105
85
|
export const D = gridDraggable({
|
|
@@ -115,9 +95,9 @@ export const D = gridDraggable({
|
|
|
115
95
|
const area = { left: 0, top: props.y, bottom: props.y, right: 0 };
|
|
116
96
|
return utils.bounds(area, domain, range);
|
|
117
97
|
},
|
|
118
|
-
anchorPoint: props => {
|
|
98
|
+
anchorPoint: (props) => {
|
|
119
99
|
return { x: props.x, y: props.y };
|
|
120
|
-
}
|
|
100
|
+
},
|
|
121
101
|
})(DragHandle);
|
|
122
102
|
|
|
123
103
|
export default D;
|
package/src/common/styles.js
CHANGED
|
@@ -2,14 +2,14 @@ import { color } from '@pie-lib/render-ui';
|
|
|
2
2
|
|
|
3
3
|
export const disabled = (key = 'fill') => ({
|
|
4
4
|
[key]: `var(--graph-disabled, ${color.disabled()})`,
|
|
5
|
-
pointerEvents: 'none'
|
|
5
|
+
pointerEvents: 'none',
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export const correct = (key = 'fill') => ({
|
|
9
9
|
[key]: color.correct(),
|
|
10
|
-
pointerEvents: 'none'
|
|
10
|
+
pointerEvents: 'none',
|
|
11
11
|
});
|
|
12
12
|
export const incorrect = (key = 'fill') => ({
|
|
13
13
|
[key]: color.incorrect(),
|
|
14
|
-
pointerEvents: 'none'
|
|
14
|
+
pointerEvents: 'none',
|
|
15
15
|
});
|
package/src/grid.jsx
CHANGED
|
@@ -14,7 +14,7 @@ export class Grid extends React.Component {
|
|
|
14
14
|
graphProps: types.GraphPropsType.isRequired,
|
|
15
15
|
xBand: PropTypes.func,
|
|
16
16
|
columnTickValues: PropTypes.array,
|
|
17
|
-
rowTickValues: PropTypes.array
|
|
17
|
+
rowTickValues: PropTypes.array,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
static defaultProps = {};
|
|
@@ -40,8 +40,8 @@ export class Grid extends React.Component {
|
|
|
40
40
|
|
|
41
41
|
const styles = () => ({
|
|
42
42
|
grid: {
|
|
43
|
-
stroke: color.primaryLight()
|
|
44
|
-
}
|
|
43
|
+
stroke: color.primaryLight(),
|
|
44
|
+
},
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
export default withStyles(styles)(Grid);
|
|
@@ -18,8 +18,8 @@ class RawDragHandle extends React.Component {
|
|
|
18
18
|
CustomDraggableComponent: PropTypes.func,
|
|
19
19
|
correctness: PropTypes.shape({
|
|
20
20
|
value: PropTypes.string,
|
|
21
|
-
label: PropTypes.string
|
|
22
|
-
})
|
|
21
|
+
label: PropTypes.string,
|
|
22
|
+
}),
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
render() {
|
|
@@ -50,27 +50,27 @@ class RawDragHandle extends React.Component {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export const DragHandle = withStyles(theme => ({
|
|
53
|
+
export const DragHandle = withStyles((theme) => ({
|
|
54
54
|
handle: {
|
|
55
55
|
fill: color.secondary(),
|
|
56
56
|
transition: 'fill 200ms linear, height 200ms linear',
|
|
57
57
|
'&:hover': {
|
|
58
|
-
fill: color.secondaryDark()
|
|
58
|
+
fill: color.secondaryDark(),
|
|
59
59
|
},
|
|
60
60
|
'&.correct': correct('fill'),
|
|
61
61
|
'&.incorrect': incorrect('fill'),
|
|
62
|
-
'&.non-interactive': disabled('fill')
|
|
62
|
+
'&.non-interactive': disabled('fill'),
|
|
63
63
|
},
|
|
64
64
|
line: {
|
|
65
65
|
stroke: color.secondary(),
|
|
66
66
|
transition: 'fill 200ms linear, height 200ms linear',
|
|
67
67
|
'&:hover': {
|
|
68
|
-
stroke: color.secondaryDark()
|
|
68
|
+
stroke: color.secondaryDark(),
|
|
69
69
|
},
|
|
70
70
|
'&.non-interactive': disabled('stroke'),
|
|
71
71
|
'&.correct': correct('stroke'),
|
|
72
|
-
'&.incorrect': incorrect('stroke')
|
|
73
|
-
}
|
|
72
|
+
'&.incorrect': incorrect('stroke'),
|
|
73
|
+
},
|
|
74
74
|
}))(RawDragHandle);
|
|
75
75
|
|
|
76
76
|
const DraggableHandle = gridDraggable({
|
|
@@ -85,9 +85,9 @@ const DraggableHandle = gridDraggable({
|
|
|
85
85
|
const area = { left: 0, top: props.y, bottom: props.y, right: 0 };
|
|
86
86
|
return utils.bounds(area, domain, range);
|
|
87
87
|
},
|
|
88
|
-
anchorPoint: props => {
|
|
88
|
+
anchorPoint: (props) => {
|
|
89
89
|
return { x: props.x, y: props.y };
|
|
90
|
-
}
|
|
90
|
+
},
|
|
91
91
|
})(DragHandle);
|
|
92
92
|
|
|
93
93
|
export default DraggableHandle;
|
package/src/line/common/line.jsx
CHANGED
|
@@ -19,7 +19,7 @@ const getData = (data, domain) => {
|
|
|
19
19
|
return data.map((el, i) => ({
|
|
20
20
|
...el,
|
|
21
21
|
x: length > 1 ? i * (max / (length - 1)) : 0.5,
|
|
22
|
-
y: el.value
|
|
22
|
+
y: el.value,
|
|
23
23
|
}));
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -36,35 +36,35 @@ export class RawLine extends React.Component {
|
|
|
36
36
|
data: PropTypes.arrayOf(
|
|
37
37
|
PropTypes.shape({
|
|
38
38
|
label: PropTypes.string,
|
|
39
|
-
value: PropTypes.number
|
|
40
|
-
})
|
|
39
|
+
value: PropTypes.number,
|
|
40
|
+
}),
|
|
41
41
|
),
|
|
42
|
-
CustomDraggableComponent: PropTypes.func
|
|
42
|
+
CustomDraggableComponent: PropTypes.func,
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
static defaultProps = {
|
|
46
|
-
index: 0
|
|
46
|
+
index: 0,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
constructor(props) {
|
|
50
50
|
super(props);
|
|
51
51
|
this.state = {
|
|
52
52
|
dragValue: undefined,
|
|
53
|
-
line: getData(props.data, props.graphProps.domain)
|
|
53
|
+
line: getData(props.data, props.graphProps.domain),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
58
58
|
if (!isEqual(this.props.data, nextProps.data)) {
|
|
59
59
|
this.setState({
|
|
60
|
-
line: getData(nextProps.data, nextProps.graphProps.domain)
|
|
60
|
+
line: getData(nextProps.data, nextProps.graphProps.domain),
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
setDragValue = line => this.setState({ line });
|
|
65
|
+
setDragValue = (line) => this.setState({ line });
|
|
66
66
|
|
|
67
|
-
dragStop = index => {
|
|
67
|
+
dragStop = (index) => {
|
|
68
68
|
const { onChange } = this.props;
|
|
69
69
|
this.setState({ dragging: false }, () => {
|
|
70
70
|
onChange(index, this.state.line[index]);
|
|
@@ -87,8 +87,8 @@ export class RawLine extends React.Component {
|
|
|
87
87
|
<React.Fragment>
|
|
88
88
|
<LinePath
|
|
89
89
|
data={lineToUse}
|
|
90
|
-
x={d => scale.x(d.x)}
|
|
91
|
-
y={d => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}
|
|
90
|
+
x={(d) => scale.x(d.x)}
|
|
91
|
+
y={(d) => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}
|
|
92
92
|
className={classes.line}
|
|
93
93
|
/>
|
|
94
94
|
{lineToUse &&
|
|
@@ -105,9 +105,7 @@ export class RawLine extends React.Component {
|
|
|
105
105
|
interactive={enableDraggable}
|
|
106
106
|
r={r}
|
|
107
107
|
onDragStart={() => this.setState({ dragging: true })}
|
|
108
|
-
onDrag={v =>
|
|
109
|
-
this.dragValue(i, point.dragValue !== undefined ? point.dragValue : point.y, v)
|
|
110
|
-
}
|
|
108
|
+
onDrag={(v) => this.dragValue(i, point.dragValue !== undefined ? point.dragValue : point.y, v)}
|
|
111
109
|
onDragStop={() => this.dragStop(i)}
|
|
112
110
|
graphProps={graphProps}
|
|
113
111
|
CustomDraggableComponent={CustomDraggableComponent}
|
|
@@ -120,7 +118,7 @@ export class RawLine extends React.Component {
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
const StyledLine = withStyles(theme => ({
|
|
121
|
+
const StyledLine = withStyles((theme) => ({
|
|
124
122
|
line: {
|
|
125
123
|
fill: 'transparent',
|
|
126
124
|
stroke: color.primaryLight(),
|
|
@@ -128,9 +126,9 @@ const StyledLine = withStyles(theme => ({
|
|
|
128
126
|
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
129
127
|
'&:hover': {
|
|
130
128
|
strokeWidth: 6,
|
|
131
|
-
stroke: color.primaryDark()
|
|
132
|
-
}
|
|
133
|
-
}
|
|
129
|
+
stroke: color.primaryDark(),
|
|
130
|
+
},
|
|
131
|
+
},
|
|
134
132
|
}))(RawLine);
|
|
135
133
|
|
|
136
134
|
export class Line extends React.Component {
|
|
@@ -138,7 +136,7 @@ export class Line extends React.Component {
|
|
|
138
136
|
data: PropTypes.array,
|
|
139
137
|
onChange: PropTypes.func,
|
|
140
138
|
xBand: PropTypes.func,
|
|
141
|
-
graphProps: types.GraphPropsType.isRequired
|
|
139
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
142
140
|
};
|
|
143
141
|
|
|
144
142
|
changeLine = (index, category) => {
|
package/src/line/line-cross.js
CHANGED
|
@@ -7,26 +7,29 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { dataToXBand } from '../utils';
|
|
8
8
|
import RawLine from './common/line';
|
|
9
9
|
|
|
10
|
-
const DraggableComponent = props => {
|
|
10
|
+
const DraggableComponent = (props) => {
|
|
11
11
|
const { classes = {}, className, scale, x, y, r, correctness, ...rest } = props;
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<Group
|
|
15
|
-
{...rest}
|
|
16
|
-
className={classNames(className, classes.line, correctness && correctness.value)}
|
|
17
|
-
>
|
|
14
|
+
<Group {...rest} className={classNames(className, classes.line, correctness && correctness.value)}>
|
|
18
15
|
<LinePath
|
|
19
|
-
data={[
|
|
16
|
+
data={[
|
|
17
|
+
{ x: scale.x(x) - r, y: scale.y(y) + r },
|
|
18
|
+
{ x: scale.x(x) + r, y: scale.y(y) - r },
|
|
19
|
+
]}
|
|
20
20
|
key={`point-${x}-${y}-1`}
|
|
21
|
-
x={d => d.x}
|
|
22
|
-
y={d => d.y}
|
|
21
|
+
x={(d) => d.x}
|
|
22
|
+
y={(d) => d.y}
|
|
23
23
|
strokeWidth={5}
|
|
24
24
|
/>
|
|
25
25
|
<LinePath
|
|
26
|
-
data={[
|
|
26
|
+
data={[
|
|
27
|
+
{ x: scale.x(x) - r, y: scale.y(y) - r },
|
|
28
|
+
{ x: scale.x(x) + r, y: scale.y(y) + r },
|
|
29
|
+
]}
|
|
27
30
|
key={`point-${x}-${y}-2`}
|
|
28
|
-
x={d => d.x}
|
|
29
|
-
y={d => d.y}
|
|
31
|
+
x={(d) => d.x}
|
|
32
|
+
y={(d) => d.y}
|
|
30
33
|
strokeWidth={5}
|
|
31
34
|
/>
|
|
32
35
|
</Group>
|
|
@@ -42,15 +45,15 @@ DraggableComponent.propTypes = {
|
|
|
42
45
|
classes: PropTypes.object,
|
|
43
46
|
correctness: PropTypes.shape({
|
|
44
47
|
value: PropTypes.string,
|
|
45
|
-
label: PropTypes.string
|
|
46
|
-
})
|
|
48
|
+
label: PropTypes.string,
|
|
49
|
+
}),
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
export class LineCross extends React.Component {
|
|
50
53
|
static propTypes = {
|
|
51
54
|
data: PropTypes.array,
|
|
52
55
|
onChange: PropTypes.func,
|
|
53
|
-
graphProps: types.GraphPropsType.isRequired
|
|
56
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
render() {
|
|
@@ -66,5 +69,5 @@ export class LineCross extends React.Component {
|
|
|
66
69
|
export default () => ({
|
|
67
70
|
type: 'lineCross',
|
|
68
71
|
Component: LineCross,
|
|
69
|
-
name: 'Line Cross'
|
|
72
|
+
name: 'Line Cross',
|
|
70
73
|
});
|
package/src/line/line-dot.js
CHANGED
|
@@ -24,15 +24,15 @@ DraggableComponent.propTypes = {
|
|
|
24
24
|
classes: PropTypes.object,
|
|
25
25
|
correctness: PropTypes.shape({
|
|
26
26
|
value: PropTypes.string,
|
|
27
|
-
label: PropTypes.string
|
|
28
|
-
})
|
|
27
|
+
label: PropTypes.string,
|
|
28
|
+
}),
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export class LineDot extends React.Component {
|
|
32
32
|
static propTypes = {
|
|
33
33
|
data: PropTypes.array,
|
|
34
34
|
onChange: PropTypes.func,
|
|
35
|
-
graphProps: types.GraphPropsType.isRequired
|
|
35
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
render() {
|
|
@@ -48,5 +48,5 @@ export class LineDot extends React.Component {
|
|
|
48
48
|
export default () => ({
|
|
49
49
|
type: 'lineDot',
|
|
50
50
|
Component: LineDot,
|
|
51
|
-
name: 'Line Dot'
|
|
51
|
+
name: 'Line Dot',
|
|
52
52
|
});
|