Closed etorem closed 1 month ago
There are only two indicators with the measurementType
"Score" - HVI, and Walkability Index. "1 (lowest) to 5 (highest)" is the displayType
of the HVI indicator; there's no `displayType for Walkability Index.
First I added a conditional checking for Score in a test that assigns values from an indicator's metadata to go into that tooltip field in the spec - the middle statement re 'Score' below.
if (mapMeasurementType.includes('Percent') || mapMeasurementType.includes('percent') && !mapMeasurementType.includes('percentile')) {
isPercent = true
displayType = '%'
subtitle = mapMeasurementType
} else if (mapMeasurementType.includes('Score')) {
displayType = ''
} else {
isPercent = false
displayType = metadata[0]?.DisplayType;
subtitle = mapMeasurementType + `${displayType ? ` (${displayType})` : ''}`
console.log('display type:', displayType)
}
Alternatively, I could just add the below test, which should be a little more durable to changes - ideally we wouldn't do any text-matching, but I don't think "Heat vulnerability index" as an indicator name is likely to change. (Additionally, below, we can give it an "...out of 5" displayType, to appear in the tooltip.)
if (indicatorName.includes('Heat vulnerability index')) {
displayType = ' out of 5'
}
This raises an alternate question re the grammer of our metadata. Would it be better to just re-name the HVI's displayType
field to "out of 5" instead of 1 (lowest) to 5 (highest)? I feel like there's something intuitive about "vulnerability? higher number = more vulnerability" that we might not need to spell out; and if we change this displayType
field then we wouldn't need to do any additional matching.
Update - planning to do this via metadata instead: changing displayType
from "1 (lowest) to 5 (highest)" to "out of 5."
Deployed!
When mousing over different areas on the map it reads the score followed immediately by the score range, without any separating punctuation.