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

point selection is not working #407

Open
diegozea opened this issue Oct 15, 2021 · 2 comments
Open

point selection is not working #407

diegozea opened this issue Oct 15, 2021 · 2 comments

Comments

@diegozea
Copy link

Hi! I was trying the examples on Vega-Lite documentation, and I have found that this example works fine with interval but it doesn't work with point using VegaLite:

using ElectronDisplay
using VegaLite, VegaDatasets

data = dataset("cars")
julia> data |> @vlplot(:rect, x="Cylinders:o", y="Origin", 
           selection={pts={type="interval"}},
           color={condition={
               selection="pts",
               aggregate="count"
           }, value="grey"})

julia> data |> @vlplot(:rect, x="Cylinders:o", y="Origin", 
           selection={pts={type="point"}},
           color={condition={
               selection="pts",
               aggregate="count"
           }, value="grey"})
Gtk-Message: 19:17:09.779: GtkDialog mapped without a transient parent. This is discouraged.

Screenshot from 2021-10-15 19-17-55

Julia 1.6.2 & Ubuntu:

  [a93c6f00] DataFrames v1.2.2
  [d872a56f] ElectronDisplay v1.0.1
  [1a8c2f83] Query v1.0.0
  [efcf1570] Setfield v0.7.1
  [239c3e63] Vega v2.3.0
  [0ae4a718] VegaDatasets v2.1.1
  [112f6efa] VegaLite v2.6.0

P.S.: I am finding it hard to use VegaLite interactivity with @vlplot following the params documentation of Vega-Lite. It would be awesome to have a section on interactivity in the VegaLite.jl docs :)

@jeremiahpslewis
Copy link
Contributor

Hey!

Just a few thoughts on debugging this:

  1. It can be helpful to export the plot to a 'vegalite' json spec and check whether that is properly formatted by running it in-browser here

You can do this by appending |> save("test_plot.vegalite") to either of your plots

  1. The plot works fine in-browser, so it's not your code and it's not the spec, it's a rendering issue on the package side.

  2. You can get a more informative error message by trying to export your plot to a png, by appending |> save("test.png") to the plot that isn't working. This takes electron, etc. out of the picture.

  3. If you do so, one gets the more informative, but still cryptic error message

Reprex:

data |> @vlplot(:rect, x="Cylinders:o", y="Origin",
                  selection={pts={type="point"}},
                  color={condition={
                      selection="pts",
                      aggregate="count"
                  }, value="grey"}) |> save("test.png")
TypeError: Cannot destructure property 'fields' of 'selectionConfig[selDef.type]' as it is undefined.
    at parseUnitSelection (/Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/node_modules/vega-lite/build/vega-lite.js:13924:9)
    at UnitModel.parseSelections (/Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/node_modules/vega-lite/build/vega-lite.js:25031:34)
    at UnitModel.parse (/Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/node_modules/vega-lite/build/vega-lite.js:20643:12)
    at Object.compile (/Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/node_modules/vega-lite/build/vega-lite.js:25305:13)
    at compile (/Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/vl2vg.js:18:27)
    at /Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/vl2vg.js:32:19
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /Users/jeremiahlewis/.julia/artifacts/07b35f566ff32f265444804e50108d7f7f217576/node_modules/vega-cli/src/render.js:62:31
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Errors encountered while save FileIO.File{FileIO.DataFormat{:PNG}, String}("test.png").

I think this likely indicates that we're hitting a Vega-lite js bug which is fixed in version 5.1.1 (browser version), but is present in 3.0.11, the version of Vega-lite which this package currently uses. See here. Unfortunately, binaries are still a pain point in this package which is otherwise astoundingly useful and fun for getting a nice plot on a page (and for < makie.jl scale datasets).

Sorry I can't provide a cure ATM, but hope the diagnosis is useful / accurate. ;)

@diegozea
Copy link
Author

Thanks!

I can see the same error on my computer.

TypeError: Cannot destructure property 'fields' of 'selectionConfig[selDef.type]' as it is undefined.
    at parseUnitSelection (/home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/node_modules/vega-lite/build/vega-lite.js:13924:9)
    at UnitModel.parseSelections (/home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/node_modules/vega-lite/build/vega-lite.js:25031:34)
    at UnitModel.parse (/home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/node_modules/vega-lite/build/vega-lite.js:20643:12)
    at Object.compile (/home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/node_modules/vega-lite/build/vega-lite.js:25305:13)
    at compile (/home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/vl2vg.js:18:27)
    at /home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/vl2vg.js:32:19
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /home/diego/.julia/artifacts/f22a465460a987b8219c0c4c44b4a94e443a9a4c/node_modules/vega-cli/src/render.js:62:31
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

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