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

Single encoding selector with nearest does not work under specific conditions #9388

Open
1 task done
kgoodrick-uu opened this issue Jul 11, 2024 · 2 comments
Open
1 task done
Labels

Comments

@kgoodrick-uu
Copy link

Bug Description

When a chart is created with a single x encoding, 5 values, and a size of width=250 and height=40, adding a selector with the nearest mode enabled does not allow the 2nd element to be selected. This works fine if wither the height or width are increased/decreased by 1. It also works if one changes the x encoding to y and swaps the width and height.

{
  "data": {"values": [{"x": 1}, {"x": 2}, {"x": 3}, {"x": 4}, {"x": 5}]},
  "mark": {"type": "point"},
  "encoding": {
    "color": {
      "condition": {"param": "x_selector", "value": "green"},
      "value": "grey"
    },
    "x": {"field": "x", "type": "nominal"}
  },
  "params": [
    {
      "name": "x_selector",
      "select": {
        "type": "point",
        "fields": ["x"],
        "nearest": true,
        "on": "click"
      },
      "value": 1
    }
  ],
  "height": 40,
  "width": 250
}

Here is a working example vega-editor. It is possible to select all points by clicking except the 2nd one.

A workaround for this is to use encodings=["x"], but I think it's possible that whatever is causing this could cause other bugs, so worth looking into.

Checklist

  • I checked for duplicate issues.
@kgoodrick-uu
Copy link
Author

kgoodrick-uu commented Jul 11, 2024

This appears to be caused by a bug while creating the Voroni diagram. If you make the stroke visible in the compiled Vega you can see that there is a line through the 2nd point when the width is 250.

image

However, if you change the width to 251 the diagram looks reasonable:

image

Given this I believe that the bug is in Vega, not Vega-Lite, so I have opened another issue in that repository.

@kgoodrick-uu
Copy link
Author

This was fixed upstream in d3/d3-delaunay#147

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

1 participant