react event handling:
const Line = props => {
const {data, xScale, yScale, containerWidth, containerHeight} = props;
const styles = extractStyles(props);
const events = extractEvents(props);
xScale.rangeRound([0, containerWidth]);
yScale.rangeRound([containerHeight, 0]);
const line = d3.line()
.x(d => xScale(d[0]))
.y(d => yScale(d[1]));
return (
<g>
<path
{...styles}
{...events}
d={line(data)}
/>
</g>
);
};
d3 event handling
react event handling:
d3 event handling