Skip to content

The rect mark should be aware of the interval scale option #1863

@mbostock

Description

@mbostock

Related #1511, the rect mark isn’t aware of the interval scale option, so this produces an empty chart:

untitled (87)

Plot.plot({
  x: { interval: 1, tickFormat: "d" },
  y: { interval: 5 },
  color: { type: "log" },
  marks: [
    Plot.rect(causes, {
      x: "year",
      y: "age",
      fill: "mx",
      tip: true
    })
  ]
})

You need to pass the interval option to the rect mark explicitly to get the desired result:

untitled (86)

Plot.plot({
  x: { tickFormat: "d" },
  color: { type: "log" },
  marks: [
    Plot.rect(causes, {
      x: { value: "year", interval: 1 },
      y: { value: "age", interval: 5 },
      fill: "mx",
      tip: true
    })
  ]
})

But, since the plot options are passed to the rect mark during initialization, it should be possible to do this automatically. 🤔

I think this affects maybeIntervalK and maybeIntervalMidK: rather than exclusively creating channel transforms based on the passed-in interval option, we need a mark transform to compute the interval’d channels so that we can look at the plot options.

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