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

Allow for Menu to select a sql expression #298

Open
frtennis1 opened this issue Feb 18, 2024 · 0 comments · May be fixed by #299
Open

Allow for Menu to select a sql expression #298

frtennis1 opened this issue Feb 18, 2024 · 0 comments · May be fixed by #299

Comments

@frtennis1
Copy link
Contributor

The Presidential Opinion example has something that looks a lot like "select a column/sql-expression via this menu and it gets plotted on the chart." This is a really neat feature to have.

However, the way it is implemented (where the Parameter takes on a value of 1 or -1 and a sql expression does a multiplication with the column values) doesn't generalize well to more than two options.

It is already possible to get the "choose between many options" behavior in javascript by setting the options of the menu to the object produced by vg.sql. However, to my knowledge, this is not possible to do via a spec. In a spec, the best you can do is make the options strings, but the strings get quoted as literals, and are not interpreted as column names.

I thought of two ways this could be implemented to work with specs:

  1. The Menu could special-case some key-namespace to interpret as sql (probably in the form of objects that look like {sql: "y_column"})
  2. The spec parser could have some syntax for producing a vg.sql object. I went down this route at first, but it's relatively tricky to get it to work because the menu options are parsed via the completely generic parseOptions creating a LiteralNode with the list of options. So to get this feature would require special-casing in code that is fully generic right now (and the LiteralNode which right now holds an opaque list would have to be further decomposed into nodes).
@frtennis1 frtennis1 linked a pull request Feb 18, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant