diff --git a/src/axes.js b/src/axes.js
index abb1cd0d92..70343a8047 100644
--- a/src/axes.js
+++ b/src/axes.js
@@ -143,6 +143,6 @@ function inferLabel(channels = [], scale, axis, key) {
return candidate;
}
-function inferFontVariant(scale) {
+export function inferFontVariant(scale) {
return isOrdinalScale(scale) ? undefined : "tabular-nums";
}
diff --git a/src/legends/ramp.js b/src/legends/ramp.js
index e1df6d5d33..5cbf30b03c 100644
--- a/src/legends/ramp.js
+++ b/src/legends/ramp.js
@@ -1,6 +1,7 @@
import {create, quantize, interpolateNumber, piecewise, format, scaleBand, scaleLinear, axisBottom} from "d3";
+import {inferFontVariant} from "../axes.js";
import {interpolatePiecewise} from "../scales/quantitative.js";
-import {applyInlineStyles, maybeClassName} from "../style.js";
+import {applyInlineStyles, impliedString, maybeClassName} from "../style.js";
export function legendRamp(color, {
label = color.label,
@@ -14,6 +15,7 @@ export function legendRamp(color, {
style,
ticks = (width - marginLeft - marginRight) / 64,
tickFormat,
+ fontVariant = inferFontVariant(color),
round = true,
className
}) {
@@ -141,6 +143,7 @@ export function legendRamp(color, {
.tickValues(Array.isArray(ticks) ? ticks : null))
.attr("font-size", null)
.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")
diff --git a/src/legends/swatches.js b/src/legends/swatches.js
index 28720d2118..997ee5f7bf 100644
--- a/src/legends/swatches.js
+++ b/src/legends/swatches.js
@@ -1,10 +1,12 @@
import {create} from "d3";
+import {inferFontVariant} from "../axes.js";
import {maybeTickFormat} from "../axis.js";
-import {applyInlineStyles, maybeClassName} from "../style.js";
+import {applyInlineStyles, impliedString, maybeClassName} from "../style.js";
export function legendSwatches(color, {
columns,
tickFormat,
+ fontVariant = inferFontVariant(color),
// TODO label,
swatchSize = 15,
swatchWidth = swatchSize,
@@ -96,6 +98,7 @@ export function legendSwatches(color, {
}
${extraStyle}
`))
+ .style("font-variant", impliedString(fontVariant, "normal"))
.call(applyInlineStyles, style)
.node();
}
diff --git a/test/output/colorLegendDiverging.svg b/test/output/colorLegendDiverging.svg
index 6c8ecebfbe..461a99b903 100644
--- a/test/output/colorLegendDiverging.svg
+++ b/test/output/colorLegendDiverging.svg
@@ -14,7 +14,7 @@
}
-
+
−10%
diff --git a/test/output/colorLegendDivergingPivot.svg b/test/output/colorLegendDivergingPivot.svg
index 98d92fe4a4..6a79c777f3 100644
--- a/test/output/colorLegendDivergingPivot.svg
+++ b/test/output/colorLegendDivergingPivot.svg
@@ -14,7 +14,7 @@
}
-
+
1
diff --git a/test/output/colorLegendDivergingPivotAsymmetric.svg b/test/output/colorLegendDivergingPivotAsymmetric.svg
index ebcb03e0ea..59cb76488e 100644
--- a/test/output/colorLegendDivergingPivotAsymmetric.svg
+++ b/test/output/colorLegendDivergingPivotAsymmetric.svg
@@ -14,7 +14,7 @@
}
-
+
1
diff --git a/test/output/colorLegendDivergingSqrt.svg b/test/output/colorLegendDivergingSqrt.svg
index f9a247d9a0..243e1bc5ae 100644
--- a/test/output/colorLegendDivergingSqrt.svg
+++ b/test/output/colorLegendDivergingSqrt.svg
@@ -14,7 +14,7 @@
}
-
+
−10%
diff --git a/test/output/colorLegendImplicitLabel.svg b/test/output/colorLegendImplicitLabel.svg
index 9c91811f5c..b796285b48 100644
--- a/test/output/colorLegendImplicitLabel.svg
+++ b/test/output/colorLegendImplicitLabel.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendInterpolate.svg b/test/output/colorLegendInterpolate.svg
index 82088280c5..04b4e30ec0 100644
--- a/test/output/colorLegendInterpolate.svg
+++ b/test/output/colorLegendInterpolate.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendInterpolateSqrt.svg b/test/output/colorLegendInterpolateSqrt.svg
index 02f319057d..36f50d537a 100644
--- a/test/output/colorLegendInterpolateSqrt.svg
+++ b/test/output/colorLegendInterpolateSqrt.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendLabelBoth.svg b/test/output/colorLegendLabelBoth.svg
index 4e7041602b..b4c17bca51 100644
--- a/test/output/colorLegendLabelBoth.svg
+++ b/test/output/colorLegendLabelBoth.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendLabelLegend.svg b/test/output/colorLegendLabelLegend.svg
index 4e7041602b..b4c17bca51 100644
--- a/test/output/colorLegendLabelLegend.svg
+++ b/test/output/colorLegendLabelLegend.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendLabelScale.svg b/test/output/colorLegendLabelScale.svg
index 0d7524ad3b..760505caf9 100644
--- a/test/output/colorLegendLabelScale.svg
+++ b/test/output/colorLegendLabelScale.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendLinear.svg b/test/output/colorLegendLinear.svg
index 905fccdb6a..2966023882 100644
--- a/test/output/colorLegendLinear.svg
+++ b/test/output/colorLegendLinear.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendLinearTruncatedScheme.svg b/test/output/colorLegendLinearTruncatedScheme.svg
index a235415ce6..e57b73d9fd 100644
--- a/test/output/colorLegendLinearTruncatedScheme.svg
+++ b/test/output/colorLegendLinearTruncatedScheme.svg
@@ -14,7 +14,7 @@
}
-
+
0.0
diff --git a/test/output/colorLegendLog.svg b/test/output/colorLegendLog.svg
index ae34e1fb74..056e328340 100644
--- a/test/output/colorLegendLog.svg
+++ b/test/output/colorLegendLog.svg
@@ -14,7 +14,7 @@
}
-
+
1
diff --git a/test/output/colorLegendLogTicks.svg b/test/output/colorLegendLogTicks.svg
index e10d9a8093..2fec47899a 100644
--- a/test/output/colorLegendLogTicks.svg
+++ b/test/output/colorLegendLogTicks.svg
@@ -14,7 +14,7 @@
}
-
+
1
diff --git a/test/output/colorLegendMargins.svg b/test/output/colorLegendMargins.svg
index 9ea8123f47..66183dae2c 100644
--- a/test/output/colorLegendMargins.svg
+++ b/test/output/colorLegendMargins.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendQuantile.svg b/test/output/colorLegendQuantile.svg
index 841e7f50ae..27ce4ad61e 100644
--- a/test/output/colorLegendQuantile.svg
+++ b/test/output/colorLegendQuantile.svg
@@ -22,7 +22,7 @@
-
+
200
diff --git a/test/output/colorLegendQuantileImplicit.svg b/test/output/colorLegendQuantileImplicit.svg
index 841e7f50ae..27ce4ad61e 100644
--- a/test/output/colorLegendQuantileImplicit.svg
+++ b/test/output/colorLegendQuantileImplicit.svg
@@ -22,7 +22,7 @@
-
+
200
diff --git a/test/output/colorLegendQuantitative.svg b/test/output/colorLegendQuantitative.svg
index 905fccdb6a..2966023882 100644
--- a/test/output/colorLegendQuantitative.svg
+++ b/test/output/colorLegendQuantitative.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendQuantitativeScheme.svg b/test/output/colorLegendQuantitativeScheme.svg
index c28aea018f..438418e60e 100644
--- a/test/output/colorLegendQuantitativeScheme.svg
+++ b/test/output/colorLegendQuantitativeScheme.svg
@@ -14,7 +14,7 @@
}
-
+
0.0
diff --git a/test/output/colorLegendSqrt.svg b/test/output/colorLegendSqrt.svg
index 02f319057d..36f50d537a 100644
--- a/test/output/colorLegendSqrt.svg
+++ b/test/output/colorLegendSqrt.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/colorLegendSqrtPiecewise.svg b/test/output/colorLegendSqrtPiecewise.svg
index 6639b02c10..431e48ecdb 100644
--- a/test/output/colorLegendSqrtPiecewise.svg
+++ b/test/output/colorLegendSqrtPiecewise.svg
@@ -14,7 +14,7 @@
}
-
+
−100
diff --git a/test/output/colorLegendThreshold.svg b/test/output/colorLegendThreshold.svg
index 498d5ecc0c..869606020c 100644
--- a/test/output/colorLegendThreshold.svg
+++ b/test/output/colorLegendThreshold.svg
@@ -25,7 +25,7 @@
-
+
1
diff --git a/test/output/colorLegendThresholdTickSize.svg b/test/output/colorLegendThresholdTickSize.svg
index d6880b06ae..c55d1873a3 100644
--- a/test/output/colorLegendThresholdTickSize.svg
+++ b/test/output/colorLegendThresholdTickSize.svg
@@ -24,7 +24,7 @@
-
+
2.5
diff --git a/test/output/opacityLegend.svg b/test/output/opacityLegend.svg
index b1d687a06d..3050b8e43e 100644
--- a/test/output/opacityLegend.svg
+++ b/test/output/opacityLegend.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/opacityLegendColor.svg b/test/output/opacityLegendColor.svg
index 60fb77723c..52b580b47c 100644
--- a/test/output/opacityLegendColor.svg
+++ b/test/output/opacityLegendColor.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/opacityLegendLinear.svg b/test/output/opacityLegendLinear.svg
index 3cddc5f6e0..04067ef3d7 100644
--- a/test/output/opacityLegendLinear.svg
+++ b/test/output/opacityLegendLinear.svg
@@ -14,7 +14,7 @@
}
-
+
0
diff --git a/test/output/opacityLegendLog.svg b/test/output/opacityLegendLog.svg
index 5cd768520a..34acaf44e7 100644
--- a/test/output/opacityLegendLog.svg
+++ b/test/output/opacityLegendLog.svg
@@ -14,7 +14,7 @@
}
-
+
1
diff --git a/test/output/opacityLegendRange.svg b/test/output/opacityLegendRange.svg
index 1da56374cb..2ba4991003 100644
--- a/test/output/opacityLegendRange.svg
+++ b/test/output/opacityLegendRange.svg
@@ -14,7 +14,7 @@
}
-
+
0.0
diff --git a/test/output/opacityLegendSqrt.svg b/test/output/opacityLegendSqrt.svg
index a52cdf0357..8ba88bebca 100644
--- a/test/output/opacityLegendSqrt.svg
+++ b/test/output/opacityLegendSqrt.svg
@@ -14,7 +14,7 @@
}
-
+
0.0