@tradingaction/coordinates 2.0.12 → 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 -24
- package/README.md +5 -5
- package/lib/CrossHairCursor.d.ts +22 -22
- package/lib/CrossHairCursor.js +75 -75
- package/lib/CurrentCoordinate.d.ts +31 -31
- package/lib/CurrentCoordinate.js +53 -53
- package/lib/Cursor.d.ts +31 -31
- package/lib/Cursor.js +121 -121
- package/lib/EdgeCoordinate.d.ts +32 -32
- package/lib/EdgeCoordinate.js +150 -150
- package/lib/EdgeCoordinateV2.d.ts +3 -3
- package/lib/EdgeCoordinateV2.js +137 -137
- package/lib/EdgeCoordinateV3.d.ts +3 -3
- package/lib/EdgeCoordinateV3.js +175 -175
- package/lib/EdgeIndicator.d.ts +55 -55
- package/lib/EdgeIndicator.js +84 -84
- package/lib/EdgeIndicator.js.map +1 -1
- package/lib/MouseCoordinateX.d.ts +49 -49
- package/lib/MouseCoordinateX.js +84 -84
- package/lib/MouseCoordinateXV2.d.ts +61 -61
- package/lib/MouseCoordinateXV2.js +91 -91
- package/lib/MouseCoordinateY.d.ts +68 -68
- package/lib/MouseCoordinateY.js +90 -90
- package/lib/PriceCoordinate.d.ts +53 -53
- package/lib/PriceCoordinate.js +80 -80
- package/lib/index.d.ts +8 -8
- package/lib/index.js +8 -8
- package/package.json +3 -3
- package/src/EdgeIndicator.tsx +1 -9
package/LICENSE
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
https://github.com/reactivemarkets/react-financial-charts
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2015-2018 Ragu Ramaswamy
|
|
5
|
-
Copyright (c) 2016 Julien Renaux
|
|
6
|
-
Copyright (c) 2019 Reactive Markets
|
|
7
|
-
|
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
in the Software without restriction, including without limitation the rights
|
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
furnished to do so, subject to the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be included in
|
|
16
|
-
all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
https://github.com/reactivemarkets/react-financial-charts
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2015-2018 Ragu Ramaswamy
|
|
5
|
+
Copyright (c) 2016 Julien Renaux
|
|
6
|
+
Copyright (c) 2019 Reactive Markets
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Coordinates
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
npm i @
|
|
5
|
-
```
|
|
1
|
+
# Coordinates
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npm i @tradingaction/coordinates
|
|
5
|
+
```
|
package/lib/CrossHairCursor.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { strokeDashTypes } from "@tradingaction/core";
|
|
3
|
-
export interface CrossHairCursorProps {
|
|
4
|
-
readonly customX?: (props: CrossHairCursorProps, moreProps: any) => number;
|
|
5
|
-
readonly snapX?: boolean;
|
|
6
|
-
readonly strokeStyle?: string;
|
|
7
|
-
readonly strokeDasharray?: strokeDashTypes;
|
|
8
|
-
readonly strokeWidth?: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class CrossHairCursor extends React.Component<CrossHairCursorProps> {
|
|
11
|
-
static defaultProps: {
|
|
12
|
-
customX: (props: CrossHairCursorProps, moreProps: any) => any;
|
|
13
|
-
snapX: boolean;
|
|
14
|
-
strokeStyle: string;
|
|
15
|
-
strokeDasharray: string;
|
|
16
|
-
strokeWidth: number;
|
|
17
|
-
};
|
|
18
|
-
static contextType: React.Context<import("@tradingaction/core/lib/ChartCanvas").ChartCanvasContextType<number | Date>>;
|
|
19
|
-
render(): JSX.Element;
|
|
20
|
-
private readonly drawOnCanvas;
|
|
21
|
-
private readonly getLines;
|
|
22
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { strokeDashTypes } from "@tradingaction/core";
|
|
3
|
+
export interface CrossHairCursorProps {
|
|
4
|
+
readonly customX?: (props: CrossHairCursorProps, moreProps: any) => number;
|
|
5
|
+
readonly snapX?: boolean;
|
|
6
|
+
readonly strokeStyle?: string;
|
|
7
|
+
readonly strokeDasharray?: strokeDashTypes;
|
|
8
|
+
readonly strokeWidth?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class CrossHairCursor extends React.Component<CrossHairCursorProps> {
|
|
11
|
+
static defaultProps: {
|
|
12
|
+
customX: (props: CrossHairCursorProps, moreProps: any) => any;
|
|
13
|
+
snapX: boolean;
|
|
14
|
+
strokeStyle: string;
|
|
15
|
+
strokeDasharray: string;
|
|
16
|
+
strokeWidth: number;
|
|
17
|
+
};
|
|
18
|
+
static contextType: React.Context<import("@tradingaction/core/lib/ChartCanvas").ChartCanvasContextType<number | Date>>;
|
|
19
|
+
render(): JSX.Element;
|
|
20
|
+
private readonly drawOnCanvas;
|
|
21
|
+
private readonly getLines;
|
|
22
|
+
}
|
package/lib/CrossHairCursor.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { getStrokeDasharrayCanvas, GenericComponent, getMouseCanvas, ChartCanvasContext, } from "@tradingaction/core";
|
|
3
|
-
const defaultCustomX = (props, moreProps) => {
|
|
4
|
-
const { xScale, xAccessor, currentItem, mouseXY } = moreProps;
|
|
5
|
-
const { snapX } = props;
|
|
6
|
-
const x = snapX ? Math.round(xScale(xAccessor(currentItem))) : mouseXY[0] + 0.5;
|
|
7
|
-
return x;
|
|
8
|
-
};
|
|
9
|
-
export class CrossHairCursor extends React.Component {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.drawOnCanvas = (ctx, moreProps) => {
|
|
13
|
-
const lines = this.getLines(this.props, moreProps);
|
|
14
|
-
if (lines === undefined) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const { margin, ratio } = this.context;
|
|
18
|
-
const originX = 0.5 * ratio + margin.left;
|
|
19
|
-
const originY = 0.5 * ratio + margin.top;
|
|
20
|
-
ctx.save();
|
|
21
|
-
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
22
|
-
ctx.scale(ratio, ratio);
|
|
23
|
-
ctx.translate(originX, originY);
|
|
24
|
-
lines.forEach((line) => {
|
|
25
|
-
const dashArray = getStrokeDasharrayCanvas(line.strokeDasharray);
|
|
26
|
-
ctx.strokeStyle = line.strokeStyle;
|
|
27
|
-
ctx.lineWidth = line.strokeWidth;
|
|
28
|
-
ctx.setLineDash(dashArray);
|
|
29
|
-
ctx.beginPath();
|
|
30
|
-
ctx.moveTo(line.x1, line.y1);
|
|
31
|
-
ctx.lineTo(line.x2, line.y2);
|
|
32
|
-
ctx.stroke();
|
|
33
|
-
});
|
|
34
|
-
ctx.restore();
|
|
35
|
-
};
|
|
36
|
-
this.getLines = (props, moreProps) => {
|
|
37
|
-
const { mouseXY, currentItem, show, height, width } = moreProps;
|
|
38
|
-
const { customX = CrossHairCursor.defaultProps.customX, strokeStyle = CrossHairCursor.defaultProps.strokeStyle, strokeDasharray, strokeWidth = CrossHairCursor.defaultProps.strokeWidth, } = props;
|
|
39
|
-
if (!show || currentItem === undefined) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
const line1 = {
|
|
43
|
-
x1: 0,
|
|
44
|
-
x2: width,
|
|
45
|
-
y1: mouseXY[1] + 0.5,
|
|
46
|
-
y2: mouseXY[1] + 0.5,
|
|
47
|
-
strokeStyle,
|
|
48
|
-
strokeDasharray,
|
|
49
|
-
strokeWidth,
|
|
50
|
-
};
|
|
51
|
-
const x = customX(props, moreProps);
|
|
52
|
-
const line2 = {
|
|
53
|
-
x1: x,
|
|
54
|
-
x2: x,
|
|
55
|
-
y1: 0,
|
|
56
|
-
y2: height,
|
|
57
|
-
strokeStyle,
|
|
58
|
-
strokeDasharray,
|
|
59
|
-
strokeWidth,
|
|
60
|
-
};
|
|
61
|
-
return [line1, line2];
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
render() {
|
|
65
|
-
return (React.createElement(GenericComponent, { clip: false, canvasDraw: this.drawOnCanvas, canvasToDraw: getMouseCanvas, drawOn: ["mousemove", "pan", "drag"] }));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
CrossHairCursor.defaultProps = {
|
|
69
|
-
customX: defaultCustomX,
|
|
70
|
-
snapX: true,
|
|
71
|
-
strokeStyle: "rgba(55, 71, 79, 0.8)",
|
|
72
|
-
strokeDasharray: "Dash",
|
|
73
|
-
strokeWidth: 1,
|
|
74
|
-
};
|
|
75
|
-
CrossHairCursor.contextType = ChartCanvasContext;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getStrokeDasharrayCanvas, GenericComponent, getMouseCanvas, ChartCanvasContext, } from "@tradingaction/core";
|
|
3
|
+
const defaultCustomX = (props, moreProps) => {
|
|
4
|
+
const { xScale, xAccessor, currentItem, mouseXY } = moreProps;
|
|
5
|
+
const { snapX } = props;
|
|
6
|
+
const x = snapX ? Math.round(xScale(xAccessor(currentItem))) : mouseXY[0] + 0.5;
|
|
7
|
+
return x;
|
|
8
|
+
};
|
|
9
|
+
export class CrossHairCursor extends React.Component {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
13
|
+
const lines = this.getLines(this.props, moreProps);
|
|
14
|
+
if (lines === undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { margin, ratio } = this.context;
|
|
18
|
+
const originX = 0.5 * ratio + margin.left;
|
|
19
|
+
const originY = 0.5 * ratio + margin.top;
|
|
20
|
+
ctx.save();
|
|
21
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
22
|
+
ctx.scale(ratio, ratio);
|
|
23
|
+
ctx.translate(originX, originY);
|
|
24
|
+
lines.forEach((line) => {
|
|
25
|
+
const dashArray = getStrokeDasharrayCanvas(line.strokeDasharray);
|
|
26
|
+
ctx.strokeStyle = line.strokeStyle;
|
|
27
|
+
ctx.lineWidth = line.strokeWidth;
|
|
28
|
+
ctx.setLineDash(dashArray);
|
|
29
|
+
ctx.beginPath();
|
|
30
|
+
ctx.moveTo(line.x1, line.y1);
|
|
31
|
+
ctx.lineTo(line.x2, line.y2);
|
|
32
|
+
ctx.stroke();
|
|
33
|
+
});
|
|
34
|
+
ctx.restore();
|
|
35
|
+
};
|
|
36
|
+
this.getLines = (props, moreProps) => {
|
|
37
|
+
const { mouseXY, currentItem, show, height, width } = moreProps;
|
|
38
|
+
const { customX = CrossHairCursor.defaultProps.customX, strokeStyle = CrossHairCursor.defaultProps.strokeStyle, strokeDasharray, strokeWidth = CrossHairCursor.defaultProps.strokeWidth, } = props;
|
|
39
|
+
if (!show || currentItem === undefined) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const line1 = {
|
|
43
|
+
x1: 0,
|
|
44
|
+
x2: width,
|
|
45
|
+
y1: mouseXY[1] + 0.5,
|
|
46
|
+
y2: mouseXY[1] + 0.5,
|
|
47
|
+
strokeStyle,
|
|
48
|
+
strokeDasharray,
|
|
49
|
+
strokeWidth,
|
|
50
|
+
};
|
|
51
|
+
const x = customX(props, moreProps);
|
|
52
|
+
const line2 = {
|
|
53
|
+
x1: x,
|
|
54
|
+
x2: x,
|
|
55
|
+
y1: 0,
|
|
56
|
+
y2: height,
|
|
57
|
+
strokeStyle,
|
|
58
|
+
strokeDasharray,
|
|
59
|
+
strokeWidth,
|
|
60
|
+
};
|
|
61
|
+
return [line1, line2];
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
return (React.createElement(GenericComponent, { clip: false, canvasDraw: this.drawOnCanvas, canvasToDraw: getMouseCanvas, drawOn: ["mousemove", "pan", "drag"] }));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
CrossHairCursor.defaultProps = {
|
|
69
|
+
customX: defaultCustomX,
|
|
70
|
+
snapX: true,
|
|
71
|
+
strokeStyle: "rgba(55, 71, 79, 0.8)",
|
|
72
|
+
strokeDasharray: "Dash",
|
|
73
|
+
strokeWidth: 1,
|
|
74
|
+
};
|
|
75
|
+
CrossHairCursor.contextType = ChartCanvasContext;
|
|
76
76
|
//# sourceMappingURL=CrossHairCursor.js.map
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export interface CurrentCoordinateProps {
|
|
3
|
-
/**
|
|
4
|
-
* Fill style for the circle.
|
|
5
|
-
*/
|
|
6
|
-
readonly fillStyle?: string | ((datum: any) => string);
|
|
7
|
-
/**
|
|
8
|
-
* The radius to draw the circle
|
|
9
|
-
*/
|
|
10
|
-
readonly r: number;
|
|
11
|
-
/**
|
|
12
|
-
* Stroke of the circle
|
|
13
|
-
*/
|
|
14
|
-
readonly strokeStyle?: string | ((datum: any) => string);
|
|
15
|
-
/**
|
|
16
|
-
* Y accessor to use for the circle.
|
|
17
|
-
*/
|
|
18
|
-
readonly yAccessor: (item: any) => number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Draws a circle at the current x location of radius `r`.
|
|
22
|
-
*/
|
|
23
|
-
export declare class CurrentCoordinate extends React.Component<CurrentCoordinateProps> {
|
|
24
|
-
static defaultProps: {
|
|
25
|
-
fillStyle: string;
|
|
26
|
-
r: number;
|
|
27
|
-
};
|
|
28
|
-
render(): JSX.Element;
|
|
29
|
-
private readonly drawOnCanvas;
|
|
30
|
-
private readonly getCircle;
|
|
31
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface CurrentCoordinateProps {
|
|
3
|
+
/**
|
|
4
|
+
* Fill style for the circle.
|
|
5
|
+
*/
|
|
6
|
+
readonly fillStyle?: string | ((datum: any) => string);
|
|
7
|
+
/**
|
|
8
|
+
* The radius to draw the circle
|
|
9
|
+
*/
|
|
10
|
+
readonly r: number;
|
|
11
|
+
/**
|
|
12
|
+
* Stroke of the circle
|
|
13
|
+
*/
|
|
14
|
+
readonly strokeStyle?: string | ((datum: any) => string);
|
|
15
|
+
/**
|
|
16
|
+
* Y accessor to use for the circle.
|
|
17
|
+
*/
|
|
18
|
+
readonly yAccessor: (item: any) => number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Draws a circle at the current x location of radius `r`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class CurrentCoordinate extends React.Component<CurrentCoordinateProps> {
|
|
24
|
+
static defaultProps: {
|
|
25
|
+
fillStyle: string;
|
|
26
|
+
r: number;
|
|
27
|
+
};
|
|
28
|
+
render(): JSX.Element;
|
|
29
|
+
private readonly drawOnCanvas;
|
|
30
|
+
private readonly getCircle;
|
|
31
|
+
}
|
package/lib/CurrentCoordinate.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
/**
|
|
4
|
-
* Draws a circle at the current x location of radius `r`.
|
|
5
|
-
*/
|
|
6
|
-
export class CurrentCoordinate extends React.Component {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.drawOnCanvas = (ctx, moreProps) => {
|
|
10
|
-
const circle = this.getCircle(moreProps);
|
|
11
|
-
if (circle === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const { fillStyle, r, strokeStyle } = this.props;
|
|
15
|
-
const fillColor = fillStyle instanceof Function ? fillStyle(moreProps.currentItem) : fillStyle;
|
|
16
|
-
if (fillColor !== undefined) {
|
|
17
|
-
ctx.fillStyle = fillColor;
|
|
18
|
-
}
|
|
19
|
-
const strokeColor = strokeStyle instanceof Function ? strokeStyle(moreProps.currentItem) : strokeStyle;
|
|
20
|
-
if (strokeColor !== undefined) {
|
|
21
|
-
ctx.strokeStyle = strokeColor;
|
|
22
|
-
}
|
|
23
|
-
ctx.beginPath();
|
|
24
|
-
ctx.arc(circle.x, circle.y, r, 0, 2 * Math.PI, false);
|
|
25
|
-
ctx.fill();
|
|
26
|
-
if (strokeColor !== undefined) {
|
|
27
|
-
ctx.stroke();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this.getCircle = (moreProps) => {
|
|
31
|
-
const { show, xScale, chartConfig: { yScale }, currentItem, xAccessor, } = moreProps;
|
|
32
|
-
if (!show || currentItem === undefined) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
const { yAccessor } = this.props;
|
|
36
|
-
const xValue = xAccessor(currentItem);
|
|
37
|
-
const yValue = yAccessor(currentItem);
|
|
38
|
-
if (yValue === undefined) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
const x = Math.round(xScale(xValue));
|
|
42
|
-
const y = Math.round(yScale(yValue));
|
|
43
|
-
return { x, y };
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
render() {
|
|
47
|
-
return (React.createElement(GenericChartComponent, { canvasDraw: this.drawOnCanvas, canvasToDraw: getMouseCanvas, drawOn: ["mousemove", "pan"] }));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
CurrentCoordinate.defaultProps = {
|
|
51
|
-
fillStyle: "#2196f3",
|
|
52
|
-
r: 3,
|
|
53
|
-
};
|
|
1
|
+
import { getMouseCanvas, GenericChartComponent } from "@tradingaction/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Draws a circle at the current x location of radius `r`.
|
|
5
|
+
*/
|
|
6
|
+
export class CurrentCoordinate extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.drawOnCanvas = (ctx, moreProps) => {
|
|
10
|
+
const circle = this.getCircle(moreProps);
|
|
11
|
+
if (circle === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const { fillStyle, r, strokeStyle } = this.props;
|
|
15
|
+
const fillColor = fillStyle instanceof Function ? fillStyle(moreProps.currentItem) : fillStyle;
|
|
16
|
+
if (fillColor !== undefined) {
|
|
17
|
+
ctx.fillStyle = fillColor;
|
|
18
|
+
}
|
|
19
|
+
const strokeColor = strokeStyle instanceof Function ? strokeStyle(moreProps.currentItem) : strokeStyle;
|
|
20
|
+
if (strokeColor !== undefined) {
|
|
21
|
+
ctx.strokeStyle = strokeColor;
|
|
22
|
+
}
|
|
23
|
+
ctx.beginPath();
|
|
24
|
+
ctx.arc(circle.x, circle.y, r, 0, 2 * Math.PI, false);
|
|
25
|
+
ctx.fill();
|
|
26
|
+
if (strokeColor !== undefined) {
|
|
27
|
+
ctx.stroke();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this.getCircle = (moreProps) => {
|
|
31
|
+
const { show, xScale, chartConfig: { yScale }, currentItem, xAccessor, } = moreProps;
|
|
32
|
+
if (!show || currentItem === undefined) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const { yAccessor } = this.props;
|
|
36
|
+
const xValue = xAccessor(currentItem);
|
|
37
|
+
const yValue = yAccessor(currentItem);
|
|
38
|
+
if (yValue === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const x = Math.round(xScale(xValue));
|
|
42
|
+
const y = Math.round(yScale(yValue));
|
|
43
|
+
return { x, y };
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
return (React.createElement(GenericChartComponent, { canvasDraw: this.drawOnCanvas, canvasToDraw: getMouseCanvas, drawOn: ["mousemove", "pan"] }));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
CurrentCoordinate.defaultProps = {
|
|
51
|
+
fillStyle: "#2196f3",
|
|
52
|
+
r: 3,
|
|
53
|
+
};
|
|
54
54
|
//# sourceMappingURL=CurrentCoordinate.js.map
|
package/lib/Cursor.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { strokeDashTypes } from "@tradingaction/core";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
export interface CursorProps {
|
|
4
|
-
readonly customX?: (props: CursorProps, moreProps: any) => number;
|
|
5
|
-
readonly disableYCursor?: boolean;
|
|
6
|
-
readonly snapX?: boolean;
|
|
7
|
-
readonly strokeDasharray?: strokeDashTypes;
|
|
8
|
-
readonly strokeStyle?: string;
|
|
9
|
-
readonly useXCursorShape?: boolean;
|
|
10
|
-
readonly xCursorShapeFillStyle?: string | ((currentItem: any) => string);
|
|
11
|
-
readonly xCursorShapeStrokeStyle?: string | ((currentItem: any) => string);
|
|
12
|
-
readonly xCursorShapeStrokeDasharray?: strokeDashTypes;
|
|
13
|
-
}
|
|
14
|
-
export declare class Cursor extends React.Component<CursorProps> {
|
|
15
|
-
static defaultProps: {
|
|
16
|
-
strokeStyle: string;
|
|
17
|
-
strokeDasharray: string;
|
|
18
|
-
snapX: boolean;
|
|
19
|
-
customX: (props: CursorProps, moreProps: any) => any;
|
|
20
|
-
disableYCursor: boolean;
|
|
21
|
-
useXCursorShape: boolean;
|
|
22
|
-
xCursorShapeStrokeStyle: string;
|
|
23
|
-
};
|
|
24
|
-
static contextType: React.Context<import("@tradingaction/core/lib/ChartCanvas").ChartCanvasContextType<number | Date>>;
|
|
25
|
-
render(): JSX.Element;
|
|
26
|
-
private getXCursorShapeStroke;
|
|
27
|
-
private getXCursorShapeFill;
|
|
28
|
-
private getXCursorShape;
|
|
29
|
-
private getXYCursor;
|
|
30
|
-
private readonly drawOnCanvas;
|
|
31
|
-
}
|
|
1
|
+
import { strokeDashTypes } from "@tradingaction/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface CursorProps {
|
|
4
|
+
readonly customX?: (props: CursorProps, moreProps: any) => number;
|
|
5
|
+
readonly disableYCursor?: boolean;
|
|
6
|
+
readonly snapX?: boolean;
|
|
7
|
+
readonly strokeDasharray?: strokeDashTypes;
|
|
8
|
+
readonly strokeStyle?: string;
|
|
9
|
+
readonly useXCursorShape?: boolean;
|
|
10
|
+
readonly xCursorShapeFillStyle?: string | ((currentItem: any) => string);
|
|
11
|
+
readonly xCursorShapeStrokeStyle?: string | ((currentItem: any) => string);
|
|
12
|
+
readonly xCursorShapeStrokeDasharray?: strokeDashTypes;
|
|
13
|
+
}
|
|
14
|
+
export declare class Cursor extends React.Component<CursorProps> {
|
|
15
|
+
static defaultProps: {
|
|
16
|
+
strokeStyle: string;
|
|
17
|
+
strokeDasharray: string;
|
|
18
|
+
snapX: boolean;
|
|
19
|
+
customX: (props: CursorProps, moreProps: any) => any;
|
|
20
|
+
disableYCursor: boolean;
|
|
21
|
+
useXCursorShape: boolean;
|
|
22
|
+
xCursorShapeStrokeStyle: string;
|
|
23
|
+
};
|
|
24
|
+
static contextType: React.Context<import("@tradingaction/core/lib/ChartCanvas").ChartCanvasContextType<number | Date>>;
|
|
25
|
+
render(): JSX.Element;
|
|
26
|
+
private getXCursorShapeStroke;
|
|
27
|
+
private getXCursorShapeFill;
|
|
28
|
+
private getXCursorShape;
|
|
29
|
+
private getXYCursor;
|
|
30
|
+
private readonly drawOnCanvas;
|
|
31
|
+
}
|