Skip to content

Instantly share code, notes, and snippets.

@nautilytics
Last active January 2, 2020 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nautilytics/a476e0c62314af31c255b038965b16f5 to your computer and use it in GitHub Desktop.
Save nautilytics/a476e0c62314af31c255b038965b16f5 to your computer and use it in GitHub Desktop.
An example of creating an axis using React
import {select as d3_select} from 'd3-selection';
...
const xAxisRef = useRef();
useEffect(() => {
renderXAxis();
});
const renderXAxis = () => {
const xAxis = d3_select(xAxisRef.current);
xAxis.call(axisBottom(xScale));
};
return (
<g className="axis--x" ref={xAxisRef} transform={`translate(0,${height})`}></g>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment