Last active
January 2, 2020 15:59
-
-
Save nautilytics/a476e0c62314af31c255b038965b16f5 to your computer and use it in GitHub Desktop.
An example of creating an axis using React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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