Skip to content

Commit e26e5d2

Browse files
committed
init
1 parent 807e7a4 commit e26e5d2

File tree

27 files changed

+1293
-365
lines changed

27 files changed

+1293
-365
lines changed

.yarn/install-state.gz

35.9 KB
Binary file not shown.

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
{
2-
"name": "reearth-visualizer-plugin-shadcn-template",
2+
"name": "30day-map-challenge-2024-hdx",
33
"version": "0.0.1",
44
"type": "module",
55
"engines": {
66
"node": ">=20.11.0"
77
},
88
"scripts": {
9-
"dev:demo:main": "cross-env EXTENSION_NAME=demo UI_NAME=main vite -c configs/ui.ts",
10-
"build:demo:main": "cross-env EXTENSION_NAME=demo UI_NAME=main vite build -c configs/ui.ts",
11-
"build:demo:extension": "cross-env EXTENSION_NAME=demo vite build -c configs/extension.ts",
12-
"build:demo": "run-s build:demo:main build:demo:extension",
13-
"build": "run-s build:demo zip",
9+
"dev:diseaseoutbreaks:main": "cross-env EXTENSION_NAME=diseaseoutbreaks UI_NAME=main vite -c configs/ui.ts",
10+
"build:diseaseoutbreaks:main": "cross-env EXTENSION_NAME=diseaseoutbreaks UI_NAME=main vite build -c configs/ui.ts",
11+
"build:diseaseoutbreaks:extension": "cross-env EXTENSION_NAME=diseaseoutbreaks vite build -c configs/extension.ts",
12+
"build:diseaseoutbreaks": "run-s build:diseaseoutbreaks:main build:diseaseoutbreaks:extension",
13+
"build": "run-s build:diseaseoutbreaks zip",
1414
"preview": "vite preview --port 5005 --strict-port",
1515
"zip": "node ./scripts/zip.mjs",
1616
"lint": "eslint .",
1717
"fix": "eslint --fix .",
1818
"format": "prettier --write .",
19-
"dev-build": "concurrently 'yarn dev:demo:main' 'yarn build:demo:main --watch' 'yarn build:demo:extension --watch' 'vite preview --port 5005 --strict-port'"
19+
"dev-build": "concurrently 'yarn dev:diseaseoutbreaks:main' 'yarn build:diseaseoutbreaks:main --watch' 'yarn build:diseaseoutbreaks:extension --watch' 'vite preview --port 5005 --strict-port'",
20+
"data": "node ./scripts/data.mjs"
2021
},
2122
"dependencies": {
2223
"@radix-ui/react-icons": "1.3.0",
@@ -25,7 +26,8 @@
2526
"@radix-ui/react-slot": "1.1.0",
2627
"class-variance-authority": "0.7.0",
2728
"clsx": "2.1.1",
28-
"lucide-react": "0.400.0",
29+
"lucide-react": "^0.454.0",
30+
"recharts": "^2.13.2",
2931
"tailwind-merge": "2.3.0",
3032
"tailwindcss-animate": "1.0.7"
3133
},
@@ -39,6 +41,7 @@
3941
"@vitejs/plugin-react": "4.3.1",
4042
"archiver": "7.0.1",
4143
"autoprefixer": "10.4.19",
44+
"chroma-js": "3.1.2",
4245
"concurrently": "8.2.2",
4346
"cross-env": "7.0.3",
4447
"eslint": "9.6.0",
@@ -56,6 +59,7 @@
5659
"vite": "5.3.1",
5760
"vite-plugin-cdn-import": "1.0.1",
5861
"vite-plugin-singlefile": "2.0.2",
62+
"xlsx": "0.18.5",
5963
"yml": "1.0.0"
6064
},
6165
"resolutions": {

public/reearth.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
id: reearth-visualizer-plugin-shadcn-template
2-
name: Visualizer plugin shadcn template
1+
id: global-pandemic-and-epidemic-prone-diseaseoutbreaks
2+
name: Global Pandemic- and Epidemic-Prone Disease Outbreaks
33
version: 1.0.0
44
extensions:
5-
- id: demo
5+
- id: diseaseoutbreaks
66
type: widget
7-
name: Demo
7+
name: Global Pandemic- and Epidemic-Prone Disease Outbreaks
8+
widgetLayout:
9+
extendable:
10+
horizontally: true
11+
defaultLocation:
12+
zone: outer
13+
section: center
14+
area: bottom
815
schema:
916
groups:
1017
- id: appearance

scripts/data.mjs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { readFileSync, writeFileSync } from "fs";
2+
import path from "path";
3+
4+
import * as XLSX from "xlsx";
5+
import { read } from "xlsx/xlsx.mjs";
6+
7+
const root = path.resolve("./");
8+
const source = `${root}/source`;
9+
const output = `${root}/src/data`;
10+
11+
const buf = readFileSync(`${source}/disease_outbreaks_HDX.xlsx`);
12+
const workbook = read(buf);
13+
14+
const sheetName = workbook.SheetNames[0];
15+
const worksheet = workbook.Sheets[sheetName];
16+
17+
const jsonData = XLSX.utils.sheet_to_json(worksheet);
18+
19+
if (!jsonData) {
20+
throw new Error("No data found");
21+
}
22+
23+
// Remove header row
24+
jsonData.shift();
25+
26+
// Pick the data we needed
27+
const yearlyOutbreaksCount = jsonData.reduce((acc, data) => {
28+
const year = data["Year"];
29+
30+
if (!year) {
31+
return acc;
32+
}
33+
34+
if (!acc[year]) {
35+
acc[year] = 0;
36+
}
37+
38+
acc[year] += 1;
39+
40+
return acc;
41+
}, {});
42+
43+
writeFileSync(
44+
`${output}/yearlyCount.json`,
45+
JSON.stringify(yearlyOutbreaksCount)
46+
);
47+
48+
const countryOutbreaks = jsonData.reduce((acc, data) => {
49+
const country = data["iso2"];
50+
const year = data["Year"];
51+
const disease = data["Disease"];
52+
53+
if (!country || !year) {
54+
return acc;
55+
}
56+
57+
if (!acc[year]) {
58+
acc[year] = {};
59+
}
60+
61+
if (!acc[year][country]) {
62+
acc[year][country] = [];
63+
}
64+
65+
acc[year][country].push(disease);
66+
67+
return acc;
68+
}, {});
69+
70+
writeFileSync(
71+
`${output}/countryOutbreaks.json`,
72+
JSON.stringify(countryOutbreaks)
73+
);
74+
75+
// get all the contries from the data
76+
const countries = jsonData.reduce((acc, data) => {
77+
const country = data["iso2"];
78+
79+
if (!acc.includes(country)) {
80+
acc.push(country);
81+
}
82+
83+
return acc;
84+
}, []);
85+
86+
const simpleGeojson = JSON.parse(
87+
readFileSync(`${source}/ne_110m_admin_0_countries.geojson`)
88+
);
89+
90+
const filteredGeojson = {
91+
type: "FeatureCollection",
92+
features: simpleGeojson.features.map((feature) => {
93+
if (!countries.includes(feature.properties.iso_a2)) return null;
94+
return {
95+
...feature,
96+
properties: {
97+
isoA2: feature.properties.iso_a2,
98+
admin: feature.properties.admin,
99+
},
100+
};
101+
}),
102+
};
103+
104+
writeFileSync(`${output}/countries.geojson`, JSON.stringify(filteredGeojson));

source/disease_outbreaks_HDX.xlsx

365 KB
Binary file not shown.

source/ne_110m_admin_0_countries.geojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/data/countries.geojson

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/data/countryOutbreaks.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/data/yearlyCount.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"1996":78,"1997":42,"1998":86,"1999":67,"2000":40,"2001":49,"2002":36,"2003":83,"2004":73,"2005":40,"2006":43,"2007":29,"2008":48,"2009":207,"2010":73,"2011":48,"2012":33,"2013":33,"2014":40,"2015":57,"2016":58,"2017":57,"2018":43,"2019":95,"2020":254,"2021":273,"2022":420,"2023":367,"2024":278}

src/extensions/demo/demo.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)