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

interactive geoshape chart doesn't show #679

Closed
iliatimofeev opened this issue Mar 30, 2018 · 5 comments
Closed

interactive geoshape chart doesn't show #679

iliatimofeev opened this issue Mar 30, 2018 · 5 comments

Comments

@iliatimofeev
Copy link
Contributor

Chart(...).mark_geoshape(...)...interactive() generates invalid json that couldn't be shown.

import altair as alt
from vega_datasets import data
#alt.renderers.enable('notebook')

states = alt.topo_feature(data.us_10m.url, feature='states')
# US states background
background = alt.Chart(states).mark_geoshape(
    fill='lightgray',
    stroke='white'
).properties(
    projection={'type': 'albersUsa'},
    width=500,
    height=300)

background.interactive()

Vega Editor shows error

[Error] Error: Expression parse error: " ? {unit: \"\", intervals: []} : null"
[Warning] Cannot project a selection on encoding channel "x", which has no field.
[Warning] Cannot project a selection on encoding channel "y", which has no field.

on this generated json

{"$schema":"https://vega.github.io/schema/vega-lite/v2.3.0.json",
    "width": 500,
    "height": 300,
    "config": {
        "view": {
            "width": 400,
            "height": 300
        }
    },
    "data": {
        "url": "https://vega.github.io/vega-datasets/data/us-10m.json",
        "format": {
            "feature": "states",
            "type": "topojson"
        }
    },
    "mark": {
        "type": "geoshape",
        "fill": "lightgray",
        "stroke": "white"
    },
    "projection": {
        "type": "albersUsa"
    },
 
 -->"selection": {
        "selector010": {
            "type": "interval",
            "bind": "scales",
            "encodings": [
                "x",
                "y"
            ]
        }
    }
  
}
@jakevdp
Copy link
Collaborator

jakevdp commented Mar 30, 2018

Geo markers do not yet support interaction in Vega-Lite. The issue is being tracked here: vega/vega-lite#3306

@jakevdp
Copy link
Collaborator

jakevdp commented Mar 30, 2018

Looking closer, the particular error you're getting is not related to geographic markers; you're asking for interactive x/y encodings, but you've not mapped those encodings to any data. You get the same error with a simpler chart; e.g.

alt.Chart('data.csv').mark_point().interactive()

@iliatimofeev
Copy link
Contributor Author

I expected that interactive() give me a zoomable version of the chart which i can get without it :)

Something like https://vega.github.io/vega/examples/zoomable-world-map/
Or better like https://bl.ocks.org/mbostock/2374239 it works more natural

So i think that for simplicity details like encoding of x or longitude should be hidden from me in that case.

By the way according to documentation { "type": "interval", "bind": "scales" } will be enough to zooming, so adding encoding block in interactive() looks unnecessary.

Another problem that it shows empty cell without any explanation or hints on the causes. I know that it's another issue and is somewhere tracked :) but I lost the link.

@jakevdp
Copy link
Collaborator

jakevdp commented Mar 30, 2018

The zoomable plot you linked to is a vega plot; vega supports interactive geographic scales, but vega-lite does not, so there's no way to make the Altair API create zoomable geographic visualizations. If that is ever supported by vega-lite, then we can think about details of what the Altair API might look like.

Regarding the empty plot: we're working on a solution that will display javascript errors in the notebook in cases like this. See #512 and #666.

@joelostblom
Copy link
Contributor

This will available in Altair after vega/vega-lite#3306 is merged, so closing this as there is nothing to do on the Altair side of things.

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

No branches or pull requests

3 participants