@tradingaction/tooltip 2.1.2 → 2.1.3

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.
@@ -1,97 +0,0 @@
1
- import { functor, GenericChartComponent } from "@tradingaction/core";
2
- import { format } from "d3-format";
3
- import * as React from "react";
4
- import { ToolTipText } from "./ToolTipText";
5
- import { ToolTipTSpanLabel } from "./ToolTipTSpanLabel";
6
-
7
- export interface StochasticTooltipProps {
8
- readonly origin: number[] | ((width: number, height: number) => [number, number]);
9
- readonly className?: string;
10
- readonly fontFamily?: string;
11
- readonly fontSize?: number;
12
- readonly fontWeight?: number;
13
- readonly labelFill?: string;
14
- readonly onClick?: (event: React.MouseEvent) => void;
15
- readonly yAccessor: (currentItem: any) => { K: number; D: number };
16
- readonly options: {
17
- windowSize: number;
18
- kWindowSize: number;
19
- dWindowSize: number;
20
- };
21
- readonly appearance: {
22
- stroke: {
23
- dLine: string;
24
- kLine: string;
25
- };
26
- };
27
- readonly displayFormat: (value: number) => string;
28
- readonly displayInit?: string;
29
- readonly displayValuesFor?: (props: StochasticTooltipProps, moreProps: any) => any;
30
- readonly label: string;
31
- }
32
-
33
- export class StochasticTooltip extends React.Component<StochasticTooltipProps> {
34
- public static defaultProps = {
35
- className: "react-financial-charts-tooltip",
36
- displayFormat: format(".2f"),
37
- displayInit: "n/a",
38
- displayValuesFor: (_: any, props: any) => props.currentItem,
39
- label: "STO",
40
- origin: [0, 0],
41
- };
42
-
43
- public render() {
44
- return <GenericChartComponent clip={false} svgDraw={this.renderSVG} drawOn={["mousemove"]} />;
45
- }
46
-
47
- private readonly renderSVG = (moreProps: any) => {
48
- const {
49
- onClick,
50
- fontFamily,
51
- fontSize,
52
- fontWeight,
53
- yAccessor,
54
- displayFormat,
55
- origin: originProp,
56
- label,
57
- className,
58
- displayInit,
59
- displayValuesFor = StochasticTooltip.defaultProps.displayValuesFor,
60
- options,
61
- appearance,
62
- labelFill,
63
- } = this.props;
64
- const {
65
- chartConfig: { width, height },
66
- fullData,
67
- } = moreProps;
68
-
69
- const currentItem = displayValuesFor(this.props, moreProps) ?? fullData[fullData.length - 1];
70
-
71
- const stochastic = currentItem && yAccessor(currentItem);
72
-
73
- const K = (stochastic?.K && displayFormat(stochastic.K)) ?? displayInit;
74
- const D = (stochastic?.D && displayFormat(stochastic.D)) ?? displayInit;
75
-
76
- const origin = functor(originProp);
77
-
78
- const [x, y] = origin(width, height);
79
-
80
- const { stroke } = appearance;
81
-
82
- return (
83
- <g className={className} transform={`translate(${x}, ${y})`} onClick={onClick}>
84
- <ToolTipText x={0} y={0} fontFamily={fontFamily} fontSize={fontSize} fontWeight={fontWeight}>
85
- <ToolTipTSpanLabel fill={labelFill}>{`${label} %K(`}</ToolTipTSpanLabel>
86
- <tspan fill={stroke.kLine}>{`${options.windowSize}, ${options.kWindowSize}`}</tspan>
87
- <ToolTipTSpanLabel fill={labelFill}>): </ToolTipTSpanLabel>
88
- <tspan fill={stroke.kLine}>{K}</tspan>
89
- <ToolTipTSpanLabel fill={labelFill}> %D (</ToolTipTSpanLabel>
90
- <tspan fill={stroke.dLine}>{options.dWindowSize}</tspan>
91
- <ToolTipTSpanLabel fill={labelFill}>): </ToolTipTSpanLabel>
92
- <tspan fill={stroke.dLine}>{D}</tspan>
93
- </ToolTipText>
94
- </g>
95
- );
96
- };
97
- }
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
-
3
- export class ToolTipTSpanLabel extends React.PureComponent<React.SVGProps<SVGTSpanElement>> {
4
- public static defaultProps = {
5
- className: "react-financial-charts-tooltip-label",
6
- fill: "#4682B4",
7
- };
8
-
9
- public render() {
10
- const { children, ...rest } = this.props;
11
-
12
- return <tspan {...rest}>{children}</tspan>;
13
- }
14
- }
@@ -1,15 +0,0 @@
1
- import * as React from "react";
2
-
3
- export class ToolTipText extends React.PureComponent<React.SVGProps<SVGTextElement>> {
4
- public static defaultProps = {
5
- className: "react-financial-charts-tooltip",
6
- fontFamily: "-apple-system, system-ui, 'Helvetica Neue', Ubuntu, sans-serif",
7
- fontSize: 11,
8
- };
9
-
10
- public render() {
11
- const { children, ...rest } = this.props;
12
-
13
- return <text {...rest}>{children}</text>;
14
- }
15
- }
package/src/index.ts DELETED
@@ -1,13 +0,0 @@
1
- export * from "./BollingerBandTooltip";
2
- export * from "./GroupTooltip";
3
- export * from "./HoverTooltip";
4
- export * from "./IndicatorDisplayTooltip";
5
- export * from "./MACDTooltip";
6
- export * from "./MovingAverageTooltip";
7
- export * from "./OHLCTooltip";
8
- export * from "./RSITooltip";
9
- export * from "./SingleTooltip";
10
- export * from "./SingleValueTooltip";
11
- export * from "./StochasticTooltip";
12
- export * from "./ToolTipText";
13
- export * from "./ToolTipTSpanLabel";