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

Expr does not work for guide title #7264

Open
mattijn opened this issue Feb 24, 2021 · 5 comments
Open

Expr does not work for guide title #7264

mattijn opened this issue Feb 24, 2021 · 5 comments

Comments

@mattijn
Copy link
Contributor

mattijn commented Feb 24, 2021

I've the following chart that renders correctly, even though it issues a schema validation warning.

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "url": "https://vega.github.io/vega-lite/data/us-10m.json",
    "format": {"type": "topojson", "feature": "states"}
  },
  "params": [
    {
      "name": "selection",
      "select": {"type": "point", "fields": ["key"]},
      "value": [{"key": "hurricanes"}],
      "bind": {
        "input": "select",
        "options": ["population", "engineers", "hurricanes"]
      }
    }
  ],
  "transform": [
    {
      "lookup": "id",
      "from": {
        "data": {"url": "data/population_engineers_hurricanes.csv"},
        "key": "id",
        "fields": ["population", "engineers", "hurricanes"]
      }
    },
    {"fold": ["population", "engineers", "hurricanes"]},
    {"filter": {"param": "selection"}}
  ],
  "projection": {"type": "albersUsa"},
  "mark": "geoshape",
  "encoding": {
    "color": {
      "field": "value",
      "type": "quantitative",
      "legend": {"title": {"signal": "selection_key"}}
    }
  }
}

signal_legend
The schema validation comes from this line:

"legend": {"title": {"signal": "selection_key"}}

While reading the new docs (congrats again!) I have the feeling that I should be able to replace the signal with an expr, as such:

"legend": {"title": {"expr": "selection"}}

but then the legend title does not render anymore.
expr_legend

Is this something that could/should be supported with an expr?


spec using signal Open the Chart in the Vega Editor

spec using expr Open the Chart in the Vega Editor

@domoritz
Copy link
Member

Done in #7265

@mattijn
Copy link
Contributor Author

mattijn commented Feb 25, 2021

Awesome

@domoritz
Copy link
Member

domoritz commented May 7, 2021

Reopening until the pull request is merged

@domoritz domoritz reopened this May 7, 2021
domoritz added a commit that referenced this issue May 7, 2021
@domoritz domoritz changed the title Expr does not work for legend title Expr does not work for guide title Jun 3, 2021
@liquidcarbon
Copy link

Any update on expr in titles?
I'd like to be able to change Y axis title dynamically

image

@liquidcarbon
Copy link

liquidcarbon commented May 9, 2024

Looks like it's already working in VegaLite, but not yet implemented in Altair.
vega/altair#3417

Correction: it's working but with a warning, as explained in the Altair thread. The true solution is to implement it here on the Vega side.

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

Successfully merging a pull request may close this issue.

3 participants