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

Support header attribute on facet / row / column encoding channels #763

Closed
markuspeters opened this issue Apr 10, 2024 · 2 comments
Closed

Comments

@markuspeters
Copy link

When creating a faceted Vega Lite plot using the Scala library, I would like to be able to set the facets' header and sort properties to control the title and sort attributes of the facets.

For example, the following plot:

VegaLite.facet(
      jsan"""
      [
        {"class": "square", "color": "red", "v": 28},
        {"class": "square", "color": "green", "v": 55},
        {"class": "round", "color": "green", "v": 17},
        {"class": "round", "color": "blue", "v": 43}
      ]""").
    column(field = "class", `type` = "nominal").
    mark("bar").
    x(field = "color", `type` = "nominal").
    y(field = "v", `type` = "quantitative")

translates to the following column encoding channel:

    "column": {
      "field": "class",
      "center": false,
      "type": "nominal",
      "align": "all"
    }

What I am missing is the ability to additionally express:

    "column": {
      ...
      "align": "all",
      "sort": ["Lesson (regular)", "Lesson (other)"],
      "header": {"title": "Data Class","labelAngle": -90, "labelAlign": "right"}
    }

The Vega Lite page is silent on the availability of the header and sort properties on the facet/row/column encoding channels though at least the header property is later used in the Grid Facet example on the same page, and the Vega Editor interprets both correctly.

I'll be happy to submit a PR if that seems useful.

@haifengl
Copy link
Owner

Added. All changes are in master branch now.

@markuspeters
Copy link
Author

Looks great! Thank you once more for handling this yourself.

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

No branches or pull requests

2 participants