Skip to content

Commit f00e7cc

Browse files
authored
fix ramp legend font-variant (#911)
1 parent 82e446c commit f00e7cc

29 files changed

+104
-102
lines changed

src/legends/ramp.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,16 @@ export function legendRamp(color, {
149149
.attr("font-family", null)
150150
.attr("font-variant", impliedString(fontVariant, "normal"))
151151
.call(tickAdjust)
152-
.call(g => g.select(".domain").remove())
153-
.call(label === undefined ? () => {} : g => g.append("text")
154-
.attr("x", marginLeft)
155-
.attr("y", marginTop + marginBottom - height - 6)
156-
.attr("fill", "currentColor") // TODO move to stylesheet?
157-
.attr("text-anchor", "start")
158-
.attr("font-weight", "bold")
159-
.text(label));
152+
.call(g => g.select(".domain").remove());
153+
154+
if (label !== undefined) {
155+
svg.append("text")
156+
.attr("x", marginLeft)
157+
.attr("y", marginTop - 6)
158+
.attr("fill", "currentColor") // TODO move to stylesheet?
159+
.attr("font-weight", "bold")
160+
.text(label);
161+
}
160162

161163
return svg.node();
162164
}

test/output/carsHexbin.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
</g>
2727
<g class="tick" opacity="1" transform="translate(240.5,0)">
2828
<line stroke="currentColor" y2="6" y1="-10"></line><text fill="currentColor" y="9" dy="0.71em">5,000</text>
29-
</g><text x="0" y="-16" fill="currentColor" text-anchor="start" font-weight="bold">weight (lb)</text>
30-
</g>
29+
</g>
30+
</g><text x="0" y="12" fill="currentColor" font-weight="bold">weight (lb)</text>
3131
</svg><svg class="plot-2" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="400" viewBox="0 0 640 400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3232
<style>
3333
.plot-2 {

test/output/carsJitter.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
</g>
2727
<g class="tick" opacity="1" transform="translate(192.5,0)">
2828
<line stroke="currentColor" y2="6" y1="-10"></line><text fill="currentColor" y="9" dy="0.71em">200</text>
29-
</g><text x="0" y="-16" fill="currentColor" text-anchor="start" font-weight="bold">power (hp)</text>
30-
</g>
29+
</g>
30+
</g><text x="0" y="12" fill="currentColor" font-weight="bold">power (hp)</text>
3131
</svg><svg class="plot-2" fill="currentColor" font-family="system-ui, sans-serif" font-size="10" text-anchor="middle" width="640" height="350" viewBox="0 0 640 350" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3232
<style>
3333
.plot-2 {

test/output/colorLegendDiverging.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendDivergingSqrt.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendImplicitLabel.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendLabelBoth.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendLabelLegend.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendLabelScale.svg

Lines changed: 2 additions & 2 deletions
Loading

test/output/colorLegendMargins.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)