David Pomerenke
commited on
Commit
·
3680a5f
1
Parent(s):
f046407
Add scores to world map hover title
Browse files
frontend/src/components/WorldMap.js
CHANGED
@@ -14,16 +14,22 @@ const smoothProgressBar = fraction => {
|
|
14 |
}
|
15 |
|
16 |
const makeTitle = data => d => {
|
17 |
-
const
|
|
|
18 |
(a, b) => b.population - a.population
|
19 |
)
|
20 |
const pop = languages?.map(a => a.population).reduce((prev, a) => prev + a, 0)
|
21 |
const langstring =
|
22 |
languages
|
23 |
?.slice(0, 10)
|
24 |
-
.map(
|
|
|
|
|
|
|
|
|
|
|
25 |
.join('\n\n') + (languages?.length > 10 ? `\n\n...` : '')
|
26 |
-
return `${d.properties.ADMIN}\n\n${langstring}`
|
27 |
}
|
28 |
|
29 |
const WorldMap = ({ data }) => {
|
|
|
14 |
}
|
15 |
|
16 |
const makeTitle = data => d => {
|
17 |
+
const cData = data[d.properties?.ISO_A2_EH]
|
18 |
+
const languages = cData?.languages.toSorted(
|
19 |
(a, b) => b.population - a.population
|
20 |
)
|
21 |
const pop = languages?.map(a => a.population).reduce((prev, a) => prev + a, 0)
|
22 |
const langstring =
|
23 |
languages
|
24 |
?.slice(0, 10)
|
25 |
+
.map(
|
26 |
+
a =>
|
27 |
+
`${smoothProgressBar(a.population / pop)} ${
|
28 |
+
a.name
|
29 |
+
} – ${a.score.toFixed(2)}`
|
30 |
+
)
|
31 |
.join('\n\n') + (languages?.length > 10 ? `\n\n...` : '')
|
32 |
+
return `${d.properties.ADMIN} – ${cData?.score.toFixed(2)}\n\n${langstring}`
|
33 |
}
|
34 |
|
35 |
const WorldMap = ({ data }) => {
|