Skip to content

Unable to combine legends when using line mark with "point": true or separate line and point layers #9748

@labkey-alan

Description

@labkey-alan

Bug Description

Repro for the bug can be found on this vega editor url.

My spec, minus the data, looks like:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v6.json",
  "data": {
    "values": []
  },
  "mark": {"type": "line", "point": true},
  "encoding": {
    "x": {
      "field": "maxSpeed.value",
      "type": "quantitative",
      "title": "Max Speed"
    },
    "y": {
      "field": "weight.value",
      "type": "quantitative",
      "title": "Weight"
    },
    "color": {
      "field": "type.value",
      "type": "nominal",
      "title": "Type",
      "legend": {"title": "Type", "type": "symbol"}
    },
    "shape": {
      "field": "type.value",
      "type": "nominal",
      "title": "Type",
      "legend": {"title": "Type"}
    }
  }
}

With the above spec I would expect the legend to have one section "Type" and to include one legend value per type, with the color and shape represented per value on the legend:

Image

However, what I get are two distinct legends, one for the shape, and one for the color. If I change the mark to use point like so:

"mark": { "type": "point" },

I get a properly combined legend:

Image

Checklist

  • I checked for duplicate issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions