@ivanmatiaspascual/interactive 1.3.1-sp1-beta.0.1.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 +190 -0
- 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 +83 -0
- package/lib/FibonacciRetracement.js +163 -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 +70 -0
- package/lib/InteractiveText.js +89 -0
- package/lib/InteractiveText.js.map +1 -0
- package/lib/InteractiveYCoordinate.d.ts +128 -0
- package/lib/InteractiveYCoordinate.js +106 -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 +77 -0
- package/lib/TrendLine.js +125 -0
- package/lib/TrendLine.js.map +1 -0
- package/lib/ZoomButtons.d.ts +37 -0
- package/lib/ZoomButtons.js +85 -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 +57 -0
- package/lib/components/InteractiveStraightLine.js +220 -0
- package/lib/components/InteractiveStraightLine.js.map +1 -0
- package/lib/components/InteractiveText.d.ts +37 -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 +77 -0
- package/lib/wrapper/EachFibRetracement.js +197 -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 +58 -0
- package/lib/wrapper/EachText.js +79 -0
- package/lib/wrapper/EachText.js.map +1 -0
- package/lib/wrapper/EachTrendLine.d.ts +76 -0
- package/lib/wrapper/EachTrendLine.js +141 -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 +55 -0
- package/src/Brush.tsx +177 -0
- package/src/ClickCallback.tsx +37 -0
- package/src/DrawingObjectSelector.tsx +97 -0
- package/src/EquidistantChannel.tsx +268 -0
- package/src/FibonacciRetracement.tsx +298 -0
- package/src/GannFan.tsx +233 -0
- package/src/InteractiveText.tsx +185 -0
- package/src/InteractiveYCoordinate.tsx +205 -0
- package/src/StandardDeviationChannel.tsx +269 -0
- package/src/TrendLine.tsx +283 -0
- package/src/ZoomButtons.tsx +172 -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 +317 -0
- package/src/components/InteractiveText.tsx +153 -0
- package/src/components/InteractiveYCoordinate.tsx +205 -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 +342 -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 +183 -0
- package/src/wrapper/EachTrendLine.tsx +297 -0
- package/src/wrapper/index.ts +7 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getXValue } from "@ivanmatiaspascual/core/lib/utils/ChartDataUtil";
|
|
3
|
+
import { isHover, saveNodeType } from "../utils";
|
|
4
|
+
import { HoverTextNearMouse, InteractiveText } from "../components";
|
|
5
|
+
|
|
6
|
+
export interface EachTextProps {
|
|
7
|
+
readonly index?: number;
|
|
8
|
+
readonly position?: any;
|
|
9
|
+
readonly bgFill: string;
|
|
10
|
+
readonly bgStrokeWidth: number;
|
|
11
|
+
readonly bgStroke?: string;
|
|
12
|
+
readonly textFill: string;
|
|
13
|
+
readonly fontWeight: string;
|
|
14
|
+
readonly fontFamily: string;
|
|
15
|
+
readonly fontStyle: string;
|
|
16
|
+
readonly fontSize: number;
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly selected: boolean;
|
|
19
|
+
readonly onDrag?: (e: React.MouseEvent, index: number | undefined, xyValue: number[]) => void;
|
|
20
|
+
readonly onDragComplete?: (e: React.MouseEvent, moreProps: any) => void;
|
|
21
|
+
readonly hoverText: {
|
|
22
|
+
readonly enable: boolean;
|
|
23
|
+
readonly fontFamily: string;
|
|
24
|
+
readonly fontSize: number;
|
|
25
|
+
readonly fill: string;
|
|
26
|
+
readonly text: string;
|
|
27
|
+
readonly selectedText: string;
|
|
28
|
+
readonly bgFill: string;
|
|
29
|
+
readonly bgOpacity: number;
|
|
30
|
+
readonly bgWidth: number | string;
|
|
31
|
+
readonly bgHeight: number | string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface EachTextState {
|
|
36
|
+
hover: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class EachText extends React.Component<EachTextProps, EachTextState> {
|
|
40
|
+
public static defaultProps = {
|
|
41
|
+
bgStrokeWidth: 1,
|
|
42
|
+
selected: false,
|
|
43
|
+
hoverText: {
|
|
44
|
+
...HoverTextNearMouse.defaultProps,
|
|
45
|
+
enable: true,
|
|
46
|
+
bgHeight: "auto",
|
|
47
|
+
bgWidth: "auto",
|
|
48
|
+
text: "Click to select object",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
private dragStartPosition: any;
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
private isHover: any;
|
|
55
|
+
private saveNodeType: any;
|
|
56
|
+
|
|
57
|
+
public constructor(props: EachTextProps) {
|
|
58
|
+
super(props);
|
|
59
|
+
|
|
60
|
+
this.handleHover = this.handleHover.bind(this);
|
|
61
|
+
|
|
62
|
+
this.handleDragStart = this.handleDragStart.bind(this);
|
|
63
|
+
this.handleDrag = this.handleDrag.bind(this);
|
|
64
|
+
|
|
65
|
+
this.isHover = isHover.bind(this);
|
|
66
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
67
|
+
|
|
68
|
+
this.state = {
|
|
69
|
+
hover: false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public render() {
|
|
74
|
+
const {
|
|
75
|
+
position,
|
|
76
|
+
bgFill,
|
|
77
|
+
bgStroke,
|
|
78
|
+
bgStrokeWidth,
|
|
79
|
+
textFill,
|
|
80
|
+
fontFamily,
|
|
81
|
+
fontSize,
|
|
82
|
+
fontWeight,
|
|
83
|
+
fontStyle,
|
|
84
|
+
text,
|
|
85
|
+
hoverText,
|
|
86
|
+
selected,
|
|
87
|
+
onDragComplete,
|
|
88
|
+
} = this.props;
|
|
89
|
+
const { hover } = this.state;
|
|
90
|
+
|
|
91
|
+
const hoverHandler = {
|
|
92
|
+
onHover: this.handleHover,
|
|
93
|
+
onUnHover: this.handleHover,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const {
|
|
97
|
+
enable: hoverTextEnabled,
|
|
98
|
+
selectedText: hoverTextSelected,
|
|
99
|
+
text: hoverTextUnselected,
|
|
100
|
+
...restHoverTextProps
|
|
101
|
+
} = hoverText;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<g>
|
|
105
|
+
<InteractiveText
|
|
106
|
+
ref={this.saveNodeType("text")}
|
|
107
|
+
selected={selected || hover}
|
|
108
|
+
interactiveCursorClass="react-financial-charts-move-cursor"
|
|
109
|
+
{...hoverHandler}
|
|
110
|
+
onDragStart={this.handleDragStart}
|
|
111
|
+
onDrag={this.handleDrag}
|
|
112
|
+
onDragComplete={onDragComplete}
|
|
113
|
+
position={position}
|
|
114
|
+
bgFillStyle={bgFill}
|
|
115
|
+
bgStroke={bgStroke || textFill}
|
|
116
|
+
bgStrokeWidth={bgStrokeWidth}
|
|
117
|
+
textFill={textFill}
|
|
118
|
+
fontFamily={fontFamily}
|
|
119
|
+
fontStyle={fontStyle}
|
|
120
|
+
fontWeight={fontWeight}
|
|
121
|
+
fontSize={fontSize}
|
|
122
|
+
text={text}
|
|
123
|
+
/>
|
|
124
|
+
<HoverTextNearMouse
|
|
125
|
+
show={hoverTextEnabled && hover}
|
|
126
|
+
{...restHoverTextProps}
|
|
127
|
+
text={selected ? hoverTextSelected : hoverTextUnselected}
|
|
128
|
+
/>
|
|
129
|
+
</g>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private readonly handleHover = (_: React.MouseEvent, moreProps: any) => {
|
|
134
|
+
if (this.state.hover !== moreProps.hovering) {
|
|
135
|
+
this.setState({
|
|
136
|
+
hover: moreProps.hovering,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
private readonly handleDrag = (e: React.MouseEvent, moreProps: any) => {
|
|
142
|
+
const { index, onDrag } = this.props;
|
|
143
|
+
if (onDrag === undefined) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const {
|
|
148
|
+
mouseXY: [, mouseY],
|
|
149
|
+
chartConfig: { yScale },
|
|
150
|
+
xAccessor,
|
|
151
|
+
mouseXY,
|
|
152
|
+
plotData,
|
|
153
|
+
xScale,
|
|
154
|
+
} = moreProps;
|
|
155
|
+
|
|
156
|
+
const { dx, dy } = this.dragStartPosition;
|
|
157
|
+
const xValue = xScale.invert(xScale(getXValue(xScale, xAccessor, mouseXY, plotData)) - dx);
|
|
158
|
+
// xScale.invert(xScale(xAccessor(currentItem)) - dx);
|
|
159
|
+
const xyValue = [xValue, yScale.invert(mouseY - dy)];
|
|
160
|
+
|
|
161
|
+
onDrag(e, index, xyValue);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
private readonly handleDragStart = (_: React.MouseEvent, moreProps: any) => {
|
|
165
|
+
const { position } = this.props;
|
|
166
|
+
const { mouseXY } = moreProps;
|
|
167
|
+
const {
|
|
168
|
+
chartConfig: { yScale },
|
|
169
|
+
xScale,
|
|
170
|
+
} = moreProps;
|
|
171
|
+
const [mouseX, mouseY] = mouseXY;
|
|
172
|
+
|
|
173
|
+
const [textCX, textCY] = position;
|
|
174
|
+
const dx = mouseX - xScale(textCX);
|
|
175
|
+
const dy = mouseY - yScale(textCY);
|
|
176
|
+
|
|
177
|
+
this.dragStartPosition = {
|
|
178
|
+
position,
|
|
179
|
+
dx,
|
|
180
|
+
dy,
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ascending as d3Ascending } from "d3-array";
|
|
3
|
+
import { noop, strokeDashTypes } from "@ivanmatiaspascual/core";
|
|
4
|
+
import { getXValue } from "@ivanmatiaspascual/core/lib/utils/ChartDataUtil";
|
|
5
|
+
import { isHover, saveNodeType } from "../utils";
|
|
6
|
+
import { ClickableCircle, HoverTextNearMouse, InteractiveStraightLine } from "../components";
|
|
7
|
+
|
|
8
|
+
export interface EachTrendLineProps {
|
|
9
|
+
readonly x1Value: any;
|
|
10
|
+
readonly x2Value: any;
|
|
11
|
+
readonly y1Value: any;
|
|
12
|
+
readonly y2Value: any;
|
|
13
|
+
readonly index?: number;
|
|
14
|
+
readonly type:
|
|
15
|
+
| "XLINE" // extends from -Infinity to +Infinity
|
|
16
|
+
| "RAY" // extends to +/-Infinity in one direction
|
|
17
|
+
| "LINE"; // extends between the set bounds
|
|
18
|
+
readonly onDrag: (e: React.MouseEvent, index: number | undefined, moreProps: any) => void;
|
|
19
|
+
readonly onEdge1Drag: any; // func
|
|
20
|
+
readonly onEdge2Drag: any; // func
|
|
21
|
+
readonly onDragComplete?: (e: React.MouseEvent, moreProps: any) => void;
|
|
22
|
+
readonly onSelect: (e: React.MouseEvent, interactives: any[], moreProps: any) => void;
|
|
23
|
+
readonly r: number;
|
|
24
|
+
readonly strokeOpacity: number;
|
|
25
|
+
readonly defaultClassName?: string;
|
|
26
|
+
readonly selected?: boolean;
|
|
27
|
+
readonly strokeStyle: string;
|
|
28
|
+
readonly strokeWidth: number;
|
|
29
|
+
readonly strokeDasharray: strokeDashTypes;
|
|
30
|
+
readonly edgeStrokeWidth: number;
|
|
31
|
+
readonly edgeStroke: string;
|
|
32
|
+
readonly edgeInteractiveCursor: string;
|
|
33
|
+
readonly lineInteractiveCursor: string;
|
|
34
|
+
readonly edgeFill: string;
|
|
35
|
+
readonly hoverText: {
|
|
36
|
+
readonly enable: boolean;
|
|
37
|
+
readonly fontFamily: string;
|
|
38
|
+
readonly fontSize: number;
|
|
39
|
+
readonly fill: string;
|
|
40
|
+
readonly text: string;
|
|
41
|
+
readonly selectedText: string;
|
|
42
|
+
readonly bgFill: string;
|
|
43
|
+
readonly bgOpacity: number;
|
|
44
|
+
readonly bgWidth: number | string;
|
|
45
|
+
readonly bgHeight: number | string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface EachTrendLineState {
|
|
50
|
+
anchor?: string;
|
|
51
|
+
hover?: any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class EachTrendLine extends React.Component<EachTrendLineProps, EachTrendLineState> {
|
|
55
|
+
public static defaultProps = {
|
|
56
|
+
onDrag: noop,
|
|
57
|
+
onEdge1Drag: noop,
|
|
58
|
+
onEdge2Drag: noop,
|
|
59
|
+
onSelect: noop,
|
|
60
|
+
selected: false,
|
|
61
|
+
edgeStroke: "#000000",
|
|
62
|
+
edgeFill: "#FFFFFF",
|
|
63
|
+
edgeStrokeWidth: 2,
|
|
64
|
+
r: 5,
|
|
65
|
+
strokeWidth: 1,
|
|
66
|
+
strokeDasharray: "Solid",
|
|
67
|
+
hoverText: {
|
|
68
|
+
enable: false,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
private dragStart: any;
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
private isHover: any;
|
|
75
|
+
private saveNodeType: any;
|
|
76
|
+
|
|
77
|
+
public constructor(props: EachTrendLineProps) {
|
|
78
|
+
super(props);
|
|
79
|
+
|
|
80
|
+
this.isHover = isHover.bind(this);
|
|
81
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
82
|
+
|
|
83
|
+
this.state = {
|
|
84
|
+
hover: false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public render() {
|
|
89
|
+
const {
|
|
90
|
+
x1Value,
|
|
91
|
+
y1Value,
|
|
92
|
+
x2Value,
|
|
93
|
+
y2Value,
|
|
94
|
+
type,
|
|
95
|
+
strokeStyle,
|
|
96
|
+
strokeWidth,
|
|
97
|
+
strokeDasharray,
|
|
98
|
+
r,
|
|
99
|
+
edgeStrokeWidth,
|
|
100
|
+
edgeFill,
|
|
101
|
+
edgeStroke,
|
|
102
|
+
edgeInteractiveCursor,
|
|
103
|
+
lineInteractiveCursor,
|
|
104
|
+
hoverText,
|
|
105
|
+
selected,
|
|
106
|
+
onDragComplete,
|
|
107
|
+
} = this.props;
|
|
108
|
+
|
|
109
|
+
const {
|
|
110
|
+
enable: hoverTextEnabled,
|
|
111
|
+
selectedText: hoverTextSelected,
|
|
112
|
+
text: hoverTextUnselected,
|
|
113
|
+
...restHoverTextProps
|
|
114
|
+
} = hoverText;
|
|
115
|
+
|
|
116
|
+
const { hover, anchor } = this.state;
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<g>
|
|
120
|
+
<InteractiveStraightLine
|
|
121
|
+
ref={this.saveNodeType("line")}
|
|
122
|
+
selected={selected || hover}
|
|
123
|
+
onHover={this.handleHover}
|
|
124
|
+
onUnHover={this.handleHover}
|
|
125
|
+
x1Value={x1Value}
|
|
126
|
+
y1Value={y1Value}
|
|
127
|
+
x2Value={x2Value}
|
|
128
|
+
y2Value={y2Value}
|
|
129
|
+
type={type}
|
|
130
|
+
strokeStyle={strokeStyle}
|
|
131
|
+
strokeWidth={hover || selected ? strokeWidth + 1 : strokeWidth}
|
|
132
|
+
strokeDasharray={strokeDasharray}
|
|
133
|
+
interactiveCursorClass={lineInteractiveCursor}
|
|
134
|
+
onDragStart={this.handleLineDragStart}
|
|
135
|
+
onDrag={this.handleLineDrag}
|
|
136
|
+
onDragComplete={onDragComplete}
|
|
137
|
+
/>
|
|
138
|
+
<ClickableCircle
|
|
139
|
+
ref={this.saveNodeType("edge1")}
|
|
140
|
+
show={selected || hover}
|
|
141
|
+
cx={x1Value}
|
|
142
|
+
cy={y1Value}
|
|
143
|
+
r={r}
|
|
144
|
+
fillStyle={edgeFill}
|
|
145
|
+
strokeStyle={anchor === "edge1" ? strokeStyle : edgeStroke}
|
|
146
|
+
strokeWidth={edgeStrokeWidth}
|
|
147
|
+
interactiveCursorClass={edgeInteractiveCursor}
|
|
148
|
+
onDragStart={this.handleEdge1DragStart}
|
|
149
|
+
onDrag={this.handleEdge1Drag}
|
|
150
|
+
onDragComplete={this.handleDragComplete}
|
|
151
|
+
/>
|
|
152
|
+
<ClickableCircle
|
|
153
|
+
ref={this.saveNodeType("edge2")}
|
|
154
|
+
show={selected || hover}
|
|
155
|
+
cx={x2Value}
|
|
156
|
+
cy={y2Value}
|
|
157
|
+
r={r}
|
|
158
|
+
fillStyle={edgeFill}
|
|
159
|
+
strokeStyle={anchor === "edge2" ? strokeStyle : edgeStroke}
|
|
160
|
+
strokeWidth={edgeStrokeWidth}
|
|
161
|
+
interactiveCursorClass={edgeInteractiveCursor}
|
|
162
|
+
onDragStart={this.handleEdge2DragStart}
|
|
163
|
+
onDrag={this.handleEdge2Drag}
|
|
164
|
+
onDragComplete={this.handleDragComplete}
|
|
165
|
+
/>
|
|
166
|
+
<HoverTextNearMouse
|
|
167
|
+
show={hoverTextEnabled && hover}
|
|
168
|
+
{...restHoverTextProps}
|
|
169
|
+
text={selected ? hoverTextSelected : hoverTextUnselected}
|
|
170
|
+
/>
|
|
171
|
+
</g>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private readonly handleHover = (_: React.MouseEvent, moreProps: any) => {
|
|
176
|
+
if (this.state.hover !== moreProps.hovering) {
|
|
177
|
+
this.setState({
|
|
178
|
+
hover: moreProps.hovering,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
private readonly handleEdge2Drag = (e: React.MouseEvent, moreProps: any) => {
|
|
184
|
+
const { index, onDrag, x1Value, y1Value } = this.props;
|
|
185
|
+
|
|
186
|
+
const [x2Value, y2Value] = getNewXY(moreProps);
|
|
187
|
+
|
|
188
|
+
onDrag(e, index, {
|
|
189
|
+
x1Value,
|
|
190
|
+
y1Value,
|
|
191
|
+
x2Value,
|
|
192
|
+
y2Value,
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
private readonly handleEdge1Drag = (e: React.MouseEvent, moreProps: any) => {
|
|
197
|
+
const { index, onDrag, x2Value, y2Value } = this.props;
|
|
198
|
+
|
|
199
|
+
const [x1Value, y1Value] = getNewXY(moreProps);
|
|
200
|
+
|
|
201
|
+
onDrag(e, index, {
|
|
202
|
+
x1Value,
|
|
203
|
+
y1Value,
|
|
204
|
+
x2Value,
|
|
205
|
+
y2Value,
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
private readonly handleDragComplete = (e: React.MouseEvent, moreProps: any) => {
|
|
210
|
+
this.setState({
|
|
211
|
+
anchor: undefined,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const { onDragComplete } = this.props;
|
|
215
|
+
if (onDragComplete === undefined) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
onDragComplete(e, moreProps);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
private readonly handleEdge2DragStart = () => {
|
|
223
|
+
this.setState({
|
|
224
|
+
anchor: "edge1",
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
private readonly handleEdge1DragStart = () => {
|
|
229
|
+
this.setState({
|
|
230
|
+
anchor: "edge2",
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
private readonly handleLineDrag = (e: React.MouseEvent, moreProps: any) => {
|
|
235
|
+
const { index, onDrag } = this.props;
|
|
236
|
+
|
|
237
|
+
const { x1Value, y1Value, x2Value, y2Value } = this.dragStart;
|
|
238
|
+
|
|
239
|
+
const {
|
|
240
|
+
xScale,
|
|
241
|
+
chartConfig: { yScale },
|
|
242
|
+
xAccessor,
|
|
243
|
+
fullData,
|
|
244
|
+
} = moreProps;
|
|
245
|
+
const { startPos, mouseXY } = moreProps;
|
|
246
|
+
|
|
247
|
+
const x1 = xScale(x1Value);
|
|
248
|
+
const y1 = yScale(y1Value);
|
|
249
|
+
const x2 = xScale(x2Value);
|
|
250
|
+
const y2 = yScale(y2Value);
|
|
251
|
+
|
|
252
|
+
const dx = startPos[0] - mouseXY[0];
|
|
253
|
+
const dy = startPos[1] - mouseXY[1];
|
|
254
|
+
|
|
255
|
+
const newX1Value = getXValue(xScale, xAccessor, [x1 - dx, y1 - dy], fullData);
|
|
256
|
+
const newY1Value = yScale.invert(y1 - dy);
|
|
257
|
+
const newX2Value = getXValue(xScale, xAccessor, [x2 - dx, y2 - dy], fullData);
|
|
258
|
+
const newY2Value = yScale.invert(y2 - dy);
|
|
259
|
+
|
|
260
|
+
onDrag(e, index, {
|
|
261
|
+
x1Value: newX1Value,
|
|
262
|
+
y1Value: newY1Value,
|
|
263
|
+
x2Value: newX2Value,
|
|
264
|
+
y2Value: newY2Value,
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
private readonly handleLineDragStart = () => {
|
|
269
|
+
const { x1Value, y1Value, x2Value, y2Value } = this.props;
|
|
270
|
+
|
|
271
|
+
this.dragStart = {
|
|
272
|
+
x1Value,
|
|
273
|
+
y1Value,
|
|
274
|
+
x2Value,
|
|
275
|
+
y2Value,
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function getNewXY(moreProps: any) {
|
|
281
|
+
const {
|
|
282
|
+
xScale,
|
|
283
|
+
chartConfig: { yScale },
|
|
284
|
+
xAccessor,
|
|
285
|
+
plotData,
|
|
286
|
+
mouseXY,
|
|
287
|
+
} = moreProps;
|
|
288
|
+
const mouseY = mouseXY[1];
|
|
289
|
+
|
|
290
|
+
const x = getXValue(xScale, xAccessor, mouseXY, plotData);
|
|
291
|
+
|
|
292
|
+
const [small, big] = yScale.domain().slice().sort(d3Ascending);
|
|
293
|
+
const y = yScale.invert(mouseY);
|
|
294
|
+
const newY = Math.min(Math.max(y, small), big);
|
|
295
|
+
|
|
296
|
+
return [x, newY];
|
|
297
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { EachEquidistantChannel } from "./EachEquidistantChannel";
|
|
2
|
+
export { EachFibRetracement } from "./EachFibRetracement";
|
|
3
|
+
export { EachGannFan } from "./EachGannFan";
|
|
4
|
+
export { EachInteractiveYCoordinate } from "./EachInteractiveYCoordinate";
|
|
5
|
+
export { EachLinearRegressionChannel } from "./EachLinearRegressionChannel";
|
|
6
|
+
export { EachText } from "./EachText";
|
|
7
|
+
export { EachTrendLine } from "./EachTrendLine";
|