1
1
import * as React from "react" ;
2
2
3
+ import { strokeDashTypes } from "../utils" ;
3
4
import { OverlayBarSeries } from "./OverlayBarSeries" ;
4
5
import { StraightLine } from "./StraightLine" ;
5
6
6
7
interface ElderRaySeriesProps {
8
+ readonly bearPowerFill ?: string ;
9
+ readonly bullPowerFill ?: string ;
7
10
readonly className ?: string ;
8
- readonly yAccessor : any ; // func
9
- readonly opacity ?: number ;
11
+ readonly clip ?: boolean ;
10
12
readonly stroke ?: boolean ;
11
- readonly bullPowerFill ?: string ;
12
- readonly bearPowerFill ?: string ;
13
+ readonly strokeOpacity ?: number ;
13
14
readonly straightLineStroke ?: string ;
14
15
readonly straightLineOpacity ?: number ;
16
+ readonly straightLineStrokeDasharray ?: strokeDashTypes ;
15
17
readonly widthRatio ?: number ;
16
- readonly clip ?: boolean ;
18
+ readonly yAccessor : ( data : any ) => { bearPower : number , bullPower : number } ;
17
19
}
18
20
19
21
export class ElderRaySeries extends React . Component < ElderRaySeriesProps > {
20
22
21
23
public static defaultProps = {
24
+ bearPowerFill : "#ef5350" ,
25
+ bullPowerFill : "#26a69a" ,
22
26
className : "react-financial-charts-elderray-series" ,
23
- straightLineStroke : "#000000" ,
24
- straightLineOpacity : 0.3 ,
25
- opacity : 0.5 ,
27
+ clip : true ,
28
+ opacity : 0.7 ,
26
29
stroke : true ,
27
- bullPowerFill : "#6BA583" ,
28
- bearPowerFill : "#FF0000" ,
30
+ strokeOpacity : 0.7 ,
31
+ straightLineStroke : "#000000" ,
32
+ straightLineStrokeDasharray : "Dash" ,
33
+ straightLineOpacity : 0.7 ,
29
34
widthRatio : 0.8 ,
30
- clip : true ,
31
35
} ;
32
36
33
37
public render ( ) {
34
- const { className, opacity, stroke,
38
+ const {
39
+ className,
40
+ clip,
41
+ stroke,
42
+ strokeOpacity,
35
43
straightLineStroke,
44
+ straightLineStrokeDasharray,
36
45
straightLineOpacity,
37
46
widthRatio,
38
47
} = this . props ;
39
- const { clip } = this . props ;
40
48
41
49
return (
42
50
< g className = { className } >
@@ -45,35 +53,36 @@ export class ElderRaySeries extends React.Component<ElderRaySeriesProps> {
45
53
className = "react-financial-charts-elderray-bar"
46
54
stroke = { stroke }
47
55
fill = { this . fillForEachBar }
48
- opacity = { opacity }
56
+ opacity = { strokeOpacity }
49
57
widthRatio = { widthRatio }
50
58
clip = { clip }
51
59
yAccessor = { [ this . yAccessorBullTop , this . yAccessorBearTop , this . yAccessorBullBottom , this . yAccessorBearBottom ] } />
52
60
< StraightLine
53
61
className = "react-financial-charts-elderray-straight-line"
54
62
yValue = { 0 }
55
63
stroke = { straightLineStroke }
64
+ strokeDasharray = { straightLineStrokeDasharray }
56
65
opacity = { straightLineOpacity } />
57
66
</ g >
58
67
) ;
59
68
}
60
69
61
- private readonly yAccessorBullTop = ( d ) => {
70
+ private readonly yAccessorBullTop = ( d : any ) => {
62
71
const { yAccessor } = this . props ;
63
72
return yAccessor ( d ) && ( yAccessor ( d ) . bullPower > 0 ? yAccessor ( d ) . bullPower : undefined ) ;
64
73
}
65
74
66
- private readonly yAccessorBearTop = ( d ) => {
75
+ private readonly yAccessorBearTop = ( d : any ) => {
67
76
const { yAccessor } = this . props ;
68
77
return yAccessor ( d ) && ( yAccessor ( d ) . bearPower > 0 ? yAccessor ( d ) . bearPower : undefined ) ;
69
78
}
70
79
71
- private readonly yAccessorBullBottom = ( d ) => {
80
+ private readonly yAccessorBullBottom = ( d : any ) => {
72
81
const { yAccessor } = this . props ;
73
82
return yAccessor ( d ) && ( yAccessor ( d ) . bullPower < 0 ? 0 : undefined ) ;
74
83
}
75
84
76
- private readonly yAccessorBearBottom = ( d ) => {
85
+ private readonly yAccessorBearBottom = ( d : any ) => {
77
86
const { yAccessor } = this . props ;
78
87
return yAccessor ( d ) && ( yAccessor ( d ) . bullPower < 0
79
88
|| yAccessor ( d ) . bullPower * yAccessor ( d ) . bearPower < 0 // bullPower is +ve and bearPower is -ve
0 commit comments