Last active
May 20, 2021 05:14
-
-
Save LiorB-D/ba302c76a84d2973ffbe1fd115ce026d to your computer and use it in GitHub Desktop.
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 './App.css'; | |
import * as d3 from 'd3' | |
import {useEffect, useState} from 'react' | |
function App() { | |
useEffect(() => { | |
// Create a dataset of pets and the amount of people that own them | |
let dataSet = [ | |
{subject: "Dogs", count: 150}, | |
{subject: "Fish", count: 75}, | |
{subject: "Cats", count: 135}, | |
{subject: "Bunnies", count: 240}, | |
] | |
// Generate a p tag for each element in the dataSet with the text: Subject: Count | |
d3.select('#pgraphs').selectAll('p').data(dataSet).enter().append('p').text(dt => dt.subject + ": " + dt.count) | |
}, []) | |
return ( | |
<div className = "App"> | |
<div id="pgraphs"></div> // Create a div to house our p tags | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment