Skip to content

Commit aacc4ca

Browse files
committed
refactor: update colors
1 parent e26e5d2 commit aacc4ca

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

scripts/data.mjs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (!jsonData) {
2323
// Remove header row
2424
jsonData.shift();
2525

26-
// Pick the data we needed
26+
// Yearly count of outbreaks
2727
const yearlyOutbreaksCount = jsonData.reduce((acc, data) => {
2828
const year = data["Year"];
2929

@@ -45,6 +45,7 @@ writeFileSync(
4545
JSON.stringify(yearlyOutbreaksCount)
4646
);
4747

48+
// Yearly country wise count of outbreaks
4849
const countryOutbreaks = jsonData.reduce((acc, data) => {
4950
const country = data["iso2"];
5051
const year = data["Year"];
@@ -72,7 +73,22 @@ writeFileSync(
7273
JSON.stringify(countryOutbreaks)
7374
);
7475

75-
// get all the contries from the data
76+
// Get the max count of outbreaks for one contry in a year
77+
// const maxOutbreaks = Object.keys(countryOutbreaks).reduce((acc, year) => {
78+
// const max = Math.max(
79+
// ...Object.values(countryOutbreaks[year]).map(
80+
// (outbreaks) => outbreaks.length
81+
// )
82+
// );
83+
84+
// acc[year] = max;
85+
86+
// return acc;
87+
// }, {});
88+
// console.log(maxOutbreaks);
89+
// Output: max is 10 at yaer 2022
90+
91+
// Pick necessary countries geojson
7692
const countries = jsonData.reduce((acc, data) => {
7793
const country = data["iso2"];
7894

src/extensions/diseaseoutbreaks/diseaseoutbreaks.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ const layerId = reearth.layers.add({
3535
fillColor: {
3636
expression: {
3737
conditions: [
38-
["${diseasesCount} === 0", "color('#ff000000')"],
39-
["${diseasesCount} === 1", "color('#ff000011')"],
40-
["${diseasesCount} === 2", "color('#ff000022')"],
41-
["${diseasesCount} === 3", "color('#ff000033')"],
42-
["${diseasesCount} === 4", "color('#ff000044')"],
43-
["${diseasesCount} === 5", "color('#ff000055')"],
44-
["${diseasesCount} === 6", "color('#ff000066')"],
45-
["${diseasesCount} === 7", "color('#ff000077')"],
46-
["${diseasesCount} === 8", "color('#ff000088')"],
47-
["${diseasesCount} === 9", "color('#ff000099')"],
38+
["${diseasesCount} === 1", "color('#FFD7D490')"],
39+
["${diseasesCount} === 2", "color('#FFB8B190')"],
40+
["${diseasesCount} === 3", "color('#FF9A8F90')"],
41+
["${diseasesCount} === 4", "color('#FF7C6D90')"],
42+
["${diseasesCount} === 5", "color('#FF5D4B90')"],
43+
["${diseasesCount} === 6", "color('#E24B3D90')"],
44+
["${diseasesCount} === 7", "color('#C4393090')"],
45+
["${diseasesCount} === 8", "color('#A1272490')"],
46+
["${diseasesCount} === 9", "color('#85151B90')"],
47+
["${diseasesCount} === 10", "color('#6A0C1590')"],
4848
["true", "color('#ffffff00')"],
4949
],
5050
},

0 commit comments

Comments
 (0)