-
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
MohamedSy1
committed
Jan 9, 2024
1 parent
a475e75
commit d746190
Showing
7 changed files
with
122 additions
and
91 deletions.
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
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; |
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
], | ||
"areaName": "Astoria", | ||
"Borough": "Queens" | ||
}, | ||
}, | ||
{ | ||
"2010": 0.0, | ||
"2011": 0.0, | ||
|
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,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; |
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