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

Title alignment seems inconsistent #3531

Open
kanitw opened this issue Jul 7, 2022 · 3 comments
Open

Title alignment seems inconsistent #3531

kanitw opened this issue Jul 7, 2022 · 3 comments
Labels
bug For bugs or other software errors

Comments

@kanitw
Copy link
Member

kanitw commented Jul 7, 2022

I'm using Vega-Lite spec to demonstrate the problem, but the issue is from the underlying title layout in Vega.

  • Title with middle anchor is middle of the plotting view:

image

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": {"text": "A Simple Chart", "anchor": "middle"}, 
  "data": { 
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43},
      {"a": "D", "b": 91},
      {"a": "E", "b": 81},
      {"a": "F", "b": 53},
      {"a": "G", "b": 19},
      {"a": "H", "b": 87},
      {"a": "I", "b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "nominal"},
    "y": {"field": "b", "type": "quantitative"}
  }
}

However, changing anchor to "start" is the aligned to the whole canvas:

image

Users may want an option to align to the start of the plotting "view" as well.

@kanitw kanitw added the bug For bugs or other software errors label Jul 7, 2022
@nsajko
Copy link

nsajko commented Jul 20, 2022

I think that "frame": "group" does what you want: https://vega.github.io/vega/docs/title/

@allisonwhilden
Copy link

Ahh. That does appear to work for me. Thanks!

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": {"text": "A Simple Chart", "frame": "group", "anchor": "start"}, 
  "data": { 
    "values": [
      {"a": "A", "b": 28},
      {"a": "B", "b": 55},
      {"a": "C", "b": 43},
      {"a": "D", "b": 91},
      {"a": "E", "b": 81},
      {"a": "F", "b": 53},
      {"a": "G", "b": 19},
      {"a": "H", "b": 87},
      {"a": "I", "b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "nominal"},
    "y": {"field": "b", "type": "quantitative"}
  }
}

image

@joelostblom
Copy link
Contributor

Would it make sense if the default was "frame": "group" for all values of anchor instead of that it changes depending on if anchor is "middle" or "left"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For bugs or other software errors
Projects
None yet
Development

No branches or pull requests

4 participants