Skip to content

Commit f542d8f

Browse files
authored
An external legend should carry the label from the chart, whether explicit or implicit (#607)
closes #605
1 parent e999678 commit f542d8f

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

src/legends/ramp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {interpolatePiecewise} from "../scales/quantitative.js";
33
import {applyInlineStyles, maybeClassName} from "../style.js";
44

55
export function legendRamp(color, {
6-
label,
6+
label = color.label,
77
tickSize = 6,
88
width = 240,
99
height = 44 + tickSize,
Lines changed: 34 additions & 0 deletions
Loading

test/plots/legend-color.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ export function colorLegendQuantileImplicit() {
204204
}).legend("color");
205205
}
206206

207+
export function colorLegendImplicitLabel() {
208+
return Plot.plot({
209+
color: {scheme: "viridis"},
210+
marks: [Plot.dot(d3.range(100).map(i => ({thing: i})), {fill: "thing"})]
211+
}).legend("color");
212+
}
213+
207214
export function colorLegendDiverging() {
208215
return Plot.legend({
209216
color: {

0 commit comments

Comments
 (0)