Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScatterSeries bug - not using functor in stroke and fill #784

Open
Boorj opened this issue Feb 7, 2021 · 0 comments · May be fixed by #785
Open

ScatterSeries bug - not using functor in stroke and fill #784

Boorj opened this issue Feb 7, 2021 · 0 comments · May be fixed by #785

Comments

@Boorj
Copy link

Boorj commented Feb 7, 2021

Problem appears when you call Scatter Series this way:

 <ScatterSeries yAccessor={d=>d.y} 
       marker={CircleMarker}
       markerProps={{
           r: 3,
           opacity: 0.4,
           stroke: d=>(d.y > 5 ? '#b213ff' : '#13b2ff') // <-- here's functor for stroke
       }}/>

Stroke (and fill) functors are applied to datums here:
https://github.com/rrag/react-stockcharts/blob/master/src/lib/series/ScatterSeries.js#L80

and here it is forgotten: https://github.com/rrag/react-stockcharts/blob/master/src/lib/series/ScatterSeries.js#L34

renderSVG(moreProps) {
    //...
    const points = helper(this.props, moreProps, xAccessor);

    return <g className={className}>
        {points.map((point, idx) => {

            // `point` contains stroke and fill with already applied function call
            // and markerProps still contain possible functors

            const { marker: Marker } = point; // <-- stroke, fill are ignored here
            return <Marker key={idx} {...markerProps} point={point} />;  //

            // using this way - `<circle>` marker will get stroke===functor ((d)=>...), which is error.
        })}
    </g>;
}

So the solutions will be next:

const { marker: Marker, stroke, fill, ...restPointData} = point;
return <Marker key={idx} {...markerProps} stroke={stroke} fill={fill} point={restPointData} />;
Boorj added a commit to Boorj/react-stockcharts that referenced this issue Feb 8, 2021
Fixes rrag#784. Also, canvas rendering is looking forward to be fixed - to support for functors for markers: `stroke(d)` and `fill(d)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant