@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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { strokeDashTypes } from "@tradingaction/core";
|
|
3
|
+
interface InteractiveYCoordinateProps {
|
|
4
|
+
readonly onChoosePosition: (e: React.MouseEvent, newText: any, moreProps: any) => void;
|
|
5
|
+
readonly onDragComplete: (e: React.MouseEvent, newAlertList: any[], moreProps: any, draggedAlert: any) => void;
|
|
6
|
+
readonly onSelect?: (e: React.MouseEvent, interactives: any[], moreProps: any) => void;
|
|
7
|
+
readonly onDelete?: (e: React.MouseEvent, yCoordinate: any, moreProps: any) => void;
|
|
8
|
+
readonly defaultPriceCoordinate: {
|
|
9
|
+
readonly bgFill: string;
|
|
10
|
+
readonly bgOpacity: number;
|
|
11
|
+
readonly stroke: string;
|
|
12
|
+
readonly strokeDasharray: strokeDashTypes;
|
|
13
|
+
readonly strokeOpacity: number;
|
|
14
|
+
readonly strokeWidth: number;
|
|
15
|
+
readonly textFill: string;
|
|
16
|
+
readonly fontFamily: string;
|
|
17
|
+
readonly fontWeight: string;
|
|
18
|
+
readonly fontStyle: string;
|
|
19
|
+
readonly fontSize: number;
|
|
20
|
+
readonly text: string;
|
|
21
|
+
readonly textBox: {
|
|
22
|
+
readonly height: number;
|
|
23
|
+
readonly left: number;
|
|
24
|
+
readonly padding: {
|
|
25
|
+
left: number;
|
|
26
|
+
right: number;
|
|
27
|
+
};
|
|
28
|
+
readonly closeIcon: {
|
|
29
|
+
padding: {
|
|
30
|
+
left: number;
|
|
31
|
+
right: number;
|
|
32
|
+
};
|
|
33
|
+
width: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly edge: {
|
|
37
|
+
readonly stroke: string;
|
|
38
|
+
readonly strokeOpacity: number;
|
|
39
|
+
readonly strokeWidth: number;
|
|
40
|
+
readonly fill: string;
|
|
41
|
+
readonly fillOpacity: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
readonly hoverText: object;
|
|
45
|
+
readonly yCoordinateList: any[];
|
|
46
|
+
readonly enabled: boolean;
|
|
47
|
+
}
|
|
48
|
+
interface InteractiveYCoordinateState {
|
|
49
|
+
current?: any;
|
|
50
|
+
override?: any;
|
|
51
|
+
}
|
|
52
|
+
export declare class InteractiveYCoordinate extends React.Component<InteractiveYCoordinateProps, InteractiveYCoordinateState> {
|
|
53
|
+
static defaultProps: {
|
|
54
|
+
defaultPriceCoordinate: {
|
|
55
|
+
bgFill: string;
|
|
56
|
+
bgOpacity: number;
|
|
57
|
+
stroke: string;
|
|
58
|
+
strokeOpacity: number;
|
|
59
|
+
strokeDasharray: string;
|
|
60
|
+
strokeWidth: number;
|
|
61
|
+
textFill: string;
|
|
62
|
+
fontFamily: string;
|
|
63
|
+
fontSize: number;
|
|
64
|
+
fontStyle: string;
|
|
65
|
+
fontWeight: string;
|
|
66
|
+
text: string;
|
|
67
|
+
textBox: {
|
|
68
|
+
height: number;
|
|
69
|
+
left: number;
|
|
70
|
+
padding: {
|
|
71
|
+
left: number;
|
|
72
|
+
right: number;
|
|
73
|
+
};
|
|
74
|
+
closeIcon: {
|
|
75
|
+
padding: {
|
|
76
|
+
left: number;
|
|
77
|
+
right: number;
|
|
78
|
+
};
|
|
79
|
+
width: number;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
edge: {
|
|
83
|
+
stroke: string;
|
|
84
|
+
strokeOpacity: number;
|
|
85
|
+
strokeWidth: number;
|
|
86
|
+
fill: string;
|
|
87
|
+
fillOpacity: number;
|
|
88
|
+
orient: string;
|
|
89
|
+
at: string;
|
|
90
|
+
arrowWidth: number;
|
|
91
|
+
dx: number;
|
|
92
|
+
rectWidth: number;
|
|
93
|
+
rectHeight: number;
|
|
94
|
+
displayFormat: (n: number | {
|
|
95
|
+
valueOf(): number;
|
|
96
|
+
}) => string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
hoverText: {
|
|
100
|
+
enable: boolean;
|
|
101
|
+
bgHeight: number;
|
|
102
|
+
bgWidth: number;
|
|
103
|
+
text: string;
|
|
104
|
+
fontFamily: string;
|
|
105
|
+
fontSize: number;
|
|
106
|
+
fill: string;
|
|
107
|
+
bgFill: string;
|
|
108
|
+
bgOpacity: number;
|
|
109
|
+
};
|
|
110
|
+
yCoordinateList: never[];
|
|
111
|
+
};
|
|
112
|
+
static contextType: React.Context<import("@tradingaction/core").ChartContextType>;
|
|
113
|
+
private getSelectionState;
|
|
114
|
+
private saveNodeType;
|
|
115
|
+
private terminate;
|
|
116
|
+
constructor(props: InteractiveYCoordinateProps);
|
|
117
|
+
render(): JSX.Element;
|
|
118
|
+
private readonly handleDelete;
|
|
119
|
+
private readonly handleDragComplete;
|
|
120
|
+
private readonly handleDrag;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { format } from "d3-format";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ChartContext, isDefined } from "@tradingaction/core";
|
|
4
|
+
import { HoverTextNearMouse } from "./components";
|
|
5
|
+
import { getValueFromOverride, isHoverForInteractiveType, saveNodeType, terminate } from "./utils";
|
|
6
|
+
import { EachInteractiveYCoordinate } from "./wrapper";
|
|
7
|
+
export class InteractiveYCoordinate extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.handleDelete = (e, index, moreProps) => {
|
|
11
|
+
const { onDelete, yCoordinateList } = this.props;
|
|
12
|
+
if (onDelete !== undefined && index !== undefined) {
|
|
13
|
+
onDelete(e, yCoordinateList[index], moreProps);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
this.handleDragComplete = (e, moreProps) => {
|
|
17
|
+
const { override } = this.state;
|
|
18
|
+
if (isDefined(override)) {
|
|
19
|
+
const { yCoordinateList } = this.props;
|
|
20
|
+
const newAlertList = yCoordinateList.map((each, idx) => {
|
|
21
|
+
const selected = idx === override.index;
|
|
22
|
+
return selected
|
|
23
|
+
? Object.assign(Object.assign({}, each), { yValue: override.yValue, selected }) : Object.assign(Object.assign({}, each), { selected });
|
|
24
|
+
});
|
|
25
|
+
const draggedAlert = newAlertList[override.index];
|
|
26
|
+
this.setState({
|
|
27
|
+
override: null,
|
|
28
|
+
}, () => {
|
|
29
|
+
const { onDragComplete } = this.props;
|
|
30
|
+
if (onDragComplete !== undefined) {
|
|
31
|
+
onDragComplete(e, newAlertList, moreProps, draggedAlert);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.handleDrag = (_, index, yValue) => {
|
|
37
|
+
this.setState({
|
|
38
|
+
override: {
|
|
39
|
+
index,
|
|
40
|
+
yValue,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
this.terminate = terminate.bind(this);
|
|
45
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
46
|
+
this.getSelectionState = isHoverForInteractiveType("yCoordinateList").bind(this);
|
|
47
|
+
this.state = {};
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
const { yCoordinateList } = this.props;
|
|
51
|
+
const { override } = this.state;
|
|
52
|
+
return (React.createElement("g", null, yCoordinateList.map((each, idx) => {
|
|
53
|
+
const props = each;
|
|
54
|
+
return (React.createElement(EachInteractiveYCoordinate, Object.assign({ key: each.id, ref: this.saveNodeType(idx), index: idx }, props, { selected: each.selected, yValue: getValueFromOverride(override, idx, "yValue", each.yValue), onDelete: this.handleDelete, onDrag: this.handleDrag, onDragComplete: this.handleDragComplete, edgeInteractiveCursor: "react-financial-charts-move-cursor" })));
|
|
55
|
+
})));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
InteractiveYCoordinate.defaultProps = {
|
|
59
|
+
defaultPriceCoordinate: {
|
|
60
|
+
bgFill: "#FFFFFF",
|
|
61
|
+
bgOpacity: 1,
|
|
62
|
+
stroke: "#6574CD",
|
|
63
|
+
strokeOpacity: 1,
|
|
64
|
+
strokeDasharray: "ShortDash2",
|
|
65
|
+
strokeWidth: 1,
|
|
66
|
+
textFill: "#6574CD",
|
|
67
|
+
fontFamily: "-apple-system, system-ui, Roboto, 'Helvetica Neue', Ubuntu, sans-serif",
|
|
68
|
+
fontSize: 12,
|
|
69
|
+
fontStyle: "normal",
|
|
70
|
+
fontWeight: "normal",
|
|
71
|
+
text: "Alert",
|
|
72
|
+
textBox: {
|
|
73
|
+
height: 24,
|
|
74
|
+
left: 20,
|
|
75
|
+
padding: { left: 10, right: 5 },
|
|
76
|
+
closeIcon: {
|
|
77
|
+
padding: { left: 5, right: 8 },
|
|
78
|
+
width: 8,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
edge: {
|
|
82
|
+
stroke: "#6574CD",
|
|
83
|
+
strokeOpacity: 1,
|
|
84
|
+
strokeWidth: 1,
|
|
85
|
+
fill: "#FFFFFF",
|
|
86
|
+
fillOpacity: 1,
|
|
87
|
+
orient: "right",
|
|
88
|
+
at: "right",
|
|
89
|
+
arrowWidth: 10,
|
|
90
|
+
dx: 0,
|
|
91
|
+
rectWidth: 50,
|
|
92
|
+
rectHeight: 20,
|
|
93
|
+
displayFormat: format(".2f"),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
hoverText: Object.assign(Object.assign({}, HoverTextNearMouse.defaultProps), { enable: true, bgHeight: 18, bgWidth: 175, text: "Click and drag the edge circles" }),
|
|
97
|
+
yCoordinateList: [],
|
|
98
|
+
};
|
|
99
|
+
InteractiveYCoordinate.contextType = ChartContext;
|
|
100
|
+
//# sourceMappingURL=InteractiveYCoordinate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractiveYCoordinate.js","sourceRoot":"","sources":["../src/InteractiveYCoordinate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAmB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAqDvD,MAAM,OAAO,sBAAuB,SAAQ,KAAK,CAAC,SAAmE;IAyDjH,YAAmB,KAAkC;QACjD,KAAK,CAAC,KAAK,CAAC,CAAC;QAmCA,iBAAY,GAAG,CAAC,CAAmB,EAAE,KAAyB,EAAE,SAAc,EAAE,EAAE;YAC/F,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YACjD,IAAI,QAAQ,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;gBAC/C,QAAQ,CAAC,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;aAClD;QACL,CAAC,CAAC;QAEe,uBAAkB,GAAG,CAAC,CAAmB,EAAE,SAAc,EAAE,EAAE;YAC1E,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAChC,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;gBACrB,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;gBACvC,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,IA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J;QACD,IAAI,EAAE;YACF,MAAM,EAAE,SAAS;YACjB,aAAa,EAAE,CAAC;YAChB,WAAW,EAAE,CAAC;YACd,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,CAAC;YACd,MAAM,EAAE,OAAO;YACf,EAAE,EAAE,OAAO;YACX,UAAU,EAAE,EAAE;YACd,EAAE,EAAE,CAAC;YACL,SAAS,EAAE,EAAE;YACb,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC;SAC/B;KACJ;IACD,SAAS,kCACF,kBAAkB,CAAC,YAAY,KAClC,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,iCAAiC,GAC1C;IACD,eAAe,EAAE,EAAE;CACtB,CAAC;AAEY,kCAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface StandardDeviationChannelProps {
|
|
3
|
+
readonly enabled: boolean;
|
|
4
|
+
readonly snapTo?: (datum: any) => number;
|
|
5
|
+
readonly onStart?: () => void;
|
|
6
|
+
readonly onComplete?: (e: React.MouseEvent, newChannels: any, moreProps: any) => void;
|
|
7
|
+
readonly onSelect?: (e: React.MouseEvent, interactives: any[], moreProps: any) => void;
|
|
8
|
+
readonly currentPositionStroke?: string;
|
|
9
|
+
readonly currentPositionStrokeWidth?: number;
|
|
10
|
+
readonly currentPositionOpacity?: number;
|
|
11
|
+
readonly currentPositionRadius?: number;
|
|
12
|
+
readonly appearance: {
|
|
13
|
+
readonly stroke?: string;
|
|
14
|
+
readonly strokeOpacity?: number;
|
|
15
|
+
readonly strokeWidth?: number;
|
|
16
|
+
readonly fill?: string;
|
|
17
|
+
readonly fillOpacity?: number;
|
|
18
|
+
readonly edgeStrokeWidth?: number;
|
|
19
|
+
readonly edgeStroke?: string;
|
|
20
|
+
readonly edgeFill?: string;
|
|
21
|
+
readonly r?: number;
|
|
22
|
+
};
|
|
23
|
+
readonly hoverText: object;
|
|
24
|
+
readonly channels: any[];
|
|
25
|
+
}
|
|
26
|
+
interface StandardDeviationChannelState {
|
|
27
|
+
current?: any;
|
|
28
|
+
override?: any;
|
|
29
|
+
}
|
|
30
|
+
export declare class StandardDeviationChannel extends React.Component<StandardDeviationChannelProps, StandardDeviationChannelState> {
|
|
31
|
+
static defaultProps: {
|
|
32
|
+
snapTo: (d: any) => any;
|
|
33
|
+
appearance: {
|
|
34
|
+
stroke: string;
|
|
35
|
+
fillOpacity: number;
|
|
36
|
+
strokeOpacity: number;
|
|
37
|
+
strokeWidth: number;
|
|
38
|
+
fill: string;
|
|
39
|
+
edgeStrokeWidth: number;
|
|
40
|
+
edgeStroke: string;
|
|
41
|
+
edgeFill: string;
|
|
42
|
+
r: number;
|
|
43
|
+
};
|
|
44
|
+
currentPositionStroke: string;
|
|
45
|
+
currentPositionOpacity: number;
|
|
46
|
+
currentPositionStrokeWidth: number;
|
|
47
|
+
currentPositionRadius: number;
|
|
48
|
+
hoverText: {
|
|
49
|
+
enable: boolean;
|
|
50
|
+
bgHeight: string;
|
|
51
|
+
bgWidth: string;
|
|
52
|
+
text: string;
|
|
53
|
+
selectedText: string;
|
|
54
|
+
fontFamily: string;
|
|
55
|
+
fontSize: number;
|
|
56
|
+
fill: string;
|
|
57
|
+
bgFill: string;
|
|
58
|
+
bgOpacity: number;
|
|
59
|
+
};
|
|
60
|
+
channels: never[];
|
|
61
|
+
};
|
|
62
|
+
private getSelectionState;
|
|
63
|
+
private mouseMoved;
|
|
64
|
+
private saveNodeType;
|
|
65
|
+
private terminate;
|
|
66
|
+
constructor(props: StandardDeviationChannelProps);
|
|
67
|
+
render(): JSX.Element;
|
|
68
|
+
private handleEnd;
|
|
69
|
+
private readonly handleStart;
|
|
70
|
+
private readonly handleDrawLine;
|
|
71
|
+
private readonly handleDragLineComplete;
|
|
72
|
+
private readonly handleDragLine;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isDefined, isNotDefined } from "@tradingaction/core";
|
|
3
|
+
import { getValueFromOverride, isHoverForInteractiveType, saveNodeType, terminate } from "./utils";
|
|
4
|
+
import { HoverTextNearMouse, MouseLocationIndicator } from "./components";
|
|
5
|
+
import { EachLinearRegressionChannel } from "./wrapper";
|
|
6
|
+
export class StandardDeviationChannel extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.handleEnd = (e, xyValue, moreProps) => {
|
|
10
|
+
const { current } = this.state;
|
|
11
|
+
const { appearance, channels } = this.props;
|
|
12
|
+
if (this.mouseMoved && isDefined(current) && isDefined(current.start)) {
|
|
13
|
+
const newChannels = [
|
|
14
|
+
...channels.map((d) => (Object.assign(Object.assign({}, d), { selected: false }))),
|
|
15
|
+
{
|
|
16
|
+
start: current.start,
|
|
17
|
+
end: xyValue,
|
|
18
|
+
selected: true,
|
|
19
|
+
appearance,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
this.setState({
|
|
23
|
+
current: null,
|
|
24
|
+
}, () => {
|
|
25
|
+
const { onComplete } = this.props;
|
|
26
|
+
if (onComplete !== undefined) {
|
|
27
|
+
onComplete(e, newChannels, moreProps);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this.handleStart = (_, xyValue) => {
|
|
33
|
+
const { current } = this.state;
|
|
34
|
+
if (isNotDefined(current) || isNotDefined(current.start)) {
|
|
35
|
+
this.mouseMoved = false;
|
|
36
|
+
this.setState({
|
|
37
|
+
current: {
|
|
38
|
+
start: xyValue,
|
|
39
|
+
end: null,
|
|
40
|
+
},
|
|
41
|
+
}, () => {
|
|
42
|
+
const { onStart } = this.props;
|
|
43
|
+
if (onStart !== undefined) {
|
|
44
|
+
onStart();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.handleDrawLine = (e, xyValue) => {
|
|
50
|
+
const { current } = this.state;
|
|
51
|
+
if (isDefined(current) && isDefined(current.start)) {
|
|
52
|
+
this.mouseMoved = true;
|
|
53
|
+
this.setState({
|
|
54
|
+
current: {
|
|
55
|
+
start: current.start,
|
|
56
|
+
end: xyValue,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.handleDragLineComplete = (e, moreProps) => {
|
|
62
|
+
const { override } = this.state;
|
|
63
|
+
const { channels } = this.props;
|
|
64
|
+
if (isDefined(override)) {
|
|
65
|
+
const newChannels = channels.map((each, idx) => idx === override.index
|
|
66
|
+
? Object.assign(Object.assign({}, each), { start: [override.x1Value, override.y1Value], end: [override.x2Value, override.y2Value], selected: true }) : each);
|
|
67
|
+
this.setState({
|
|
68
|
+
override: null,
|
|
69
|
+
}, () => {
|
|
70
|
+
const { onComplete } = this.props;
|
|
71
|
+
if (onComplete !== undefined) {
|
|
72
|
+
onComplete(e, newChannels, moreProps);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
this.handleDragLine = (e, index, newXYValue) => {
|
|
78
|
+
this.setState({
|
|
79
|
+
override: Object.assign({ index }, newXYValue),
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
this.terminate = terminate.bind(this);
|
|
83
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
84
|
+
this.getSelectionState = isHoverForInteractiveType("channels").bind(this);
|
|
85
|
+
this.state = {};
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
const { appearance, channels, currentPositionOpacity, currentPositionRadius = StandardDeviationChannel.defaultProps.currentPositionRadius, currentPositionStroke, currentPositionStrokeWidth, enabled, hoverText, snapTo, } = this.props;
|
|
89
|
+
const { current, override } = this.state;
|
|
90
|
+
const eachDefaultAppearance = Object.assign(Object.assign({}, StandardDeviationChannel.defaultProps.appearance), appearance);
|
|
91
|
+
const hoverTextDefault = Object.assign(Object.assign({}, StandardDeviationChannel.defaultProps.hoverText), hoverText);
|
|
92
|
+
const tempLine = isDefined(current) && isDefined(current.end) ? (React.createElement(EachLinearRegressionChannel, { interactive: false, x1Value: current.start[0], x2Value: current.end[0], appearance: eachDefaultAppearance, hoverText: hoverTextDefault })) : null;
|
|
93
|
+
return (React.createElement("g", null,
|
|
94
|
+
channels.map((each, idx) => {
|
|
95
|
+
const eachAppearance = isDefined(each.appearance)
|
|
96
|
+
? Object.assign(Object.assign({}, eachDefaultAppearance), each.appearance) : eachDefaultAppearance;
|
|
97
|
+
const eachHoverText = isDefined(each.hoverText)
|
|
98
|
+
? Object.assign(Object.assign({}, hoverTextDefault), each.hoverText) : hoverTextDefault;
|
|
99
|
+
return (React.createElement(EachLinearRegressionChannel, { key: idx, ref: this.saveNodeType(idx), index: idx, selected: each.selected, x1Value: getValueFromOverride(override, idx, "x1Value", each.start[0]), x2Value: getValueFromOverride(override, idx, "x2Value", each.end[0]), appearance: eachAppearance, snapTo: snapTo, hoverText: eachHoverText, onDrag: this.handleDragLine, onDragComplete: this.handleDragLineComplete, edgeInteractiveCursor: "react-financial-charts-move-cursor" }));
|
|
100
|
+
}),
|
|
101
|
+
tempLine,
|
|
102
|
+
React.createElement(MouseLocationIndicator, { enabled: enabled, snap: true, snapTo: snapTo, r: currentPositionRadius, stroke: currentPositionStroke, opacity: currentPositionOpacity, strokeWidth: currentPositionStrokeWidth, onMouseDown: this.handleStart, onClick: this.handleEnd, onMouseMove: this.handleDrawLine })));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
StandardDeviationChannel.defaultProps = {
|
|
106
|
+
snapTo: (d) => d.close,
|
|
107
|
+
appearance: {
|
|
108
|
+
stroke: "#000000",
|
|
109
|
+
fillOpacity: 0.2,
|
|
110
|
+
strokeOpacity: 1,
|
|
111
|
+
strokeWidth: 1,
|
|
112
|
+
fill: "#8AAFE2",
|
|
113
|
+
edgeStrokeWidth: 2,
|
|
114
|
+
edgeStroke: "#000000",
|
|
115
|
+
edgeFill: "#FFFFFF",
|
|
116
|
+
r: 5,
|
|
117
|
+
},
|
|
118
|
+
currentPositionStroke: "#000000",
|
|
119
|
+
currentPositionOpacity: 1,
|
|
120
|
+
currentPositionStrokeWidth: 3,
|
|
121
|
+
currentPositionRadius: 4,
|
|
122
|
+
hoverText: Object.assign(Object.assign({}, HoverTextNearMouse.defaultProps), { enable: true, bgHeight: "auto", bgWidth: "auto", text: "Click and drag the edge circles", selectedText: "" }),
|
|
123
|
+
channels: [],
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=StandardDeviationChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StandardDeviationChannel.js","sourceRoot":"","sources":["../src/StandardDeviationChannel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAgCxD,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAGnD;IAqCG,YAAmB,KAAoC;QACnD,KAAK,CAAC,KAAK,CAAC,CAAC;QAyFT,cAAS,GAAG,CAAC,CAAmB,EAAE,OAAY,EAAE,SAAc,EAAE,EAAE;YACtE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAC/B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAE5C,IAAI,IAAI,CAAC,UAAU,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,SAAS,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AE,IAAI,CAAC,WAAW,EAC7B,OAAO,EAAE,IAAI,CAAC,SAAS,EACvB,WAAW,EAAE,IAAI,CAAC,cAAc,GAClC,CACF,CACP,CAAC;IACN,CAAC;;AA5Ha,qCAAY,GAAG;IACzB,MAAM,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK;IAC3B,UAAU,EAAE;QACR,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE,GAAG;QAChB,aAAa,EAAE,CAAC;QAChB,WAAW,EAAE,CAAC;QACd,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,CAAC;QAClB,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,SAAS;QACnB,CAAC,EAAE,CAAC;KACP;IACD,qBAAqB,EAAE,SAAS;IAChC,sBAAsB,EAAE,CAAC;IACzB,0BAA0B,EAAE,CAAC;IAC7B,qBAAqB,EAAE,CAAC;IACxB,SAAS,kCACF,kBAAkB,CAAC,YAAY,KAClC,MAAM,EAAE,IAAI,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,iCAAiC,EACvC,YAAY,EAAE,EAAE,GACnB;IACD,QAAQ,EAAE,EAAE;CACf,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { strokeDashTypes } from "@tradingaction/core";
|
|
3
|
+
export interface TrendLineProps {
|
|
4
|
+
readonly snap: boolean;
|
|
5
|
+
readonly enabled: boolean;
|
|
6
|
+
readonly snapTo?: (datum: any) => number | number[];
|
|
7
|
+
readonly shouldDisableSnap?: (e: React.MouseEvent) => boolean;
|
|
8
|
+
readonly onStart: (e: React.MouseEvent, moreProps: any) => void;
|
|
9
|
+
readonly onComplete?: (e: React.MouseEvent, newTrends: any[], moreProps: any) => void;
|
|
10
|
+
readonly onSelect?: (e: React.MouseEvent, interactives: any[], moreProps: any) => void;
|
|
11
|
+
readonly onDoubleClickWhenHover?: (e: React.MouseEvent, moreProps: any, index: any) => void;
|
|
12
|
+
readonly onClickWhenHover?: (e: React.MouseEvent, moreProps: any, index: any) => void;
|
|
13
|
+
readonly onClickOutside?: (e: React.MouseEvent, moreProps: any, index: any) => void;
|
|
14
|
+
readonly onContextMenuWhenHover?: (e: React.MouseEvent, moreProps: any, index: any) => void;
|
|
15
|
+
readonly currentPositionStroke?: string;
|
|
16
|
+
readonly currentPositionStrokeWidth?: number;
|
|
17
|
+
readonly currentPositionstrokeOpacity?: number;
|
|
18
|
+
readonly currentPositionRadius?: number;
|
|
19
|
+
readonly type: "XLINE" | "RAY" | "LINE";
|
|
20
|
+
readonly hoverText: object;
|
|
21
|
+
readonly trends: any[];
|
|
22
|
+
readonly appearance: {
|
|
23
|
+
readonly strokeStyle: string;
|
|
24
|
+
readonly strokeWidth: number;
|
|
25
|
+
readonly strokeDasharray: strokeDashTypes;
|
|
26
|
+
readonly edgeStrokeWidth: number;
|
|
27
|
+
readonly edgeFill: string;
|
|
28
|
+
readonly edgeStroke: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface TrendLineState {
|
|
32
|
+
current?: any;
|
|
33
|
+
override?: any;
|
|
34
|
+
trends?: any;
|
|
35
|
+
}
|
|
36
|
+
export declare class TrendLine extends React.Component<TrendLineProps, TrendLineState> {
|
|
37
|
+
static defaultProps: {
|
|
38
|
+
type: string;
|
|
39
|
+
onStart: () => void;
|
|
40
|
+
onSelect: () => void;
|
|
41
|
+
onDoubleClickWhenHover: () => void;
|
|
42
|
+
onClickWhenHover: () => void;
|
|
43
|
+
onClickOutside: () => void;
|
|
44
|
+
currentPositionStroke: string;
|
|
45
|
+
currentPositionstrokeOpacity: number;
|
|
46
|
+
currentPositionStrokeWidth: number;
|
|
47
|
+
currentPositionRadius: number;
|
|
48
|
+
shouldDisableSnap: (e: React.MouseEvent) => boolean;
|
|
49
|
+
hoverText: {
|
|
50
|
+
enable: boolean;
|
|
51
|
+
bgHeight: string;
|
|
52
|
+
bgWidth: string;
|
|
53
|
+
text: string;
|
|
54
|
+
selectedText: string;
|
|
55
|
+
fontFamily: string;
|
|
56
|
+
fontSize: number;
|
|
57
|
+
fill: string;
|
|
58
|
+
bgFill: string;
|
|
59
|
+
bgOpacity: number;
|
|
60
|
+
};
|
|
61
|
+
trends: never[];
|
|
62
|
+
appearance: {
|
|
63
|
+
strokeStyle: string;
|
|
64
|
+
strokeWidth: number;
|
|
65
|
+
strokeDasharray: string;
|
|
66
|
+
edgeStrokeWidth: number;
|
|
67
|
+
edgeFill: string;
|
|
68
|
+
edgeStroke: string;
|
|
69
|
+
r: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
private getSelectionState;
|
|
73
|
+
private mouseMoved;
|
|
74
|
+
private saveNodeType;
|
|
75
|
+
private terminate;
|
|
76
|
+
constructor(props: TrendLineProps);
|
|
77
|
+
render(): JSX.Element;
|
|
78
|
+
private readonly handleEnd;
|
|
79
|
+
private readonly handleStart;
|
|
80
|
+
private readonly handleDrawLine;
|
|
81
|
+
private readonly handleDragLineComplete;
|
|
82
|
+
private readonly handleDragLine;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
package/lib/TrendLine.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isDefined, isNotDefined, noop } from "@tradingaction/core";
|
|
3
|
+
import { getValueFromOverride, isHoverForInteractiveType, saveNodeType, terminate } from "./utils";
|
|
4
|
+
import { HoverTextNearMouse, MouseLocationIndicator, InteractiveStraightLine } from "./components";
|
|
5
|
+
import { EachTrendLine } from "./wrapper";
|
|
6
|
+
export class TrendLine extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.handleEnd = (e, xyValue, moreProps) => {
|
|
10
|
+
const { current } = this.state;
|
|
11
|
+
const { trends, appearance, type } = this.props;
|
|
12
|
+
if (this.mouseMoved && isDefined(current) && isDefined(current.start)) {
|
|
13
|
+
const newTrends = [
|
|
14
|
+
...trends.map((d) => (Object.assign(Object.assign({}, d), { selected: false }))),
|
|
15
|
+
{
|
|
16
|
+
start: current.start,
|
|
17
|
+
end: xyValue,
|
|
18
|
+
selected: true,
|
|
19
|
+
appearance,
|
|
20
|
+
type,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
this.setState({
|
|
24
|
+
current: null,
|
|
25
|
+
trends: newTrends,
|
|
26
|
+
}, () => {
|
|
27
|
+
const { onComplete } = this.props;
|
|
28
|
+
if (onComplete !== undefined) {
|
|
29
|
+
onComplete(e, newTrends, moreProps);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.handleStart = (e, xyValue, moreProps) => {
|
|
35
|
+
const { current } = this.state;
|
|
36
|
+
if (isNotDefined(current) || isNotDefined(current.start)) {
|
|
37
|
+
this.mouseMoved = false;
|
|
38
|
+
this.setState({
|
|
39
|
+
current: {
|
|
40
|
+
start: xyValue,
|
|
41
|
+
end: null,
|
|
42
|
+
},
|
|
43
|
+
}, () => {
|
|
44
|
+
const { onStart } = this.props;
|
|
45
|
+
if (onStart !== undefined) {
|
|
46
|
+
onStart(e, moreProps);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
this.handleDrawLine = (_, xyValue) => {
|
|
52
|
+
const { current } = this.state;
|
|
53
|
+
if (isDefined(current) && isDefined(current.start)) {
|
|
54
|
+
this.mouseMoved = true;
|
|
55
|
+
this.setState({
|
|
56
|
+
current: {
|
|
57
|
+
start: current.start,
|
|
58
|
+
end: xyValue,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.handleDragLineComplete = (e, moreProps) => {
|
|
64
|
+
const { override } = this.state;
|
|
65
|
+
if (isDefined(override)) {
|
|
66
|
+
const { trends } = this.props;
|
|
67
|
+
const newTrends = trends.map((each, idx) => idx === override.index
|
|
68
|
+
? Object.assign(Object.assign({}, each), { start: [override.x1Value, override.y1Value], end: [override.x2Value, override.y2Value], selected: true }) : Object.assign(Object.assign({}, each), { selected: false }));
|
|
69
|
+
this.setState({
|
|
70
|
+
override: null,
|
|
71
|
+
}, () => {
|
|
72
|
+
const { onComplete } = this.props;
|
|
73
|
+
if (onComplete !== undefined) {
|
|
74
|
+
onComplete(e, newTrends, moreProps);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
this.handleDragLine = (_, index, newXYValue) => {
|
|
80
|
+
this.setState({
|
|
81
|
+
override: Object.assign({ index }, newXYValue),
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
this.terminate = terminate.bind(this);
|
|
85
|
+
this.saveNodeType = saveNodeType.bind(this);
|
|
86
|
+
this.getSelectionState = isHoverForInteractiveType("trends").bind(this);
|
|
87
|
+
this.state = {};
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
const { appearance, currentPositionstrokeOpacity, currentPositionRadius = TrendLine.defaultProps.currentPositionRadius, currentPositionStroke, currentPositionStrokeWidth, enabled, hoverText, shouldDisableSnap, snap, snapTo, trends, type, } = this.props;
|
|
91
|
+
const { current, override } = this.state;
|
|
92
|
+
const tempLine = isDefined(current) && isDefined(current.end) ? (React.createElement(InteractiveStraightLine, { type: type, x1Value: current.start[0], y1Value: current.start[1], x2Value: current.end[0], y2Value: current.end[1], strokeStyle: appearance.strokeStyle, strokeWidth: appearance.strokeWidth })) : null;
|
|
93
|
+
return (React.createElement("g", null,
|
|
94
|
+
trends.map((each, idx) => {
|
|
95
|
+
const eachAppearance = isDefined(each.appearance)
|
|
96
|
+
? Object.assign(Object.assign({}, appearance), each.appearance) : appearance;
|
|
97
|
+
const hoverTextWithDefault = Object.assign(Object.assign({}, TrendLine.defaultProps.hoverText), hoverText);
|
|
98
|
+
return (React.createElement(EachTrendLine, { key: idx, ref: this.saveNodeType(idx), index: idx, type: each.type, selected: each.selected, x1Value: getValueFromOverride(override, idx, "x1Value", each.start[0]), y1Value: getValueFromOverride(override, idx, "y1Value", each.start[1]), x2Value: getValueFromOverride(override, idx, "x2Value", each.end[0]), y2Value: getValueFromOverride(override, idx, "y2Value", each.end[1]), strokeStyle: eachAppearance.strokeStyle, strokeWidth: eachAppearance.strokeWidth, strokeOpacity: eachAppearance.strokeOpacity, strokeDasharray: eachAppearance.strokeDasharray, edgeStroke: eachAppearance.edgeStroke, edgeFill: eachAppearance.edgeFill, edgeStrokeWidth: eachAppearance.edgeStrokeWidth, r: eachAppearance.r, hoverText: hoverTextWithDefault, onDrag: this.handleDragLine, onDragComplete: this.handleDragLineComplete, edgeInteractiveCursor: "react-financial-charts-move-cursor", lineInteractiveCursor: "react-financial-charts-move-cursor", onDoubleClickWhenHover: this.props.onDoubleClickWhenHover, onClickWhenHover: this.props.onClickWhenHover, onClickOutside: this.props.onClickOutside, onContextMenuWhenHover: this.props.onContextMenuWhenHover }));
|
|
99
|
+
}),
|
|
100
|
+
tempLine,
|
|
101
|
+
React.createElement(MouseLocationIndicator, { enabled: enabled, snap: snap, shouldDisableSnap: shouldDisableSnap, snapTo: snapTo, r: currentPositionRadius, stroke: currentPositionStroke, opacity: currentPositionstrokeOpacity, strokeWidth: currentPositionStrokeWidth, onMouseDown: this.handleStart, onClick: this.handleEnd, onMouseMove: this.handleDrawLine })));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
TrendLine.defaultProps = {
|
|
105
|
+
type: "XLINE",
|
|
106
|
+
onStart: noop,
|
|
107
|
+
onSelect: noop,
|
|
108
|
+
onDoubleClickWhenHover: noop,
|
|
109
|
+
onClickWhenHover: noop,
|
|
110
|
+
onClickOutside: noop,
|
|
111
|
+
currentPositionStroke: "#000000",
|
|
112
|
+
currentPositionstrokeOpacity: 1,
|
|
113
|
+
currentPositionStrokeWidth: 3,
|
|
114
|
+
currentPositionRadius: 0,
|
|
115
|
+
shouldDisableSnap: (e) => e.button === 2 || e.shiftKey,
|
|
116
|
+
hoverText: Object.assign(Object.assign({}, HoverTextNearMouse.defaultProps), { enable: true, bgHeight: "auto", bgWidth: "auto", text: "Click to select object", selectedText: "" }),
|
|
117
|
+
trends: [],
|
|
118
|
+
appearance: {
|
|
119
|
+
strokeStyle: "#000000",
|
|
120
|
+
strokeWidth: 1,
|
|
121
|
+
strokeDasharray: "Solid",
|
|
122
|
+
edgeStrokeWidth: 1,
|
|
123
|
+
edgeFill: "#FFFFFF",
|
|
124
|
+
edgeStroke: "#000000",
|
|
125
|
+
r: 6,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=TrendLine.js.map
|