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

fix: make timeUnitBandPosition work with timeUnit on color #9169

Merged
merged 4 commits into from Nov 10, 2023

Conversation

fandu-db
Copy link
Contributor

@fandu-db fandu-db commented Nov 9, 2023

The problem

Chart's color is broken when timeUnitBandPosition and a temporal color are used together
image

Minimum repro:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"url": "data/stocks.csv"},
  "mark": {"type": "bar"},
  "encoding": {
    "x": {"field": "symbol", "type": "nominal"},
    "y": {"aggregate": "mean", "field": "price", "type": "quantitative"},
    "color": {"timeUnit": "year", "field": "date"}
  },
  "config": {"bar": {"timeUnitBandPosition": 0}}
}

Root cause

We are checking isRectWithOffset inconsistently
In data/aggregate.ts
isRectBasedMark(mark) && bandPosition !== 0.5 && isXorY(channel)

In scale/domain.ts
isRectBasedMark(mark) && bandPosition !== 0.5

That leads to the Vega spec trying to access a derived field that does not exist
image

Solution in this PR:
Added the missing && isXorY(channel) to domain.ts

AFTER

image

@kanitw kanitw merged commit 3e0f312 into main Nov 10, 2023
9 checks passed
@kanitw kanitw deleted the fdu/fix-isRectWithOffset branch November 10, 2023 00:44
@fandu-db fandu-db changed the title fix: make isRectWithOffset check consistent fix: make timeUnitBandPosition work with timeUnit on color Nov 10, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants