Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{empty: false} on selection throws Error: Unrecognized signal name: #374

Open
john-guerra opened this issue Jun 18, 2022 · 0 comments
Open

Comments

@john-guerra
Copy link

Adding .empty(false) to a selection throws "Error: Unrecognized signal name:"

See this example

{
  const highlight = vl.selectPoint("highlight").empty(false); //❌
  return vl
    .markRect({ strokeWidth: 2 })
    .select(highlight)
    .encode(
      vl.y().fieldN("actual"),
      vl.x().fieldN("predicted"),
      vl.fill().fieldQ("count"),
      vl.stroke().if(highlight, vl.value("black")).value(null)
    )
    .data(data)
    .config({
      scale: {
        bandPaddingInner: 0,
        bandPaddingOuter: 0
      },
      view: { step: 40 },
      range: {
        ramp: {
          scheme: "yellowgreenblue"
        }
      },
      axis: {
        domain: false
      }
    })
    .render();
}

With VegaLite API v4 one could use .empty("none") for setting the default value of the selection. I built an example for that which doesn't work with v5

Could be related to @arvind merge on Vega-Lite

Possible workaround: adding empty: false in the encoding and not in the selection definition, which was an idea I got reading this discussion between @kanitw and @domoritz. However, using the object there seems wrong...

{
  const highlight = vl.selectPoint("highlight");
  return vl
    .markRect({ strokeWidth: 2 })
    .select(highlight)
    .encode(
      vl.y().fieldN("actual"),
      vl.x().fieldN("predicted"),
      vl.fill().fieldQ("count"),
      vl
        .stroke()
        .condition({ param: "highlight", empty: false, value: "black" }) // ✅
        .value(null)
    )
    .data(data)
    .config({
      scale: {
        bandPaddingInner: 0,
        bandPaddingOuter: 0
      },
      view: { step: 40 },
      range: {
        ramp: {
          scheme: "yellowgreenblue"
        }
      },
      axis: {
        domain: false
      }
    })
    .render();
}

The reference documentation for Vega-Lite-API suggests that one should be able to use .empty(false) regardless of the location...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant