-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e7824c
commit 0d2f780
Showing
4 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useState, useRef, useEffect } from "react"; | ||
import * as d3 from 'd3'; | ||
|
||
function ScatterGraph({data}){ | ||
|
||
const [plotData, setPlotData] = useState(data); | ||
|
||
const svgRef = useRef(); | ||
|
||
useEffect(() => { | ||
const w = 400 | ||
const h = 300 | ||
const svg = d3.select(svgRef.current) | ||
.attr('width', w) | ||
.attr('height', h) | ||
.style('overflow', 'visible') | ||
.style('margin-top', '100px') | ||
|
||
const xScale = d3.scaleLinear() | ||
.domain([0, 100]) | ||
.range([0, w]) | ||
|
||
const yScale = d3.scaleLinear() | ||
.domain([0, 200]) | ||
.range([h, 0]) | ||
|
||
const xAxis = d3.axisBottom(xScale).ticks(plotData.length) | ||
const yAxis = d3.axisLeft(yScale).ticks(10) | ||
|
||
svg.append('g') | ||
.call(xAxis) | ||
.attr('transform', `translate(0, ${h})`); | ||
|
||
svg.append('g') | ||
.call(yAxis) | ||
|
||
}, [plotData]) | ||
|
||
console.log(plotData) | ||
|
||
return( | ||
<div> | ||
{/* <svg ref={svgRef}/> */} | ||
</div> | ||
) | ||
} | ||
|
||
export default ScatterGraph; |