Datadescription descripes data with colors. But values often have units (e.g. km, mm, cm, ...) Datadescription should be expanded to add the units at the displayed data.
Example code:
function appendUnits(evt) {
let units = JSON.parse(localStorage.getItem("attributeUnits"));
const repeatedSets = evt.detail.repeateds;
repeatedSets.forEach(set => {
for (let i = 0; i < set.children.length; i++) {
const child = set.children[i];
const bpElements = child.querySelectorAll("swac-bp[attrname]");
bpElements.forEach(bp => {
const attr = bp.getAttribute("attrname");
if (units[attr] !== null && units[attr] !== undefined) {
const span = child.querySelector("span");
if (span) {
span.textContent += " " + units[attr]
}
}
});
}
});
}
But code should not modify the displayed value itself but have to add the unit after the values bindpoint.
Datadescription descripes data with colors. But values often have units (e.g. km, mm, cm, ...) Datadescription should be expanded to add the units at the displayed data.
Example code:
function appendUnits(evt) {
let units = JSON.parse(localStorage.getItem("attributeUnits"));
const repeatedSets = evt.detail.repeateds;
repeatedSets.forEach(set => {
for (let i = 0; i < set.children.length; i++) {
const child = set.children[i];
const bpElements = child.querySelectorAll("swac-bp[attrname]");
}
But code should not modify the displayed value itself but have to add the unit after the values bindpoint.