Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedSy1 committed Jan 9, 2024
1 parent a475e75 commit d746190
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 91 deletions.
84 changes: 19 additions & 65 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,26 @@
import './front-end/style/index.css'
import 'leaflet/dist/leaflet.css'
import datas from "./backend/json_files/real_output.json"
import Navbar from './front-end/component/navBar'
import HomePage from "./front-end/pages/Home";
import SourcePage from "./front-end/pages/source";
import {
MapContainer,
TileLayer,
CircleMarker,
Popup,
GeoJSON,
} from 'react-leaflet'
import { MyButton } from "./front-end/component/Button"
import { useState } from 'react'
import Container1 from "./front-end/component/container1"
import color from "./front-end/assets/heatcolor.jpg"
import SourcePage from './front-end/pages/source'
BrowserRouter,
Routes,
Route,
Navigate,
RouterProvider,
createBrowserRouter,
} from "react-router-dom";

function App() {
const [startYear, setStartYear] = useState("2010")
const [endYear, setEndYear] = useState("2015")
const calculatePercentage = (areaName) => {
const rentStart = Number(areaName[startYear])
const rentEnd = Number(areaName[endYear])
if (rentStart == 0 || rentEnd == 0) {
return 0
} else {
const percentageIncrease = (rentEnd - rentStart) / rentEnd * 100
return percentageIncrease;
}
}

const changeColor = (percentIncrease) => {
if (percentIncrease <= 5) return "#00FF00"
if (percentIncrease <= 10) return "#7FFF00"
if (percentIncrease <= 15) return "#BFFF00"
if (percentIncrease <= 20) return "#FFFF00"
if (percentIncrease <= 25) return "#FFBF00"
else {
return "#FF0000"
}
}

return (
<div>
<Navbar/>
<Container1/>
<img className="pt-[25rem] absolute" src={color} alt="color description"/>
<section>
<MapContainer className='flex flex-row justify-center' center={[40.73061, -73.935242]} zoom={11} scrollWheelZoom={false}>
<TileLayer
url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
{
datas.map((data, index) => {
let rentIncrease = calculatePercentage(data)
let color = changeColor(rentIncrease)
return (
<CircleMarker center={data.coordinates} fillOpacity={0.2} fillColor={color} radius={35} key={Math.random() * 1000} color='auto'>
<Popup>Percent Increase: {Math.floor(rentIncrease)}% || {data.areaName}</Popup>
</CircleMarker>
)
})
}
</MapContainer>
<MyButton startYear={startYear} setStartYear={setStartYear} endYear={endYear} setEndYear={setEndYear}></MyButton>

</section>
</div>
<BrowserRouter>
<Routes>
<Route path="/" element={<HomePage/>}/>
<Route path="/pages" element={<SourcePage />} />
</Routes>


</BrowserRouter>

)
}

export default App
export default App;
2 changes: 1 addition & 1 deletion src/backend/json_files/real_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"areaName": "Astoria",
"Borough": "Queens"
},
},
{
"2010": 0.0,
"2011": 0.0,
Expand Down
2 changes: 1 addition & 1 deletion src/front-end/component/navBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Navbar = () => {
<a href="../App.jsx" className="hover:text-blue-500 hover:underline">Home</a>
</li>
<li>
<Link to="../pages/source.jsx" className="hover:text-blue-500 hover:underline">Source</Link>
<Link to="/pages" className="hover:text-blue-500 hover:underline">Source</Link>
</li>
<li>
<a href="" className="hover:text-blue-500 hover:underline">Contact</a>
Expand Down
72 changes: 72 additions & 0 deletions src/front-end/pages/Home.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import '../style/index.css'
import 'leaflet/dist/leaflet.css'
import datas from "../../backend/json_files/real_output.json"
import Navbar from '../component/navBar'
import {
MapContainer,
TileLayer,
CircleMarker,
Popup,
GeoJSON,
} from 'react-leaflet'
import { MyButton } from "../component/Button"
import { useState } from 'react'
import Container1 from "../component/container1"
import color from "../assets/heatcolor.jpg"
import SourcePage from './source'

function HomePage() {
const [startYear, setStartYear] = useState("2010")
const [endYear, setEndYear] = useState("2015")
const calculatePercentage = (areaName) => {
const rentStart = Number(areaName[startYear])
const rentEnd = Number(areaName[endYear])
if (rentStart == 0 || rentEnd == 0) {
return 0
} else {
const percentageIncrease = (rentEnd - rentStart) / rentEnd * 100
return percentageIncrease;
}
}

const changeColor = (percentIncrease) => {
if (percentIncrease <= 5) return "#00FF00"
if (percentIncrease <= 10) return "#7FFF00"
if (percentIncrease <= 15) return "#BFFF00"
if (percentIncrease <= 20) return "#FFFF00"
if (percentIncrease <= 25) return "#FFBF00"
else {
return "#FF0000"
}
}

return (
<div>
<Navbar/>
<Container1/>
<img className="pt-[25rem] absolute" src={color} alt="color description"/>
<section>
<MapContainer className='flex flex-row justify-center' center={[40.73061, -73.935242]} zoom={11} scrollWheelZoom={false}>
<TileLayer
url="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
{
datas.map((data, index) => {
let rentIncrease = calculatePercentage(data)
let color = changeColor(rentIncrease)
return (
<CircleMarker center={data.coordinates} fillOpacity={0.2} fillColor={color} radius={35} key={Math.random() * 1000} color='auto'>
<Popup>Percent Increase: {Math.floor(rentIncrease)}% || {data.areaName}</Popup>
</CircleMarker>
)
})
}
</MapContainer>
<MyButton startYear={startYear} setStartYear={setStartYear} endYear={endYear} setEndYear={setEndYear}></MyButton>

</section>
</div>
)
}

export default HomePage;
22 changes: 12 additions & 10 deletions src/front-end/pages/source.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ const SourcePage = () => {
return (
<div>
<Navbar />
<h1>Sources</h1>
<ul>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_white_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of White People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_black_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&ptsb=&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Black People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_hisp_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Hispanic People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_asian_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Asian People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=rent_gross_recent_med_adj&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2013-2017&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Median Rent</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=hh_inc_rent_med_adj&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Median Household Income</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_edu_collp_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Population Ages 25+ Whom Have a Bachelor's Degree and Up</a></li>
</ul>
<div className="flex-col justify-center m-[10rem] ml-[25rem] mt-[5rem]">
<h1 className="text-[70px] ml-[10rem]">Sources</h1>
<ul className="m-[1rem] mb-[2rem] place-content-center text-[2rem]">
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_white_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of White People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_black_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&ptsb=&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Black People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_hisp_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Hispanic People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_race_asian_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Percentage of Asian People</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=rent_gross_recent_med_adj&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2013-2017&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Median Rent</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=hh_inc_rent_med_adj&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Median Household Income</a></li>
<li><a href="https://app.coredata.nyc/?mlb=false&ntii=pop_edu_collp_pct&ntr=Sub-Borough%20Area&mz=14&vtl=https%3A%2F%2Fthefurmancenter.carto.com%2Fu%2Fnyufc%2Fapi%2Fv2%2Fviz%2F98d1f16e-95fd-4e52-a2b1-b7abaf634828%2Fviz.json&mln=true&mlp=true&mlat=40.718&nty=2018&mb=roadmap&pf=%7B%22subsidies%22%3Atrue%7D&md=map&mlv=false&mlng=-73.996&btl=Borough&atp=neighborhoods">Population Ages 25+ Whom Have a Bachelor's Degree and Up</a></li>
</ul>
</div>
</div>
)
}
Expand Down
27 changes: 14 additions & 13 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import ReactDOM from "react-dom/client"
import './front-end/style/index.css'
import App from './App.jsx'
import HomePage from './front-end/pages/Home.jsx'
import SourcePage from "./front-end/pages/source.jsx"
import {
BrowserRouter as Router,
Expand All @@ -11,20 +11,21 @@ import {
RouterProvider,
createBrowserRouter,
} from "react-router-dom";
import App from "./App.jsx"

const router = createBrowserRouter([
{
path: "/",
element: <App />,
},
{
path: "pages",
element: <SourcePage />,
},
]);
// const router = createBrowserRouter([
// {
// path: "/",
// element: <HomePage />,
// },
// {
// path: "/pages",
// element: <SourcePage />,
// },
// ]);

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<RouterProvider router={router} />
<React.StrictMode>
<App />
</React.StrictMode>,
)
4 changes: 3 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
// base: "/gentrification-project/"
});

0 comments on commit d746190

Please sign in to comment.