Skip to content

Commit 0eb8e0c

Browse files
committed
variable units that are "no units" are no longer shown in the color legend
1 parent 1a98634 commit 0eb8e0c

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGES.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
* Added a type column to the metadata attribute tables displayed
1414
in the "details" panel when in list mode.
1515

16+
* Variable units are no longer shown in the color legend
17+
if the units are either missing in the variable metadata or
18+
if it is a no-unit value like `-`, `1`, or an empty string. (#511)
19+
1620
# Fixes
1721

22+
* Assigned color bars are now preserved when sharing the viewer's
23+
current state. (#465)
24+
1825
* Fixed application crash caused by metadata attributes that are (JSON)
1926
objects. Now attributes values of any type are rendered.
2027

21-
* Colormaps are now preserved when sharing the viewer's current state. (#465)
22-
2328
* Parameter `allow3D` in the viewer branding configuration now hides the
2429
`Volume` tab in the side panel when set to `false`. Default is `true`.
2530

src/components/ColorBarLegend/ColorBarLegend.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,19 @@ export default function ColorBarLegend(
111111
return null;
112112
}
113113

114-
const variableTitleWithUnits =
115-
variableColorBar.type === "categorical"
114+
const effectiveVariableTitle =
115+
variableColorBar.type === "categorical" ||
116+
!variableUnits ||
117+
variableUnits === "1" ||
118+
variableUnits === "-"
116119
? variableTitle || variableName
117-
: `${variableTitle || variableName} (${variableUnits || "-"})`;
120+
: `${variableTitle || variableName} (${variableUnits})`;
118121

119122
return (
120123
<Box sx={styles.container} style={style} ref={colorBarSelectAnchorRef}>
121124
<Box sx={styles.header}>
122125
<Typography sx={styles.title} variant="subtitle1" color="textPrimary">
123-
{variableTitleWithUnits}
126+
{effectiveVariableTitle}
124127
</Typography>
125128
{datasetTitle && (
126129
<Typography

0 commit comments

Comments
 (0)