Skip to content

Error when a continuous color scale is used with a swatches legend? #844

@mbostock

Description

@mbostock

If you pass a continuous color scale to a swatches legend, it’s unlikely to do what you expect:

Screen Shot 2022-04-13 at 11 27 43 AM

Plot.legend({
  legend: "swatches",
  color: {
    type: "linear"
  }
})

You probably want to use a quantize scale instead:

Screen Shot 2022-04-13 at 11 28 44 AM

Plot.legend({
  color: {
    type: "quantize",
    scheme: "turbo"
  }
})

So, should we throw an error if you pass a continuous scale to a swatches legend?

Ref. #827

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions