In this lab, you'll build an interface to display NYC Open Data.
- Clone this repository using
git clone
cd
into the project foldernpm install
npm start
- Follow the instructions in the "Getting an App Token" section of the "NYC Open Data" lesson.
- Use the NYC Open Data Portal to locate the "2018 Central Park Squirrel Census - Squirrel Data" dataset.
- Consult the API Documentation, and open the API endpoint (the URL ending in
.json
) in a new tab. - Create a new Socrata App Token and append it to the end of the URL.
Refer back to the "Getting an App Token" section of the NYC Open Data lesson if you need help with this.
- Filter the data to only those squirrels who were viewed while running:
running=true
.
Refer back to the "Filtering Data from Socrata" section of the NYC Open Data lesson if you need help with this.
Refer back to the "Getting NYC Open Data into React" section of the NYC Open Data lesson if you need help with this.
- Update the functional component
App
inApp.js
to include acomponentDidMount
lifecycle method. - Use
fetch()
to get the data from Part One, Step 4.console.log()
the result.
Hint: you may need to use an initial
.then()
step to convert the response to JSON.
- Store the result of the API call in a state variable called
squirrels
. - Use
.map()
to render a list of all observed squirrels showing theunique_squirrel_id
of each.
Tip: When you
npm run
, your list should have about 700 entries in it. What happens if you removerunning=true
from your API request?
- Create a new component called
<Squirrel />
and pass its data to it as a prop.
Note: there's a
.Squirrel
CSS class which may be helpful.
- Add a note below the
<h1>
indicating how many observations are in the dataset. - Add an indicator, e.g. a 🍼, to any data block representing a "Juvenile" squirrel.
- Add an indication of the fur color to each data block. (e.g. as a circle, square, or background color)
- Notice that there are several fields related to squirrel color. Choose the one(s) you think will work best.
- Show an indicator of at least 4 of the following properties in each data block:
- "running", "chasing", "climbing", "eating", "foraging", "kuks", "quaas", "moans", "tail_flags", "tail_twitches", "approaches", "indifferent", "runs_from"
- Only show an indicator if the value of the property is
true
.
- Display the date of each observation on the data block.
- Try to reformat the string to show the date as "Wed. Oct. 10, 2018".
- Display the data blocks in order from oldest to newest.
- Add a button at the top of the app that sorts the data by
primary_fur_color
or another data property. - Use the
x
andy
values to display a map of the location where the squirrel was spotted.