jameslaneconkling / yard3

Yet Another React-D3 Integration Library
https://jameslaneconkling.github.io/yard3/
2 stars 3 forks source link

standardize event interface so every event is a d3 event #15

Open jameslaneconkling opened 7 years ago

jameslaneconkling commented 7 years ago

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