-
Notifications
You must be signed in to change notification settings - Fork 24
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
Showing
19 changed files
with
472 additions
and
1 deletion.
There are no files selected for viewing
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,25 @@ | ||
import { line } from 'd3'; | ||
|
||
// Positions in pixels | ||
const data = [ | ||
{ x: 0, y: 40 }, | ||
{ x: 50, y: 70 }, | ||
{ x: 100, y: 150 }, | ||
{ x: 200, y: 50 }, | ||
{ x: 300, y: 250 }, | ||
]; | ||
|
||
export const Graph = () => { | ||
// Use the line() function of d3 to create a path generator that expects data as input | ||
const lineGenerator = ''; | ||
|
||
// Use the lineGenerator function above to build the path string | ||
const path = ''; | ||
|
||
return ( | ||
<svg width={500} height={300} style={{ overflow: 'visible' }}> | ||
{/* The path built above is used here for the d argument */} | ||
<path d={path} fill="none" stroke="#69b3a2" /> | ||
</svg> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
viz/exercise/d3LineFilledAreaPractice/d3LineFunctionBasicSolution/Graph.tsx
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,24 @@ | ||
import { line } from 'd3'; | ||
|
||
// Positions in pixels | ||
const data = [ | ||
{ x: 0, y: 40 }, | ||
{ x: 50, y: 70 }, | ||
{ x: 100, y: 150 }, | ||
{ x: 200, y: 50 }, | ||
{ x: 300, y: 250 }, | ||
]; | ||
|
||
export const Graph = () => { | ||
const lineGenerator = line() | ||
.x((d) => d.x) | ||
.y((d) => d.y); | ||
|
||
const path = lineGenerator(data); | ||
|
||
return ( | ||
<svg width={500} height={300} style={{ overflow: 'visible' }}> | ||
<path d={path} fill="none" stroke="#69b3a2" /> | ||
</svg> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
viz/exercise/d3LineFilledAreaPractice/d3LineFunctionBasicSolution/index.js
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,6 @@ | ||
// File used to render something in codesandbox only | ||
import ReactDOM from 'react-dom'; | ||
import { Graph } from './Graph'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
ReactDOM.render(<Graph />, rootElement); |
29 changes: 29 additions & 0 deletions
29
viz/exercise/d3LineFilledAreaPractice/d3LineFunctionBasicSolution/package.json
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,29 @@ | ||
{ | ||
"name": "pie-chart-basic", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"main": "index.js", | ||
"dependencies": { | ||
"react": "17.0.2", | ||
"d3": "7.1.1", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "7.13.8", | ||
"typescript": "4.1.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
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,6 @@ | ||
// File used to render something in codesandbox only | ||
import ReactDOM from 'react-dom'; | ||
import { Graph } from './Graph'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
ReactDOM.render(<Graph />, rootElement); |
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,29 @@ | ||
{ | ||
"name": "pie-chart-basic", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"main": "index.js", | ||
"dependencies": { | ||
"react": "17.0.2", | ||
"d3": "7.1.1", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "7.13.8", | ||
"typescript": "4.1.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
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,38 @@ | ||
import { area, line } from 'd3'; | ||
|
||
// Positions in pixels | ||
const data = [ | ||
{ x: 0, y: 40 }, | ||
{ x: 50, y: 70 }, | ||
{ x: 100, y: 150 }, | ||
{ x: 200, y: 50 }, | ||
{ x: 300, y: 250 }, | ||
]; | ||
|
||
export const Graph = () => { | ||
const lineGenerator = line() | ||
.x((d) => d.x) | ||
.y((d) => d.y); | ||
|
||
const areaGenerator = area() | ||
.x((d) => d.x) | ||
.y0((d) => 300) | ||
.y1((d) => d.y); | ||
|
||
return ( | ||
<svg width={500} height={300} style={{ overflow: 'visible' }}> | ||
<path | ||
d={areaGenerator(data)} | ||
fill="#69b3a2" | ||
stroke="none" | ||
opacity={0.3} | ||
/> | ||
<path | ||
d={lineGenerator(data)} | ||
fill="none" | ||
stroke="#69b3a2" | ||
strokeWidth={3} | ||
/> | ||
</svg> | ||
); | ||
}; |
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,6 @@ | ||
// File used to render something in codesandbox only | ||
import ReactDOM from 'react-dom'; | ||
import { Graph } from './Graph'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
ReactDOM.render(<Graph />, rootElement); |
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,29 @@ | ||
{ | ||
"name": "pie-chart-basic", | ||
"version": "1.0.0", | ||
"description": "", | ||
"keywords": [], | ||
"main": "index.js", | ||
"dependencies": { | ||
"react": "17.0.2", | ||
"d3": "7.1.1", | ||
"react-dom": "17.0.2", | ||
"react-scripts": "4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "7.13.8", | ||
"typescript": "4.1.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
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,30 @@ | ||
import { line } from 'd3'; | ||
|
||
// Positions in pixels | ||
const data = [ | ||
{ x: 0, y: 40 }, | ||
{ x: 50, y: 70 }, | ||
{ x: 100, y: 150 }, | ||
{ x: 200, y: 50 }, | ||
{ x: 300, y: 250 }, | ||
]; | ||
|
||
const data2 = [ | ||
{ x: 0, y: 140 }, | ||
{ x: 50, y: 20 }, | ||
{ x: 100, y: 110 }, | ||
{ x: 200, y: 150 }, | ||
{ x: 300, y: 50 }, | ||
]; | ||
|
||
export const Graph = () => { | ||
const lineGenerator = line() | ||
.x((d) => d.x) | ||
.y((d) => d.y); | ||
|
||
return ( | ||
<svg width={500} height={300} style={{ overflow: 'visible' }}> | ||
{/* Write 2 paths here, one for each dataset! */} | ||
</svg> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
viz/exercise/d3LineMultipleLineChartPractice/d3LineFunctionBasicSolution/Graph.tsx
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,24 @@ | ||
import { line } from 'd3'; | ||
|
||
// Positions in pixels | ||
const data = [ | ||
{ x: 0, y: 40 }, | ||
{ x: 50, y: 70 }, | ||
{ x: 100, y: 150 }, | ||
{ x: 200, y: 50 }, | ||
{ x: 300, y: 250 }, | ||
]; | ||
|
||
export const Graph = () => { | ||
const lineGenerator = line() | ||
.x((d) => d.x) | ||
.y((d) => d.y); | ||
|
||
const path = lineGenerator(data); | ||
|
||
return ( | ||
<svg width={500} height={300} style={{ overflow: 'visible' }}> | ||
<path d={path} fill="none" stroke="#69b3a2" /> | ||
</svg> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
viz/exercise/d3LineMultipleLineChartPractice/d3LineFunctionBasicSolution/index.js
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,6 @@ | ||
// File used to render something in codesandbox only | ||
import ReactDOM from 'react-dom'; | ||
import { Graph } from './Graph'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
ReactDOM.render(<Graph />, rootElement); |
Oops, something went wrong.