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

Minor visual bug: Bars rendering on top of axis #9514

Open
1 task done
s-h-a-d-o-w opened this issue Jan 24, 2025 · 8 comments
Open
1 task done

Minor visual bug: Bars rendering on top of axis #9514

s-h-a-d-o-w opened this issue Jan 24, 2025 · 8 comments
Labels

Comments

@s-h-a-d-o-w
Copy link

Bug Description

While testing, it looked like this usually happens with horizontal graphs.

But it seems to me that axis should generally be rendered after the bars anyway? Especially since precise positioning might sometimes/often not be possible due to anti-aliasing? But I'm not deeply familiar with vega, so maybe there are reasons to not try to resolve it like that.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": 400,
  "height": 200,
  "data": {
    "values": [
      {"y": "a", "x": 608},
      {"y": "b", "x": 980},
    ]
  },
  "mark": {"type": "bar", "orient": "horizontal"},
  "encoding": {
    "x": {
      "field": "x",
      "type": "quantitative",
      "title": ""
    },
    "y": {
      "field": "y",
      "type": "nominal",
      "title": ""
    },
    "color": {
      "field": "y",
      "type": "nominal",
      "legend": null
    }
  }
}

https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQAdxoATemgAsABh1L4NMljQAmPUrVJMKVKGJJBDOBDQBtUAE80IFEoAeaABsOgAcAL4KXj5MiiCBqACcoTrhALqRIMgATgDWaKCYnjhwMUjZcWzZNHCymD4wVTQAXnI2giCZtVBsajSyZAXxQwBmNYJqPoFKRSU+AI4MSHV01jSkcZh0gqXonUrediBjcBM+3jPFuyCybAj9jpvb1-sgPYJVo+OT6Bcgs9dbvdZI8lDsyLUfrIGIJBOF4UA

Checklist

  • I checked for duplicate issues.
@PBI-David
Copy link
Contributor

PBI-David commented Jan 24, 2025

This is the Vega default. It can be changed easily enough with a zindex in the spec. For some reason, x and y axes behave differently and should probably be made consistent.

Image


{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": 400,
  "height": 200,
  "data": {"values": [{"y": "a", "x": 608}, {"y": "b", "x": 980}]},
  "mark": {"type": "bar", "orient": "horizontal"},
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "title": ""},
    "y": {"field": "y", "type": "nominal", "title": "", "axis":{"zindex": 1}},
    "color": {"field": "y", "type": "nominal", "legend": null}
  }
}

Defaults in Vega (note the difference between the two)

Image

Image

@s-h-a-d-o-w
Copy link
Author

Oh, that's awesome to know that one can change the render order like that!

(But I agree that it would be great for the default behavior being fixed, even though I'm alright with the workaround.)

@PBI-David
Copy link
Contributor

@domoritz perhaps move this to Vega?

@s-h-a-d-o-w
Copy link
Author

A downside that I just noticed with the workaround is - one can't just put zindex on all axis as a default because that will also drag the division lines in the background to the top.

@PBI-David
Copy link
Contributor

Good point. It looks related to this here: #5151

@PBI-David
Copy link
Contributor

@s-h-a-d-o-w in the meantime as a quick workaround, set an axis offset.


{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": 400,
  "height": 200,
  "data": {"values": [{"y": "a", "x": 608}, {"y": "b", "x": 980}]},
  "mark": {"type": "bar", "orient": "horizontal"},
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "title": ""},
    "y": {"field": "y", "type": "nominal", "title": "", "axis":{ "offset":1}},
    "color": {"field": "y", "type": "nominal", "legend": null}
  }
}

@s-h-a-d-o-w
Copy link
Author

Thank you very much but I only pointed out the above in case it might impact how this will be resolved or for the sake of other people.

(For my use case, the zindex solution is better, since I don't need to put it on both axis and the axis offset would cause the graph to look a bit broken.)

@PBI-David
Copy link
Contributor

I agree. I think this should be moved to Vega so that axis domains and grid lines can have different z indexes. As a new user, I would find the current behaviour a bit non-intuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants