@tradingaction/interactive 2.0.13
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/LICENSE +24 -0
- package/README.md +5 -0
- package/lib/Brush.d.ts +35 -0
- package/lib/Brush.js +103 -0
- package/lib/Brush.js.map +1 -0
- package/lib/ClickCallback.d.ts +18 -0
- package/lib/ClickCallback.js +12 -0
- package/lib/ClickCallback.js.map +1 -0
- package/lib/DrawingObjectSelector.d.ts +18 -0
- package/lib/DrawingObjectSelector.js +73 -0
- package/lib/DrawingObjectSelector.js.map +1 -0
- package/lib/EquidistantChannel.d.ts +74 -0
- package/lib/EquidistantChannel.js +149 -0
- package/lib/EquidistantChannel.js.map +1 -0
- package/lib/FibonacciRetracement.d.ts +89 -0
- package/lib/FibonacciRetracement.js +184 -0
- package/lib/FibonacciRetracement.js.map +1 -0
- package/lib/GannFan.d.ts +78 -0
- package/lib/GannFan.js +128 -0
- package/lib/GannFan.js.map +1 -0
- package/lib/InteractiveText.d.ts +65 -0
- package/lib/InteractiveText.js +83 -0
- package/lib/InteractiveText.js.map +1 -0
- package/lib/InteractiveYCoordinate.d.ts +122 -0
- package/lib/InteractiveYCoordinate.js +100 -0
- package/lib/InteractiveYCoordinate.js.map +1 -0
- package/lib/StandardDeviationChannel.d.ts +74 -0
- package/lib/StandardDeviationChannel.js +125 -0
- package/lib/StandardDeviationChannel.js.map +1 -0
- package/lib/TrendLine.d.ts +84 -0
- package/lib/TrendLine.js +128 -0
- package/lib/TrendLine.js.map +1 -0
- package/lib/ZoomButtons.d.ts +30 -0
- package/lib/ZoomButtons.js +78 -0
- package/lib/ZoomButtons.js.map +1 -0
- package/lib/components/ChannelWithArea.d.ts +30 -0
- package/lib/components/ChannelWithArea.js +126 -0
- package/lib/components/ChannelWithArea.js.map +1 -0
- package/lib/components/ClickableCircle.d.ts +26 -0
- package/lib/components/ClickableCircle.js +48 -0
- package/lib/components/ClickableCircle.js.map +1 -0
- package/lib/components/ClickableShape.d.ts +33 -0
- package/lib/components/ClickableShape.js +64 -0
- package/lib/components/ClickableShape.js.map +1 -0
- package/lib/components/GannFan.d.ts +32 -0
- package/lib/components/GannFan.js +134 -0
- package/lib/components/GannFan.js.map +1 -0
- package/lib/components/HoverTextNearMouse.d.ts +35 -0
- package/lib/components/HoverTextNearMouse.js +113 -0
- package/lib/components/HoverTextNearMouse.js.map +1 -0
- package/lib/components/InteractiveStraightLine.d.ts +61 -0
- package/lib/components/InteractiveStraightLine.js +220 -0
- package/lib/components/InteractiveStraightLine.js.map +1 -0
- package/lib/components/InteractiveText.d.ts +38 -0
- package/lib/components/InteractiveText.js +84 -0
- package/lib/components/InteractiveText.js.map +1 -0
- package/lib/components/InteractiveYCoordinate.d.ts +46 -0
- package/lib/components/InteractiveYCoordinate.js +109 -0
- package/lib/components/InteractiveYCoordinate.js.map +1 -0
- package/lib/components/LinearRegressionChannelWithArea.d.ts +31 -0
- package/lib/components/LinearRegressionChannelWithArea.js +104 -0
- package/lib/components/LinearRegressionChannelWithArea.js.map +1 -0
- package/lib/components/MouseLocationIndicator.d.ts +34 -0
- package/lib/components/MouseLocationIndicator.js +79 -0
- package/lib/components/MouseLocationIndicator.js.map +1 -0
- package/lib/components/Text.d.ts +17 -0
- package/lib/components/Text.js +26 -0
- package/lib/components/Text.js.map +1 -0
- package/lib/components/index.d.ts +11 -0
- package/lib/components/index.js +12 -0
- package/lib/components/index.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +84 -0
- package/lib/utils.js.map +1 -0
- package/lib/wrapper/EachEquidistantChannel.d.ts +59 -0
- package/lib/wrapper/EachEquidistantChannel.js +172 -0
- package/lib/wrapper/EachEquidistantChannel.js.map +1 -0
- package/lib/wrapper/EachFibRetracement.d.ts +81 -0
- package/lib/wrapper/EachFibRetracement.js +202 -0
- package/lib/wrapper/EachFibRetracement.js.map +1 -0
- package/lib/wrapper/EachGannFan.d.ts +81 -0
- package/lib/wrapper/EachGannFan.js +161 -0
- package/lib/wrapper/EachGannFan.js.map +1 -0
- package/lib/wrapper/EachInteractiveYCoordinate.d.ts +50 -0
- package/lib/wrapper/EachInteractiveYCoordinate.js +80 -0
- package/lib/wrapper/EachInteractiveYCoordinate.js.map +1 -0
- package/lib/wrapper/EachLinearRegressionChannel.d.ts +75 -0
- package/lib/wrapper/EachLinearRegressionChannel.js +89 -0
- package/lib/wrapper/EachLinearRegressionChannel.js.map +1 -0
- package/lib/wrapper/EachText.d.ts +59 -0
- package/lib/wrapper/EachText.js +83 -0
- package/lib/wrapper/EachText.js.map +1 -0
- package/lib/wrapper/EachTrendLine.d.ts +85 -0
- package/lib/wrapper/EachTrendLine.js +165 -0
- package/lib/wrapper/EachTrendLine.js.map +1 -0
- package/lib/wrapper/index.d.ts +7 -0
- package/lib/wrapper/index.js +8 -0
- package/lib/wrapper/index.js.map +1 -0
- package/package.json +53 -0
- package/src/Brush.tsx +172 -0
- package/src/ClickCallback.tsx +37 -0
- package/src/DrawingObjectSelector.tsx +97 -0
- package/src/EquidistantChannel.tsx +268 -0
- package/src/FibonacciRetracement.tsx +328 -0
- package/src/GannFan.tsx +233 -0
- package/src/InteractiveText.tsx +182 -0
- package/src/InteractiveYCoordinate.tsx +199 -0
- package/src/StandardDeviationChannel.tsx +269 -0
- package/src/TrendLine.tsx +294 -0
- package/src/ZoomButtons.tsx +165 -0
- package/src/components/ChannelWithArea.tsx +199 -0
- package/src/components/ClickableCircle.tsx +91 -0
- package/src/components/ClickableShape.tsx +114 -0
- package/src/components/GannFan.tsx +189 -0
- package/src/components/HoverTextNearMouse.tsx +174 -0
- package/src/components/InteractiveStraightLine.tsx +335 -0
- package/src/components/InteractiveText.tsx +146 -0
- package/src/components/InteractiveYCoordinate.tsx +200 -0
- package/src/components/LinearRegressionChannelWithArea.tsx +169 -0
- package/src/components/MouseLocationIndicator.tsx +128 -0
- package/src/components/Text.tsx +47 -0
- package/src/components/index.ts +11 -0
- package/src/index.ts +12 -0
- package/src/utils.ts +101 -0
- package/src/wrapper/EachEquidistantChannel.tsx +302 -0
- package/src/wrapper/EachFibRetracement.tsx +359 -0
- package/src/wrapper/EachGannFan.tsx +289 -0
- package/src/wrapper/EachInteractiveYCoordinate.tsx +198 -0
- package/src/wrapper/EachLinearRegressionChannel.tsx +202 -0
- package/src/wrapper/EachText.tsx +190 -0
- package/src/wrapper/EachTrendLine.tsx +331 -0
- package/src/wrapper/index.ts +7 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { TrendLine } from "./TrendLine";
|
|
2
|
+
export { FibonacciRetracement } from "./FibonacciRetracement";
|
|
3
|
+
export { EquidistantChannel } from "./EquidistantChannel";
|
|
4
|
+
export { StandardDeviationChannel } from "./StandardDeviationChannel";
|
|
5
|
+
export { GannFan } from "./GannFan";
|
|
6
|
+
export { ClickCallback } from "./ClickCallback";
|
|
7
|
+
export { Brush } from "./Brush";
|
|
8
|
+
export { InteractiveText } from "./InteractiveText";
|
|
9
|
+
export { InteractiveYCoordinate } from "./InteractiveYCoordinate";
|
|
10
|
+
export { DrawingObjectSelector } from "./DrawingObjectSelector";
|
|
11
|
+
export { ZoomButtons } from "./ZoomButtons";
|
|
12
|
+
export * from "./utils";
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isDefined, isNotDefined, mapObject } from "@tradingaction/core";
|
|
2
|
+
|
|
3
|
+
export function getValueFromOverride(override: any, index: any, key: any, defaultValue: any) {
|
|
4
|
+
if (isDefined(override) && override.index === index) {
|
|
5
|
+
return override[key];
|
|
6
|
+
}
|
|
7
|
+
return defaultValue;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function terminate() {
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
this.setState({
|
|
13
|
+
current: null,
|
|
14
|
+
override: null,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function saveNodeType(type: any) {
|
|
19
|
+
return (node: any) => {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
if (isDefined(this.nodes)) {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
if (isNotDefined(node) && isDefined(this.nodes[type])) {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
delete this.nodes[type];
|
|
26
|
+
} else {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
this.nodes[type] = node;
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
this.nodes = [];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function isHoverForInteractiveType(interactiveType: any) {
|
|
37
|
+
return function (moreProps: any) {
|
|
38
|
+
// this has to be function as it is bound to this
|
|
39
|
+
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
if (isDefined(this.nodes)) {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
const selecedNodes = this.nodes.map((node) => node.isHover(moreProps));
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
const interactive = this.props[interactiveType].map((t, idx) => {
|
|
46
|
+
return {
|
|
47
|
+
...t,
|
|
48
|
+
selected: selecedNodes[idx],
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
return interactive;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function isHover(moreProps: any) {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
const hovering = mapObject(this.nodes, (node) => node.isHover(moreProps)).reduce((a, b) => {
|
|
59
|
+
return a || b;
|
|
60
|
+
});
|
|
61
|
+
return hovering;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getMouseXY(moreProps: any, [ox, oy]: any) {
|
|
65
|
+
if (Array.isArray(moreProps.mouseXY)) {
|
|
66
|
+
const {
|
|
67
|
+
mouseXY: [x, y],
|
|
68
|
+
} = moreProps;
|
|
69
|
+
const mouseXY = [x - ox, y - oy];
|
|
70
|
+
return mouseXY;
|
|
71
|
+
}
|
|
72
|
+
return moreProps.mouseXY;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function getMorePropsForChart(moreProps: any, chartId: any) {
|
|
76
|
+
const { chartConfig: chartConfigList } = moreProps;
|
|
77
|
+
const chartConfig = chartConfigList.find((each: any) => each.id === chartId);
|
|
78
|
+
|
|
79
|
+
const { origin } = chartConfig;
|
|
80
|
+
const mouseXY = getMouseXY(moreProps, origin);
|
|
81
|
+
return {
|
|
82
|
+
...moreProps,
|
|
83
|
+
chartConfig,
|
|
84
|
+
mouseXY,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function getSelected(interactives: any) {
|
|
89
|
+
const selected = interactives
|
|
90
|
+
.map((each: any) => {
|
|
91
|
+
const objects = each.objects.filter((obj: any) => {
|
|
92
|
+
return obj.selected;
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
...each,
|
|
96
|
+
objects,
|
|
97
|
+
};
|
|
98
|
+
})
|
|
99
|
+
.filter((each: any) => each.objects.length > 0);
|
|
100
|
+
return selected;
|
|
101
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isDefined, noop } from "@tradingaction/core";
|
|
3
|
+
import { getXValue } from "@tradingaction/core/lib/utils/ChartDataUtil";
|
|
4
|
+
import { isHover, saveNodeType } from "../utils";
|
|
5
|
+
import { ChannelWithArea, ClickableCircle, HoverTextNearMouse } from "../components";
|
|
6
|
+
|
|
7
|
+
export interface EachEquidistantChannelProps {
|
|
8
|
+
readonly startXY: number[];
|
|
9
|
+
readonly endXY: number[];
|
|
10
|
+
readonly dy?: number;
|
|
11
|
+
readonly interactive: boolean;
|
|
12
|
+
readonly selected: boolean;
|
|
13
|
+
readonly hoverText: {
|
|
14
|
+
readonly enable: boolean;
|
|
15
|
+
readonly fontFamily: string;
|
|
16
|
+
readonly fontSize: number;
|
|
17
|
+
readonly fill: string;
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly bgFill: string;
|
|
20
|
+
readonly bgOpacity: number;
|
|
21
|
+
readonly bgWidth: number | string;
|
|
22
|
+
readonly bgHeight: number | string;
|
|
23
|
+
};
|
|
24
|
+
readonly appearance: {
|
|
25
|
+
readonly stroke: string;
|
|
26
|
+
readonly strokeWidth: number;
|
|
27
|
+
readonly fill: string;
|
|
28
|
+
readonly edgeStroke: string;
|
|
29
|
+
readonly edgeFill: string;
|
|
30
|
+
readonly edgeFill2: string;
|
|
31
|
+
readonly edgeStrokeWidth: number;
|
|
32
|
+
readonly r: number;
|
|
33
|
+
};
|
|
34
|
+
readonly index?: number;
|
|
35
|
+
readonly onDrag: (e: React.MouseEvent, index: number | undefined, moreProps: any) => void;
|
|
36
|
+
readonly onDragComplete?: (e: React.MouseEvent, moreProps: any) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface EachEquidistantChannelState {
|
|
40
|
+
hover: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class EachEquidistantChannel extends React.Component<EachEquidistantChannelProps, EachEquidistantChannelState> {
|
|
44
|
+
public static defaultProps = {
|
|
45
|
+
yDisplayFormat: (d: number) => d.toFixed(2),
|
|
46
|
+
interactive: true,
|
|
47
|
+
selected: false,
|
|
48
|
+
onDrag: noop,
|
|
49
|
+
hoverText: {
|
|
50
|
+
enable: false,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
private dragStart: any;
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
private isHover: any;
|
|
57
|
+
private saveNodeType: any;
|
|
58
|
+
|
|
59
|
+
public constructor(props: EachEquidistantChannelProps) {
|
|
60
|
+
super(props);
|
|
61
|
+
|
|
62
|
+
this.isHover = isHover.bind(this);
|
|
63
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
64
|
+
|
|
65
|
+
this.state = {
|
|
66
|
+
hover: false,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public render() {
|
|
71
|
+
const { startXY, endXY, dy } = this.props;
|
|
72
|
+
const { interactive, hoverText, appearance } = this.props;
|
|
73
|
+
const { edgeFill, edgeFill2, stroke, strokeWidth, fill } = appearance;
|
|
74
|
+
const { selected } = this.props;
|
|
75
|
+
const { onDragComplete } = this.props;
|
|
76
|
+
const { hover } = this.state;
|
|
77
|
+
const { enable: hoverTextEnabled, ...restHoverTextProps } = hoverText;
|
|
78
|
+
|
|
79
|
+
const hoverHandler = interactive ? { onHover: this.handleHover, onUnHover: this.handleHover } : {};
|
|
80
|
+
|
|
81
|
+
const line1Edge =
|
|
82
|
+
isDefined(startXY) && isDefined(endXY) ? (
|
|
83
|
+
<g>
|
|
84
|
+
{this.getEdgeCircle({
|
|
85
|
+
xy: startXY,
|
|
86
|
+
dragHandler: this.handleLine1Edge1Drag,
|
|
87
|
+
cursor: "react-financial-charts-move-cursor",
|
|
88
|
+
fill: edgeFill,
|
|
89
|
+
edge: "line1edge1",
|
|
90
|
+
})}
|
|
91
|
+
{this.getEdgeCircle({
|
|
92
|
+
xy: endXY,
|
|
93
|
+
dragHandler: this.handleLine1Edge2Drag,
|
|
94
|
+
cursor: "react-financial-charts-move-cursor",
|
|
95
|
+
fill: edgeFill,
|
|
96
|
+
edge: "line1edge2",
|
|
97
|
+
})}
|
|
98
|
+
</g>
|
|
99
|
+
) : null;
|
|
100
|
+
const line2Edge =
|
|
101
|
+
dy !== undefined && isDefined(dy) ? (
|
|
102
|
+
<g>
|
|
103
|
+
{this.getEdgeCircle({
|
|
104
|
+
xy: [startXY[0], startXY[1] + dy],
|
|
105
|
+
dragHandler: this.handleChannelHeightChange,
|
|
106
|
+
cursor: "react-financial-charts-ns-resize-cursor",
|
|
107
|
+
fill: edgeFill2,
|
|
108
|
+
edge: "line2edge1",
|
|
109
|
+
})}
|
|
110
|
+
{this.getEdgeCircle({
|
|
111
|
+
xy: [endXY[0], endXY[1] + dy],
|
|
112
|
+
dragHandler: this.handleChannelHeightChange,
|
|
113
|
+
cursor: "react-financial-charts-ns-resize-cursor",
|
|
114
|
+
fill: edgeFill2,
|
|
115
|
+
edge: "line2edge2",
|
|
116
|
+
})}
|
|
117
|
+
</g>
|
|
118
|
+
) : null;
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<g>
|
|
122
|
+
<ChannelWithArea
|
|
123
|
+
ref={this.saveNodeType("channel")}
|
|
124
|
+
selected={selected || hover}
|
|
125
|
+
{...hoverHandler}
|
|
126
|
+
startXY={startXY}
|
|
127
|
+
endXY={endXY}
|
|
128
|
+
dy={dy}
|
|
129
|
+
strokeStyle={stroke}
|
|
130
|
+
strokeWidth={hover || selected ? strokeWidth + 1 : strokeWidth}
|
|
131
|
+
fillStyle={fill}
|
|
132
|
+
interactiveCursorClass="react-financial-charts-move-cursor"
|
|
133
|
+
onDragStart={this.handleDragStart}
|
|
134
|
+
onDrag={this.handleChannelDrag}
|
|
135
|
+
onDragComplete={onDragComplete}
|
|
136
|
+
/>
|
|
137
|
+
{line1Edge}
|
|
138
|
+
{line2Edge}
|
|
139
|
+
<HoverTextNearMouse show={hoverTextEnabled && hover && !selected} {...restHoverTextProps} />
|
|
140
|
+
</g>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private readonly getEdgeCircle = ({ xy, dragHandler, cursor, fill, edge }: any) => {
|
|
145
|
+
const { hover } = this.state;
|
|
146
|
+
const { appearance } = this.props;
|
|
147
|
+
const { edgeStroke, edgeStrokeWidth, r } = appearance;
|
|
148
|
+
const { selected } = this.props;
|
|
149
|
+
const { onDragComplete } = this.props;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<ClickableCircle
|
|
153
|
+
ref={this.saveNodeType(edge)}
|
|
154
|
+
show={selected || hover}
|
|
155
|
+
cx={xy[0]}
|
|
156
|
+
cy={xy[1]}
|
|
157
|
+
r={r}
|
|
158
|
+
fillStyle={fill}
|
|
159
|
+
strokeStyle={edgeStroke}
|
|
160
|
+
strokeWidth={edgeStrokeWidth}
|
|
161
|
+
interactiveCursorClass={cursor}
|
|
162
|
+
onDragStart={this.handleDragStart}
|
|
163
|
+
onDrag={dragHandler}
|
|
164
|
+
onDragComplete={onDragComplete}
|
|
165
|
+
/>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
private readonly handleChannelHeightChange = (e: React.MouseEvent, moreProps: any) => {
|
|
170
|
+
const { index, onDrag } = this.props;
|
|
171
|
+
|
|
172
|
+
const { startXY, endXY } = this.dragStart;
|
|
173
|
+
|
|
174
|
+
const {
|
|
175
|
+
chartConfig: { yScale },
|
|
176
|
+
} = moreProps;
|
|
177
|
+
const { startPos, mouseXY } = moreProps;
|
|
178
|
+
|
|
179
|
+
const y2 = yScale(endXY[1]);
|
|
180
|
+
|
|
181
|
+
const dy = startPos[1] - mouseXY[1];
|
|
182
|
+
|
|
183
|
+
const newY2Value = yScale.invert(y2 - dy);
|
|
184
|
+
|
|
185
|
+
const newDy = newY2Value - endXY[1] + this.dragStart.dy;
|
|
186
|
+
|
|
187
|
+
onDrag(e, index, {
|
|
188
|
+
startXY,
|
|
189
|
+
endXY,
|
|
190
|
+
dy: newDy,
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
private readonly handleLine1Edge2Drag = (e: React.MouseEvent, moreProps: any) => {
|
|
195
|
+
const { index, onDrag } = this.props;
|
|
196
|
+
const { endXY } = this.dragStart;
|
|
197
|
+
|
|
198
|
+
const {
|
|
199
|
+
startPos,
|
|
200
|
+
mouseXY,
|
|
201
|
+
xAccessor,
|
|
202
|
+
xScale,
|
|
203
|
+
fullData,
|
|
204
|
+
chartConfig: { yScale },
|
|
205
|
+
} = moreProps;
|
|
206
|
+
|
|
207
|
+
const dx = startPos[0] - mouseXY[0];
|
|
208
|
+
const dy = startPos[1] - mouseXY[1];
|
|
209
|
+
|
|
210
|
+
const x1 = xScale(endXY[0]);
|
|
211
|
+
const y1 = yScale(endXY[1]);
|
|
212
|
+
|
|
213
|
+
const newX1Value = getXValue(xScale, xAccessor, [x1 - dx, y1 - dy], fullData);
|
|
214
|
+
const newY1Value = yScale.invert(y1 - dy);
|
|
215
|
+
|
|
216
|
+
onDrag(e, index, {
|
|
217
|
+
startXY: this.dragStart.startXY,
|
|
218
|
+
endXY: [newX1Value, newY1Value],
|
|
219
|
+
dy: this.dragStart.dy,
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
private readonly handleLine1Edge1Drag = (e: React.MouseEvent, moreProps: any) => {
|
|
224
|
+
const { index, onDrag } = this.props;
|
|
225
|
+
const { startXY } = this.dragStart;
|
|
226
|
+
|
|
227
|
+
const {
|
|
228
|
+
startPos,
|
|
229
|
+
mouseXY,
|
|
230
|
+
xAccessor,
|
|
231
|
+
xScale,
|
|
232
|
+
fullData,
|
|
233
|
+
chartConfig: { yScale },
|
|
234
|
+
} = moreProps;
|
|
235
|
+
|
|
236
|
+
const dx = startPos[0] - mouseXY[0];
|
|
237
|
+
const dy = startPos[1] - mouseXY[1];
|
|
238
|
+
|
|
239
|
+
const x1 = xScale(startXY[0]);
|
|
240
|
+
const y1 = yScale(startXY[1]);
|
|
241
|
+
|
|
242
|
+
const newX1Value = getXValue(xScale, xAccessor, [x1 - dx, y1 - dy], fullData);
|
|
243
|
+
const newY1Value = yScale.invert(y1 - dy);
|
|
244
|
+
|
|
245
|
+
onDrag(e, index, {
|
|
246
|
+
startXY: [newX1Value, newY1Value],
|
|
247
|
+
endXY: this.dragStart.endXY,
|
|
248
|
+
dy: this.dragStart.dy,
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
private readonly handleChannelDrag = (e: React.MouseEvent, moreProps: any) => {
|
|
253
|
+
const { index, onDrag } = this.props;
|
|
254
|
+
|
|
255
|
+
const { startXY, endXY } = this.dragStart;
|
|
256
|
+
|
|
257
|
+
const {
|
|
258
|
+
xScale,
|
|
259
|
+
chartConfig: { yScale },
|
|
260
|
+
xAccessor,
|
|
261
|
+
fullData,
|
|
262
|
+
} = moreProps;
|
|
263
|
+
const { startPos, mouseXY } = moreProps;
|
|
264
|
+
|
|
265
|
+
const x1 = xScale(startXY[0]);
|
|
266
|
+
const y1 = yScale(startXY[1]);
|
|
267
|
+
const x2 = xScale(endXY[0]);
|
|
268
|
+
const y2 = yScale(endXY[1]);
|
|
269
|
+
|
|
270
|
+
const dx = startPos[0] - mouseXY[0];
|
|
271
|
+
const dy = startPos[1] - mouseXY[1];
|
|
272
|
+
|
|
273
|
+
const newX1Value = getXValue(xScale, xAccessor, [x1 - dx, y1 - dy], fullData);
|
|
274
|
+
const newY1Value = yScale.invert(y1 - dy);
|
|
275
|
+
const newX2Value = getXValue(xScale, xAccessor, [x2 - dx, y2 - dy], fullData);
|
|
276
|
+
const newY2Value = yScale.invert(y2 - dy);
|
|
277
|
+
|
|
278
|
+
onDrag(e, index, {
|
|
279
|
+
startXY: [newX1Value, newY1Value],
|
|
280
|
+
endXY: [newX2Value, newY2Value],
|
|
281
|
+
dy: this.dragStart.dy,
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
private readonly handleDragStart = () => {
|
|
286
|
+
const { startXY, endXY, dy } = this.props;
|
|
287
|
+
|
|
288
|
+
this.dragStart = {
|
|
289
|
+
startXY,
|
|
290
|
+
endXY,
|
|
291
|
+
dy,
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
private readonly handleHover = (_: React.MouseEvent, moreProps: any) => {
|
|
296
|
+
if (this.state.hover !== moreProps.hovering) {
|
|
297
|
+
this.setState({
|
|
298
|
+
hover: moreProps.hovering,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|