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: preserve gradientLength when generating discrete gradient color legend #9400

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hydrosquall
Copy link
Member

@hydrosquall hydrosquall commented Jul 31, 2024

Motivation

Testing

  • Check in sandbox: the gradientLength property should be respected for a color legend that uses quantile, quantize, or threshold scales.
  • Try changing gradientLength to 300, and the legend should get taller.
  • Contrast with the production vega lite editor, changing the gradientLength won't do anything.
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {"url": "data/cars.json"},
  "mark": "rect",
  "encoding": {
    "y": {"field": "Origin", "type": "nominal"},
    "x": {"field": "Cylinders", "type": "ordinal"},
    "color": {
      "aggregate": "mean",
      "field": "Horsepower",
      "scale": {"type": "quantile"},
      "legend": {"gradientLength": 30}
    }
  },
  "config": {"axis": {"grid": true, "tickBand": "extent"}}
}
  • See also baseline unit test: f13f69f

Notes

  • I temporarily patched the type in vega-lite so this PR can be reviewed. However, we could make the diff in this repo smaller if we instead push a change to the LegendType field inside of vega instead.

@hydrosquall hydrosquall self-assigned this Jul 31, 2024
@hydrosquall hydrosquall force-pushed the cameron.yick/check-vega-lite-compile-spec-discrete-legend branch from c6fd282 to c158c80 Compare July 31, 2024 18:29
Copy link

cloudflare-workers-and-pages bot commented Jul 31, 2024

Deploying vega-lite with  Cloudflare Pages  Cloudflare Pages

Latest commit: 79784bc
Status: ✅  Deploy successful!
Preview URL: https://8cf42480.vega-lite.pages.dev
Branch Preview URL: https://cameron-yick-check-vega-lite.vega-lite.pages.dev

View logs

@hydrosquall hydrosquall changed the title Cameron.yick/check vega lite compile spec discrete legend fix: Preserve gradientLength when generating discrete gradient color legend Jul 31, 2024
@hydrosquall hydrosquall changed the title fix: Preserve gradientLength when generating discrete gradient color legend fix: preserve gradientLength when generating discrete gradient color legend Jul 31, 2024
(legendType === 'gradient' && property.startsWith('symbol')) ||
(legendType === 'discrete' && property.startsWith('symbol')) ||
Copy link
Member Author

@hydrosquall hydrosquall Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before I add any tests or open PRs in vega, I want to check if this is the behavior (a third legendType called discrete) we want as a public API, or if this was supposed to be a private/internal API.

The discrete legend type was added by @jheer in vega/vega@ddd2bbf , so I'll bring it up as a separate issue in the vega repo vega/vega#3954 .

@hydrosquall hydrosquall force-pushed the cameron.yick/check-vega-lite-compile-spec-discrete-legend branch from 9fe4a63 to f13f69f Compare July 31, 2024 18:59
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.

Support gradientLength for quantile and quantize color scales
1 participant