Skip to content

Commit 71e9a9b

Browse files
committed
feat(elder-ray): allowing stroke dash to be set on the zero line
Added strokeOpacity for consistency. Added straightLineStrokeDasharray.
1 parent fb96940 commit 71e9a9b

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

packages/charts/src/series/ElderRaySeries.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
import * as React from "react";
22

3+
import { strokeDashTypes } from "../utils";
34
import { OverlayBarSeries } from "./OverlayBarSeries";
45
import { StraightLine } from "./StraightLine";
56

67
interface ElderRaySeriesProps {
8+
readonly bearPowerFill?: string;
9+
readonly bullPowerFill?: string;
710
readonly className?: string;
8-
readonly yAccessor: any; // func
9-
readonly opacity?: number;
11+
readonly clip?: boolean;
1012
readonly stroke?: boolean;
11-
readonly bullPowerFill?: string;
12-
readonly bearPowerFill?: string;
13+
readonly strokeOpacity?: number;
1314
readonly straightLineStroke?: string;
1415
readonly straightLineOpacity?: number;
16+
readonly straightLineStrokeDasharray?: strokeDashTypes;
1517
readonly widthRatio?: number;
16-
readonly clip?: boolean;
18+
readonly yAccessor: (data: any) => { bearPower: number, bullPower: number };
1719
}
1820

1921
export class ElderRaySeries extends React.Component<ElderRaySeriesProps> {
2022

2123
public static defaultProps = {
24+
bearPowerFill: "#ef5350",
25+
bullPowerFill: "#26a69a",
2226
className: "react-financial-charts-elderray-series",
23-
straightLineStroke: "#000000",
24-
straightLineOpacity: 0.3,
25-
opacity: 0.5,
27+
clip: true,
28+
opacity: 0.7,
2629
stroke: true,
27-
bullPowerFill: "#6BA583",
28-
bearPowerFill: "#FF0000",
30+
strokeOpacity: 0.7,
31+
straightLineStroke: "#000000",
32+
straightLineStrokeDasharray: "Dash",
33+
straightLineOpacity: 0.7,
2934
widthRatio: 0.8,
30-
clip: true,
3135
};
3236

3337
public render() {
34-
const { className, opacity, stroke,
38+
const {
39+
className,
40+
clip,
41+
stroke,
42+
strokeOpacity,
3543
straightLineStroke,
44+
straightLineStrokeDasharray,
3645
straightLineOpacity,
3746
widthRatio,
3847
} = this.props;
39-
const { clip } = this.props;
4048

4149
return (
4250
<g className={className}>
@@ -45,35 +53,36 @@ export class ElderRaySeries extends React.Component<ElderRaySeriesProps> {
4553
className="react-financial-charts-elderray-bar"
4654
stroke={stroke}
4755
fill={this.fillForEachBar}
48-
opacity={opacity}
56+
opacity={strokeOpacity}
4957
widthRatio={widthRatio}
5058
clip={clip}
5159
yAccessor={[this.yAccessorBullTop, this.yAccessorBearTop, this.yAccessorBullBottom, this.yAccessorBearBottom]} />
5260
<StraightLine
5361
className="react-financial-charts-elderray-straight-line"
5462
yValue={0}
5563
stroke={straightLineStroke}
64+
strokeDasharray={straightLineStrokeDasharray}
5665
opacity={straightLineOpacity} />
5766
</g>
5867
);
5968
}
6069

61-
private readonly yAccessorBullTop = (d) => {
70+
private readonly yAccessorBullTop = (d: any) => {
6271
const { yAccessor } = this.props;
6372
return yAccessor(d) && (yAccessor(d).bullPower > 0 ? yAccessor(d).bullPower : undefined);
6473
}
6574

66-
private readonly yAccessorBearTop = (d) => {
75+
private readonly yAccessorBearTop = (d: any) => {
6776
const { yAccessor } = this.props;
6877
return yAccessor(d) && (yAccessor(d).bearPower > 0 ? yAccessor(d).bearPower : undefined);
6978
}
7079

71-
private readonly yAccessorBullBottom = (d) => {
80+
private readonly yAccessorBullBottom = (d: any) => {
7281
const { yAccessor } = this.props;
7382
return yAccessor(d) && (yAccessor(d).bullPower < 0 ? 0 : undefined);
7483
}
7584

76-
private readonly yAccessorBearBottom = (d) => {
85+
private readonly yAccessorBearBottom = (d: any) => {
7786
const { yAccessor } = this.props;
7887
return yAccessor(d) && (yAccessor(d).bullPower < 0
7988
|| yAccessor(d).bullPower * yAccessor(d).bearPower < 0 // bullPower is +ve and bearPower is -ve

0 commit comments

Comments
 (0)