Skip to content

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

@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
@cloudflare-workers-and-pages
Copy link

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

Deploying vega-lite with  Cloudflare Pages  Cloudflare Pages

Latest commit: b9d4f17
Status: ✅  Deploy successful!
Preview URL: https://53a88098.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
if (
// Continuous and discrete gradients ignore symbol properties
(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 .

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the new type in vega/vega#3957 . We'll need a new release of vega to happen in order for vega-lite to be able to reference it.

@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
@hydrosquall hydrosquall force-pushed the cameron.yick/check-vega-lite-compile-spec-discrete-legend branch from 79784bc to 70e0e7e Compare January 11, 2025 19:28
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

2 participants