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

Area + interval creates a spurious series #1775

Closed
Fil opened this issue Aug 1, 2023 · 1 comment · Fixed by #1837
Closed

Area + interval creates a spurious series #1775

Fil opened this issue Aug 1, 2023 · 1 comment · Fixed by #1837
Labels
bug Something isn’t working

Comments

@Fil
Copy link
Contributor

Fil commented Aug 1, 2023

as reported by @yurivish in https://observablehq.com/d/3264dbb558b44080, the following chart creates a spurious series, with a color (stroke) that is undefined. I've tweaked Yuri’s example to make the issue more visually salient, and to clarify that it is not the mix of z and fill that creates the problem. Inspecting the channels with mark.initialize reveals that the fill channel is ["A", "A"…, "B", "B", ...], but the stroke channel is full of [undefined, undefined…, "A", …, "B", …].

Capture d’écran 2023-08-01 à 11 23 28
Plot.plot({
  marks: [
    Plot.areaY(
      [
        {
          x: 0,
          y: 5,
          type: "B"
        },
        {
          x: 5,
          y: 5,
          type: "B"
        },
        {
          x: 5,
          y: 5,
          type: "A"
        },
        {
          x: 10,
          y: 5,
          type: "A"
        }
      ],
      {
        interval: 1,
        x: "x",
        y: "y",
        fill: "type",
        stroke: "type",
        strokeWidth: 2,
        strokeOpacity: 0.7
      }
    )
  ],
  color: { legend: true }
})
@Fil Fil added the bug Something isn’t working label Aug 1, 2023
@mbostock mbostock changed the title area + interval creates a spurious series Area + interval creates a spurious series Aug 14, 2023
Fil added a commit that referenced this issue Aug 26, 2023
@Fil
Copy link
Contributor Author

Fil commented Aug 26, 2023

to double-check the fix in the notebook above, create this cell:
Plot = import("https://esm.sh/gh/observablehq/plot@5e50056e9be51e3e5622fbf264f5994e953be537")

mbostock added a commit that referenced this issue Aug 26, 2023
* Empty bins fall back on the first element of their group for z, stroke and fill

closes #1775

* test edge case

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
chaichontat pushed a commit to chaichontat/plot that referenced this issue Jan 14, 2024
…q#1837)

* Empty bins fall back on the first element of their group for z, stroke and fill

closes observablehq#1775

* test edge case

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
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