Skip to content

Spurious error when facet.data is missing #1520

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

Closed
mbostock opened this issue May 2, 2023 · 0 comments · Fixed by #1521
Closed

Spurious error when facet.data is missing #1520

mbostock opened this issue May 2, 2023 · 0 comments · Fixed by #1521
Labels
bug Something isn’t working

Comments

@mbostock
Copy link
Member

mbostock commented May 2, 2023

This Plot previously rendered successfully in Plot 0.6.5, but now crashes with an error:

TypeError: Cannot read properties of undefined (reading 'length')

untitled (72)

Plot.plot({
  y: {
    percent: true,
    label: "Utilization, %"
  },
  grid: true,
  x: {
    label: "Ceph pool"
  },
  facet: {
    x: "Ceph pools usage"
  },
  color: {
    range: ["#16b336", "#f9cb2a", "#b40b0b"],
    type: "quantile",
    domain: [0.3, 0.5, 0.8]
  },
  marks: [
    Plot.barY(percents_data, {
      x: "name",
      y: "value",
      fill: "value",
      sort: { x: "y", reverse: true }
    }),
    Plot.ruleY([0])
  ]
})

The crash is happening here dereferencing data.length:

  // Warn for the common pitfall of wanting to facet mapped data with the
  // top-level facet option.
  if (
    data.length > 0 &&
    (groups.size > 1 || (groups.size === 1 && channels.fx && channels.fy && [...groups][0][1].size > 1)) &&
    arrayify(mark.data)?.length === data.length
  ) {
    warn(
      `Warning: the ${mark.ariaLabel} mark appears to use faceted data, but isn’t faceted. The mark data has the same length as the facet data and the mark facet option is "auto", but the mark data and facet data are distinct. If this mark should be faceted, set the mark facet option to true; otherwise, suppress this warning by setting the mark facet option to false.`
    );
  }
@mbostock mbostock added the bug Something isn’t working label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant