diff --git a/src/legends/ramp.js b/src/legends/ramp.js
index f8422eed09..ebe9cbce64 100644
--- a/src/legends/ramp.js
+++ b/src/legends/ramp.js
@@ -149,14 +149,16 @@ export function legendRamp(color, {
.attr("font-family", null)
.attr("font-variant", impliedString(fontVariant, "normal"))
.call(tickAdjust)
- .call(g => g.select(".domain").remove())
- .call(label === undefined ? () => {} : g => g.append("text")
- .attr("x", marginLeft)
- .attr("y", marginTop + marginBottom - height - 6)
- .attr("fill", "currentColor") // TODO move to stylesheet?
- .attr("text-anchor", "start")
- .attr("font-weight", "bold")
- .text(label));
+ .call(g => g.select(".domain").remove());
+
+ if (label !== undefined) {
+ svg.append("text")
+ .attr("x", marginLeft)
+ .attr("y", marginTop - 6)
+ .attr("fill", "currentColor") // TODO move to stylesheet?
+ .attr("font-weight", "bold")
+ .text(label);
+ }
return svg.node();
}
diff --git a/test/output/carsHexbin.html b/test/output/carsHexbin.html
index 3814364763..41dd5fa93b 100644
--- a/test/output/carsHexbin.html
+++ b/test/output/carsHexbin.html
@@ -26,8 +26,8 @@
5,000
- weight (lb)
-
+
+ weight (lb)
\ No newline at end of file
diff --git a/test/output/hexbinR.html b/test/output/hexbinR.html
index 6d10c759ea..1bf35141af 100644
--- a/test/output/hexbinR.html
+++ b/test/output/hexbinR.html
@@ -26,8 +26,8 @@
15
- Proportion of each sex (%)
-
+
+ Proportion of each sex (%)