Rechart for React中单个点的CustomizedDot

时间:2019-01-23 07:03:24

标签: reactjs recharts

在我的图形中,我具有带有以下线属性的折线图。我想在仅targetYear图上的year和年份相同的情况下出现的线上创建自定义点。

<Line 
name="Net Payment Male" 
type="monotone" 
dataKey="Maleval" 
stroke="#002e56" 
dot={<CustomizedDot 
targetYear={this.state.individualA.year} />}/>

理想情况下,我想在<CustomizedDot />中做类似的事情,只有在对象yeartargetYear相同的情况下,我才能渲染点。

class CustomizedDot extends React.Component {
    render() {
        const { cx, cy } = this.props;

        if (this.props.payload.year = this.props.targetYear){
            return (
            <circle  cx={cx} cy={cy} r={4} stroke="black" strokeWidth={1} fill="red" />
            );
        };
    }
};

这当然是行不通的。我不太确定如何获取有效负载中对​​象的各个x,y值。

0 个答案:

没有答案