@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,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
3
|
+
export class InteractiveText extends React.Component {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.calculateTextWidth = true;
|
|
7
|
+
this.isHover = (moreProps) => {
|
|
8
|
+
const { onHover } = this.props;
|
|
9
|
+
if (onHover !== undefined && this.textWidth !== undefined && !this.calculateTextWidth) {
|
|
10
|
+
const { rect } = this.helper(moreProps, this.textWidth);
|
|
11
|
+
const { mouseXY: [x, y], } = moreProps;
|
|
12
|
+
if (x >= rect.x && y >= rect.y && x <= rect.x + rect.width && y <= rect.y + rect.height) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
18
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const { bgFillStyle, bgStrokeWidth, bgStroke, textFill, fontFamily, fontSize, fontStyle, fontWeight, text } = this.props;
|
|
21
|
+
if (this.calculateTextWidth) {
|
|
22
|
+
ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
23
|
+
const { width } = ctx.measureText(text);
|
|
24
|
+
this.textWidth = width;
|
|
25
|
+
this.calculateTextWidth = false;
|
|
26
|
+
}
|
|
27
|
+
const { selected } = this.props;
|
|
28
|
+
const { x, y, rect } = this.helper(moreProps, (_a = this.textWidth) !== null && _a !== void 0 ? _a : 0);
|
|
29
|
+
ctx.fillStyle = bgFillStyle;
|
|
30
|
+
ctx.beginPath();
|
|
31
|
+
ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
|
|
32
|
+
if (selected) {
|
|
33
|
+
ctx.strokeStyle = bgStroke;
|
|
34
|
+
ctx.lineWidth = bgStrokeWidth;
|
|
35
|
+
ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);
|
|
36
|
+
}
|
|
37
|
+
ctx.fillStyle = textFill;
|
|
38
|
+
ctx.textBaseline = "middle";
|
|
39
|
+
ctx.textAlign = "center";
|
|
40
|
+
ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
41
|
+
ctx.beginPath();
|
|
42
|
+
ctx.fillText(text, x, y);
|
|
43
|
+
};
|
|
44
|
+
this.helper = (moreProps, textWidth) => {
|
|
45
|
+
const { position, fontSize } = this.props;
|
|
46
|
+
const { xScale, chartConfig: { yScale }, } = moreProps;
|
|
47
|
+
const [xValue, yValue] = position;
|
|
48
|
+
const x = xScale(xValue);
|
|
49
|
+
const y = yScale(yValue);
|
|
50
|
+
const rect = {
|
|
51
|
+
x: x - textWidth / 2 - fontSize,
|
|
52
|
+
y: y - fontSize,
|
|
53
|
+
width: textWidth + fontSize * 2,
|
|
54
|
+
height: fontSize * 2,
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
x,
|
|
58
|
+
y,
|
|
59
|
+
rect,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
componentDidUpdate(previousProps) {
|
|
64
|
+
this.calculateTextWidth =
|
|
65
|
+
previousProps.text !== this.props.text ||
|
|
66
|
+
previousProps.fontStyle !== this.props.fontStyle ||
|
|
67
|
+
previousProps.fontWeight !== this.props.fontWeight ||
|
|
68
|
+
previousProps.fontSize !== this.props.fontSize ||
|
|
69
|
+
previousProps.fontFamily !== this.props.fontFamily;
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
const { selected, interactiveCursorClass } = this.props;
|
|
73
|
+
const { onHover, onUnHover } = this.props;
|
|
74
|
+
const { onDragStart, onDrag, onDragComplete, onDoubleClick } = this.props;
|
|
75
|
+
return (React.createElement(GenericChartComponent, { isHover: this.isHover, canvasToDraw: getMouseCanvas, canvasDraw: this.drawOnCanvas, interactiveCursorClass: interactiveCursorClass, selected: selected, onDragStart: onDragStart, onDrag: onDrag, onDragComplete: onDragComplete, onDoubleClickWhenHover: onDoubleClick, onHover: onHover, onUnHover: onUnHover, drawOn: ["mousemove", "mouseleave", "pan", "drag"] }));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
InteractiveText.defaultProps = {
|
|
79
|
+
type: "SD",
|
|
80
|
+
fontWeight: "normal",
|
|
81
|
+
tolerance: 4,
|
|
82
|
+
selected: false,
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=InteractiveText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractiveText.js","sourceRoot":"","sources":["../../src/components/InteractiveText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAyB5E,MAAM,OAAO,eAAgB,SAAQ,KAAK,CAAC,SAA+B;IAA1E;;QAQY,uBAAkB,GAAG,IAAI,CAAC;QAmCjB,YAAO,GAAG,CAAC,SAAc,EAAE,EAAE;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAE/B,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBACnF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CA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ACN,CAAC;;AAxCa,4BAAY,GAAG;IACzB,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,KAAK;CAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { strokeDashTypes } from "@tradingaction/core";
|
|
3
|
+
export interface InteractiveYCoordinateProps {
|
|
4
|
+
readonly bgFillStyle: string;
|
|
5
|
+
readonly strokeStyle: string;
|
|
6
|
+
readonly strokeWidth: number;
|
|
7
|
+
readonly strokeDasharray: strokeDashTypes;
|
|
8
|
+
readonly textFill: string;
|
|
9
|
+
readonly fontFamily: string;
|
|
10
|
+
readonly fontSize: number;
|
|
11
|
+
readonly fontWeight: number | string;
|
|
12
|
+
readonly fontStyle: string;
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly edge: object;
|
|
15
|
+
readonly textBox: {
|
|
16
|
+
readonly closeIcon: any;
|
|
17
|
+
readonly left: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
readonly padding: any;
|
|
20
|
+
};
|
|
21
|
+
readonly yValue: number;
|
|
22
|
+
readonly onDragStart?: (e: React.MouseEvent, moreProps: any) => void;
|
|
23
|
+
readonly onDrag?: (e: React.MouseEvent, moreProps: any) => void;
|
|
24
|
+
readonly onDragComplete?: (e: React.MouseEvent, moreProps: any) => void;
|
|
25
|
+
readonly onHover?: (e: React.MouseEvent, moreProps: any) => void;
|
|
26
|
+
readonly onUnHover?: (e: React.MouseEvent, moreProps: any) => void;
|
|
27
|
+
readonly defaultClassName?: string;
|
|
28
|
+
readonly interactiveCursorClass?: string;
|
|
29
|
+
readonly tolerance: number;
|
|
30
|
+
readonly selected: boolean;
|
|
31
|
+
readonly hovering: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare class InteractiveYCoordinate extends React.Component<InteractiveYCoordinateProps> {
|
|
34
|
+
static defaultProps: {
|
|
35
|
+
fontWeight: string;
|
|
36
|
+
strokeWidth: number;
|
|
37
|
+
tolerance: number;
|
|
38
|
+
selected: boolean;
|
|
39
|
+
hovering: boolean;
|
|
40
|
+
};
|
|
41
|
+
private width;
|
|
42
|
+
render(): JSX.Element;
|
|
43
|
+
private readonly drawOnCanvas;
|
|
44
|
+
private readonly isHover;
|
|
45
|
+
private readonly helper;
|
|
46
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { drawOnCanvas } from "@tradingaction/coordinates/lib/EdgeCoordinateV3";
|
|
3
|
+
import { getYCoordinate } from "@tradingaction/coordinates/lib/MouseCoordinateY";
|
|
4
|
+
import { getStrokeDasharrayCanvas, getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
5
|
+
export class InteractiveYCoordinate extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.width = 0;
|
|
9
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
10
|
+
const { bgFillStyle, textFill, fontFamily, fontSize, fontStyle, fontWeight, strokeStyle, strokeWidth, strokeDasharray, text, textBox, edge, selected, hovering, } = this.props;
|
|
11
|
+
const values = this.helper(moreProps);
|
|
12
|
+
if (values == null) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { x1, x2, y, rect } = values;
|
|
16
|
+
ctx.strokeStyle = strokeStyle;
|
|
17
|
+
ctx.beginPath();
|
|
18
|
+
if (selected || hovering) {
|
|
19
|
+
ctx.lineWidth = strokeWidth + 1;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
ctx.lineWidth = strokeWidth;
|
|
23
|
+
}
|
|
24
|
+
ctx.textBaseline = "middle";
|
|
25
|
+
ctx.textAlign = "start";
|
|
26
|
+
ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
27
|
+
this.width =
|
|
28
|
+
textBox.padding.left +
|
|
29
|
+
ctx.measureText(text).width +
|
|
30
|
+
textBox.padding.right +
|
|
31
|
+
textBox.closeIcon.padding.left +
|
|
32
|
+
textBox.closeIcon.width +
|
|
33
|
+
textBox.closeIcon.padding.right;
|
|
34
|
+
ctx.setLineDash(getStrokeDasharrayCanvas(strokeDasharray));
|
|
35
|
+
ctx.moveTo(x1, y);
|
|
36
|
+
ctx.lineTo(rect.x, y);
|
|
37
|
+
ctx.moveTo(rect.x + this.width, y);
|
|
38
|
+
ctx.lineTo(x2, y);
|
|
39
|
+
ctx.stroke();
|
|
40
|
+
ctx.setLineDash([]);
|
|
41
|
+
ctx.fillStyle = bgFillStyle;
|
|
42
|
+
ctx.fillRect(rect.x, rect.y, this.width, rect.height);
|
|
43
|
+
ctx.strokeRect(rect.x, rect.y, this.width, rect.height);
|
|
44
|
+
ctx.fillStyle = textFill;
|
|
45
|
+
ctx.beginPath();
|
|
46
|
+
ctx.fillText(text, rect.x + 10, y);
|
|
47
|
+
const newEdge = Object.assign(Object.assign({}, edge), { textFill,
|
|
48
|
+
fontFamily,
|
|
49
|
+
fontSize });
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
const yValue = edge.displayFormat(this.props.yValue);
|
|
52
|
+
const yCoord = getYCoordinate(y, yValue, newEdge, moreProps);
|
|
53
|
+
drawOnCanvas(ctx, yCoord);
|
|
54
|
+
};
|
|
55
|
+
this.isHover = (moreProps) => {
|
|
56
|
+
const { onHover } = this.props;
|
|
57
|
+
if (onHover !== undefined) {
|
|
58
|
+
const values = this.helper(moreProps);
|
|
59
|
+
if (values == null) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const { x1, x2, y, rect } = values;
|
|
63
|
+
const { mouseXY: [mouseX, mouseY], } = moreProps;
|
|
64
|
+
if (mouseX >= rect.x &&
|
|
65
|
+
mouseX <= rect.x + this.width &&
|
|
66
|
+
mouseY >= rect.y &&
|
|
67
|
+
mouseY <= rect.y + rect.height) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (x1 <= mouseX && x2 >= mouseX && Math.abs(mouseY - y) < 4) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
this.helper = (moreProps) => {
|
|
77
|
+
const { yValue, textBox } = this.props;
|
|
78
|
+
const { chartConfig: { width, yScale, height }, } = moreProps;
|
|
79
|
+
const y = Math.round(yScale(yValue));
|
|
80
|
+
if (y >= 0 && y <= height) {
|
|
81
|
+
const rect = {
|
|
82
|
+
x: textBox.left,
|
|
83
|
+
y: y - textBox.height / 2,
|
|
84
|
+
height: textBox.height,
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
x1: 0,
|
|
88
|
+
x2: width,
|
|
89
|
+
y,
|
|
90
|
+
rect,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
const { interactiveCursorClass } = this.props;
|
|
97
|
+
const { onHover, onUnHover } = this.props;
|
|
98
|
+
const { onDragStart, onDrag, onDragComplete } = this.props;
|
|
99
|
+
return (React.createElement(GenericChartComponent, { clip: false, isHover: this.isHover, canvasToDraw: getMouseCanvas, canvasDraw: this.drawOnCanvas, interactiveCursorClass: interactiveCursorClass, enableDragOnHover: true, onDragStart: onDragStart, onDrag: onDrag, onDragComplete: onDragComplete, onHover: onHover, onUnHover: onUnHover, drawOn: ["mousemove", "mouseleave", "pan", "drag"] }));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
InteractiveYCoordinate.defaultProps = {
|
|
103
|
+
fontWeight: "normal",
|
|
104
|
+
strokeWidth: 1,
|
|
105
|
+
tolerance: 4,
|
|
106
|
+
selected: false,
|
|
107
|
+
hovering: false,
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=InteractiveYCoordinate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractiveYCoordinate.js","sourceRoot":"","sources":["../../src/components/InteractiveYCoord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AE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,GACpD,CACL,CAAC;IACN,CAAC;;AA/Ba,mCAAY,GAAG;IACzB,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,CAAC;IACZ,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,KAAK;CAClB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface LinearRegressionChannelWithAreaProps {
|
|
3
|
+
readonly x1Value: any;
|
|
4
|
+
readonly x2Value: any;
|
|
5
|
+
readonly type: "SD" | "Raff";
|
|
6
|
+
readonly interactiveCursorClass?: string;
|
|
7
|
+
readonly strokeStyle: string;
|
|
8
|
+
readonly strokeWidth: number;
|
|
9
|
+
readonly fillStyle: string;
|
|
10
|
+
readonly onDragStart?: (e: React.MouseEvent, moreProps: any) => void;
|
|
11
|
+
readonly onDrag?: (e: React.MouseEvent, moreProps: any) => void;
|
|
12
|
+
readonly onDragComplete?: (e: React.MouseEvent, moreProps: any) => void;
|
|
13
|
+
readonly onHover?: (e: React.MouseEvent, moreProps: any) => void;
|
|
14
|
+
readonly onUnHover?: (e: React.MouseEvent, moreProps: any) => void;
|
|
15
|
+
readonly defaultClassName?: string;
|
|
16
|
+
readonly tolerance: number;
|
|
17
|
+
readonly selected: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class LinearRegressionChannelWithArea extends React.Component<LinearRegressionChannelWithAreaProps> {
|
|
20
|
+
static defaultProps: {
|
|
21
|
+
type: string;
|
|
22
|
+
strokeWidth: number;
|
|
23
|
+
tolerance: number;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
};
|
|
26
|
+
render(): JSX.Element;
|
|
27
|
+
private readonly drawOnCanvas;
|
|
28
|
+
private readonly isHover;
|
|
29
|
+
}
|
|
30
|
+
export declare function edge1Provider(props: any): (moreProps: any) => any[];
|
|
31
|
+
export declare function edge2Provider(props: any): (moreProps: any) => any[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { deviation, sum, zip } from "d3-array";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getClosestItemIndexes, getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
4
|
+
import { isHovering2 } from "./InteractiveStraightLine";
|
|
5
|
+
export class LinearRegressionChannelWithArea extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
9
|
+
const { strokeStyle, strokeWidth, fillStyle } = this.props;
|
|
10
|
+
const { x1, y1, x2, y2, dy } = helper(this.props, moreProps);
|
|
11
|
+
ctx.lineWidth = strokeWidth;
|
|
12
|
+
ctx.strokeStyle = strokeStyle;
|
|
13
|
+
ctx.fillStyle = fillStyle;
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.moveTo(x1, y1 - dy);
|
|
16
|
+
ctx.lineTo(x2, y2 - dy);
|
|
17
|
+
ctx.stroke();
|
|
18
|
+
ctx.beginPath();
|
|
19
|
+
ctx.moveTo(x2, y2 + dy);
|
|
20
|
+
ctx.lineTo(x1, y1 + dy);
|
|
21
|
+
ctx.stroke();
|
|
22
|
+
ctx.beginPath();
|
|
23
|
+
ctx.moveTo(x1, y1 - dy);
|
|
24
|
+
ctx.lineTo(x2, y2 - dy);
|
|
25
|
+
ctx.lineTo(x2, y2 + dy);
|
|
26
|
+
ctx.lineTo(x1, y1 + dy);
|
|
27
|
+
ctx.closePath();
|
|
28
|
+
ctx.fill();
|
|
29
|
+
ctx.beginPath();
|
|
30
|
+
ctx.moveTo(x2, y2);
|
|
31
|
+
ctx.lineTo(x1, y1);
|
|
32
|
+
ctx.stroke();
|
|
33
|
+
};
|
|
34
|
+
this.isHover = (moreProps) => {
|
|
35
|
+
const { tolerance, onHover } = this.props;
|
|
36
|
+
if (onHover !== undefined) {
|
|
37
|
+
const { mouseXY } = moreProps;
|
|
38
|
+
const { x1, y1, x2, y2, dy } = helper(this.props, moreProps);
|
|
39
|
+
const yDiffs = [-dy, 0, dy];
|
|
40
|
+
const hovering = yDiffs.reduce((result, diff) => result || isHovering2([x1, y1 + diff], [x2, y2 + diff], mouseXY, tolerance), false);
|
|
41
|
+
return hovering;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
const { selected, interactiveCursorClass } = this.props;
|
|
48
|
+
const { onDragStart, onDrag, onDragComplete, onHover, onUnHover } = this.props;
|
|
49
|
+
return (React.createElement(GenericChartComponent, { isHover: this.isHover, canvasToDraw: getMouseCanvas, canvasDraw: this.drawOnCanvas, interactiveCursorClass: interactiveCursorClass, selected: selected, onDragStart: onDragStart, onDrag: onDrag, onDragComplete: onDragComplete, onHover: onHover, onUnHover: onUnHover, drawOn: ["mousemove", "mouseleave", "pan", "drag"] }));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
LinearRegressionChannelWithArea.defaultProps = {
|
|
53
|
+
type: "SD",
|
|
54
|
+
strokeWidth: 1,
|
|
55
|
+
tolerance: 4,
|
|
56
|
+
selected: false,
|
|
57
|
+
};
|
|
58
|
+
export function edge1Provider(props) {
|
|
59
|
+
return function (moreProps) {
|
|
60
|
+
const { x1, y1 } = helper(props, moreProps);
|
|
61
|
+
return [x1, y1];
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function edge2Provider(props) {
|
|
65
|
+
return function (moreProps) {
|
|
66
|
+
const { x2, y2 } = helper(props, moreProps);
|
|
67
|
+
return [x2, y2];
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function helper(props, moreProps) {
|
|
71
|
+
const { x1Value, x2Value, type } = props;
|
|
72
|
+
const { xScale, chartConfig: { yScale }, fullData, } = moreProps;
|
|
73
|
+
const { xAccessor } = moreProps;
|
|
74
|
+
const { left } = getClosestItemIndexes(fullData, x1Value, xAccessor);
|
|
75
|
+
const { right } = getClosestItemIndexes(fullData, x2Value, xAccessor);
|
|
76
|
+
const startIndex = Math.min(left, right);
|
|
77
|
+
const endIndex = Math.max(left, right) + 1;
|
|
78
|
+
const array = fullData.slice(startIndex, endIndex);
|
|
79
|
+
const xs = array.map((d) => xAccessor(d).valueOf());
|
|
80
|
+
const ys = array.map((d) => d.close);
|
|
81
|
+
const n = array.length;
|
|
82
|
+
const xys = zip(xs, ys).map((d) => {
|
|
83
|
+
return d[0] * d[1];
|
|
84
|
+
});
|
|
85
|
+
const xSquareds = xs.map((x) => Math.pow(x, 2));
|
|
86
|
+
const b = (n * sum(xys) - sum(xs) * sum(ys)) / (n * sum(xSquareds) - Math.pow(sum(xs), 2));
|
|
87
|
+
const a = (sum(ys) - b * sum(xs)) / n;
|
|
88
|
+
const newy1 = a + b * x1Value;
|
|
89
|
+
const newy2 = a + b * x2Value;
|
|
90
|
+
const x1 = xScale(x1Value);
|
|
91
|
+
const y1 = yScale(newy1);
|
|
92
|
+
const x2 = xScale(x2Value);
|
|
93
|
+
const y2 = yScale(newy2);
|
|
94
|
+
const stdDev = type === "SD" ? deviation(array, (d) => d.close) : 0;
|
|
95
|
+
const dy = yScale(newy1 - stdDev) - y1;
|
|
96
|
+
return {
|
|
97
|
+
x1,
|
|
98
|
+
y1,
|
|
99
|
+
x2,
|
|
100
|
+
y2,
|
|
101
|
+
dy,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=LinearRegressionChannelWithArea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearRegressionChannelWithArea.js","sourceRoot":"","sources":["../../src/components/LinearRegressionChannelWithArea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAA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GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3F,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IAEtC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IAC9B,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IAE9B,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzB,MAAM,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAM,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,GAAG,MAAO,CAAC,GAAG,EAAE,CAAC;IAExC,OAAO;QACH,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;KACL,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface MouseLocationIndicatorProps {
|
|
3
|
+
readonly enabled: boolean;
|
|
4
|
+
readonly snap: boolean;
|
|
5
|
+
readonly shouldDisableSnap: (e: React.MouseEvent) => boolean;
|
|
6
|
+
readonly snapTo?: (datum: any) => number | number[];
|
|
7
|
+
readonly onMouseMove: (e: React.MouseEvent, xyValue: number[], moreProps: any) => void;
|
|
8
|
+
readonly onMouseDown: (e: React.MouseEvent, xyValue: number[], moreProps: any) => void;
|
|
9
|
+
readonly onClick: (e: React.MouseEvent, xyValue: number[], moreProps: any) => void;
|
|
10
|
+
readonly r: number;
|
|
11
|
+
readonly stroke: string;
|
|
12
|
+
readonly strokeWidth: number;
|
|
13
|
+
readonly opacity: number;
|
|
14
|
+
readonly disablePan: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class MouseLocationIndicator extends React.Component<MouseLocationIndicatorProps> {
|
|
17
|
+
static defaultProps: {
|
|
18
|
+
onMouseMove: () => void;
|
|
19
|
+
onMouseDown: () => void;
|
|
20
|
+
onClick: () => void;
|
|
21
|
+
shouldDisableSnap: any;
|
|
22
|
+
stroke: string;
|
|
23
|
+
strokeWidth: number;
|
|
24
|
+
opacity: number;
|
|
25
|
+
disablePan: boolean;
|
|
26
|
+
};
|
|
27
|
+
private mutableState;
|
|
28
|
+
render(): JSX.Element;
|
|
29
|
+
private readonly xy;
|
|
30
|
+
private readonly handleClick;
|
|
31
|
+
private readonly handleMouseDown;
|
|
32
|
+
private readonly handleMousePosChange;
|
|
33
|
+
private readonly drawOnCanvas;
|
|
34
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { functor, getClosestValue, getMouseCanvas, GenericChartComponent, isDefined, noop, shallowEqual, } from "@tradingaction/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getXValue } from "@tradingaction/core/lib/utils/ChartDataUtil";
|
|
4
|
+
export class MouseLocationIndicator extends React.Component {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.mutableState = {};
|
|
8
|
+
this.xy = (e, moreProps) => {
|
|
9
|
+
const { xAccessor, plotData } = moreProps;
|
|
10
|
+
const { mouseXY, currentItem, xScale, chartConfig: { yScale }, } = moreProps;
|
|
11
|
+
const { enabled, snap, shouldDisableSnap, snapTo } = this.props;
|
|
12
|
+
if (enabled && isDefined(currentItem) && isDefined(e)) {
|
|
13
|
+
const xValue = snap && !shouldDisableSnap(e)
|
|
14
|
+
? xAccessor(currentItem)
|
|
15
|
+
: getXValue(xScale, xAccessor, mouseXY, plotData);
|
|
16
|
+
const yValue = snap && snapTo !== undefined && !shouldDisableSnap(e)
|
|
17
|
+
? getClosestValue(snapTo(currentItem), yScale.invert(mouseXY[1]))
|
|
18
|
+
: yScale.invert(mouseXY[1]);
|
|
19
|
+
const x = xScale(xValue);
|
|
20
|
+
const y = yScale(yValue);
|
|
21
|
+
return { xValue, yValue, x, y };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.handleClick = (e, moreProps) => {
|
|
25
|
+
const pos = this.xy(e, moreProps);
|
|
26
|
+
if (pos !== undefined && isDefined(pos)) {
|
|
27
|
+
const { xValue, yValue, x, y } = pos;
|
|
28
|
+
this.mutableState = { x, y };
|
|
29
|
+
this.props.onClick(e, [xValue, yValue], moreProps);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this.handleMouseDown = (e, moreProps) => {
|
|
33
|
+
const pos = this.xy(e, moreProps);
|
|
34
|
+
if (pos !== undefined && isDefined(pos)) {
|
|
35
|
+
const { xValue, yValue, x, y } = pos;
|
|
36
|
+
this.mutableState = { x, y };
|
|
37
|
+
this.props.onMouseDown(e, [xValue, yValue], moreProps);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.handleMousePosChange = (e, moreProps) => {
|
|
41
|
+
if (!shallowEqual(moreProps.mousXY, moreProps.prevMouseXY)) {
|
|
42
|
+
const pos = this.xy(e, moreProps);
|
|
43
|
+
if (pos !== undefined && isDefined(pos)) {
|
|
44
|
+
const { xValue, yValue, x, y } = pos;
|
|
45
|
+
this.mutableState = { x, y };
|
|
46
|
+
this.props.onMouseMove(e, [xValue, yValue], moreProps);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
51
|
+
const { enabled, r, stroke, strokeWidth } = this.props;
|
|
52
|
+
const { x, y } = this.mutableState;
|
|
53
|
+
const { show } = moreProps;
|
|
54
|
+
if (enabled && show && isDefined(x)) {
|
|
55
|
+
ctx.lineWidth = strokeWidth;
|
|
56
|
+
ctx.strokeStyle = stroke;
|
|
57
|
+
ctx.moveTo(x, y);
|
|
58
|
+
ctx.beginPath();
|
|
59
|
+
ctx.arc(x, y, r, 0, 2 * Math.PI, false);
|
|
60
|
+
ctx.stroke();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
const { enabled, disablePan } = this.props;
|
|
66
|
+
return (React.createElement(GenericChartComponent, { onMouseDown: this.handleMouseDown, onClick: this.handleClick, onMouseMove: this.handleMousePosChange, onPan: this.handleMousePosChange, disablePan: enabled && disablePan, canvasDraw: this.drawOnCanvas, canvasToDraw: getMouseCanvas, drawOn: ["mousemove", "pan"] }));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
MouseLocationIndicator.defaultProps = {
|
|
70
|
+
onMouseMove: noop,
|
|
71
|
+
onMouseDown: noop,
|
|
72
|
+
onClick: noop,
|
|
73
|
+
shouldDisableSnap: functor(false),
|
|
74
|
+
stroke: "#000000",
|
|
75
|
+
strokeWidth: 1,
|
|
76
|
+
opacity: 1,
|
|
77
|
+
disablePan: true,
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=MouseLocationIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MouseLocationIndicator.js","sourceRoot":"","sources":["../../src/components/MouseLocationIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,OAAO,EACP,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,IAAI,EACJ,YAAY,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,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e,EACjC,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,WAAW,EAAE,IAAI,CAAC,oBAAoB,EACtC,KAAK,EAAE,IAAI,CAAC,oBAAoB,EAChC,UAAU,EAAE,OAAO,IAAI,UAAU,EACjC,UAAU,EAAE,IAAI,CAAC,YAAY,EAC7B,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,GAC9B,CACL,CAAC;IACN,CAAC;;AA5Ba,mCAAY,GAAG;IACzB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,IAAI;IACb,iBAAiB,EAAE,OAAO,CAAC,KAAK,CAAC;IACjC,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,IAAI;CACnB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface TextProps {
|
|
3
|
+
readonly children: string;
|
|
4
|
+
readonly fontFamily: string;
|
|
5
|
+
readonly fontSize: number;
|
|
6
|
+
readonly fillStyle: string;
|
|
7
|
+
readonly selected?: boolean;
|
|
8
|
+
readonly xyProvider: (moreProps: any) => number[];
|
|
9
|
+
}
|
|
10
|
+
export declare class Text extends React.Component<TextProps> {
|
|
11
|
+
static defaultProps: {
|
|
12
|
+
selected: boolean;
|
|
13
|
+
};
|
|
14
|
+
render(): JSX.Element;
|
|
15
|
+
private readonly isHover;
|
|
16
|
+
private readonly drawOnCanvas;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
3
|
+
export class Text extends React.Component {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.isHover = () => {
|
|
7
|
+
return false;
|
|
8
|
+
};
|
|
9
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
10
|
+
const { xyProvider, fontFamily, fontSize, fillStyle, children } = this.props;
|
|
11
|
+
const [x, y] = xyProvider(moreProps);
|
|
12
|
+
ctx.font = `${fontSize}px ${fontFamily}`;
|
|
13
|
+
ctx.fillStyle = fillStyle;
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.fillText(children, x, y);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const { selected } = this.props;
|
|
20
|
+
return (React.createElement(GenericChartComponent, { isHover: this.isHover, selected: selected, canvasToDraw: getMouseCanvas, canvasDraw: this.drawOnCanvas, drawOn: ["mousemove", "pan", "drag"] }));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
Text.defaultProps = {
|
|
24
|
+
selected: false,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/components/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAW5E,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,SAAoB;IAApD;;QAmBqB,YAAO,GAAG,GAAG,EAAE;YAC5B,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC;QAEe,iBAAY,GAAG,CAAC,GAA6B,EAAE,SAAc,EAAE,EAAE;YAC9E,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAE7E,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YAErC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,MAAM,UAAU,EAAE,CAAC;YACzC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;YAE1B,GAAG,CAAC,SAAS,EAAE,CAAC;YAChB,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC;IACN,CAAC;IA7BU,MAAM;QACT,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEhC,OAAO,CACH,oBAAC,qBAAqB,IAClB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,cAAc,EAC5B,UAAU,EAAE,IAAI,CAAC,YAAY,EAC7B,MAAM,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,GACtC,CACL,CAAC;IACN,CAAC;;AAhBa,iBAAY,GAAG;IACzB,QAAQ,EAAE,KAAK;CAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./ChannelWithArea";
|
|
2
|
+
export * from "./ClickableCircle";
|
|
3
|
+
export * from "./ClickableShape";
|
|
4
|
+
export * from "./GannFan";
|
|
5
|
+
export * from "./HoverTextNearMouse";
|
|
6
|
+
export * from "./InteractiveStraightLine";
|
|
7
|
+
export * from "./InteractiveText";
|
|
8
|
+
export * from "./InteractiveYCoordinate";
|
|
9
|
+
export * from "./LinearRegressionChannelWithArea";
|
|
10
|
+
export * from "./MouseLocationIndicator";
|
|
11
|
+
export * from "./Text";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./ChannelWithArea";
|
|
2
|
+
export * from "./ClickableCircle";
|
|
3
|
+
export * from "./ClickableShape";
|
|
4
|
+
export * from "./GannFan";
|
|
5
|
+
export * from "./HoverTextNearMouse";
|
|
6
|
+
export * from "./InteractiveStraightLine";
|
|
7
|
+
export * from "./InteractiveText";
|
|
8
|
+
export * from "./InteractiveYCoordinate";
|
|
9
|
+
export * from "./LinearRegressionChannelWithArea";
|
|
10
|
+
export * from "./MouseLocationIndicator";
|
|
11
|
+
export * from "./Text";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC"}
|
package/lib/index.d.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/lib/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|