Skip to content

Commit

Permalink
Adds units to legend attribute label (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
eireland authored Sep 25, 2024
1 parent 9556707 commit 9653590
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const LegendAttributeLabel =
const dataset = dataConfiguration?.dataset,
attributeID = dataConfiguration?.attributeID('legend'),
attributeName = (attributeID ? dataset?.attrFromID(attributeID)?.name : '') ?? '',
attributeUnits = (attributeID ? dataset?.attrFromID(attributeID)?.units : '') ?? '',
labelFont = vars.labelFont,
labelBounds = getStringBounds(attributeName, labelFont),
tX = axisGap,
Expand All @@ -40,7 +41,7 @@ export const LegendAttributeLabel =
.attr('data-testid', className)
.attr('x', tX)
.attr('y', tY)
.text(attributeName)
.text(`${attributeName}${attributeUnits ? ` (${attributeUnits})` : ''}`)
)
}, [dataConfiguration])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const GraphAttributeLabel =
}
return attrIDs.map(anID => dataset?.attrFromID(anID))
.filter(attr => attr?.name !== '')
.map(attr => `${attr?.name} ${attr?.units ? `(${attr?.units})` : ""}`.trim())
.map(attr => `${attr?.name}${attr?.units ? ` (${attr?.units})` : ""}`.trim())
.join(', ')
}, [dataConfiguration?.secondaryRole, dataset, getAttributeIDs, getClickHereCue,
graphModel.pointsFusedIntoBars, place])
Expand Down

0 comments on commit 9653590

Please sign in to comment.