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

Altair/Vega Chart from GeoDataFrame not rendering in Panel #1323

Closed
nels opened this issue May 6, 2020 · 0 comments · Fixed by #1359
Closed

Altair/Vega Chart from GeoDataFrame not rendering in Panel #1323

nels opened this issue May 6, 2020 · 0 comments · Fixed by #1359
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@nels
Copy link

nels commented May 6, 2020

hi,

I have an Altair chart with GeoShape marks from a GeoDataFrame.
It renders correctly on it's own in a Jupyter notebook.
However, it fails to render when inside a Panel pane.

Simple to reproduce in a notebook:

import csv
from io import StringIO
import panel as pn
import altair as alt
from geopandas import GeoDataFrame
from shapely.geometry import box
pn.extension('vega')

some dummy data

csv_data = 'i,bid,minx,maxx,miny,maxy\n0,SR01-01,20.0,120.0,855.0,925.0\n1,SR02-02,20.0,120.0,940.0,1010.0\n2,SR03-03,140.0,240.0,940.0,1010.0\n3,SR04-04,260.0,360.0,940.0,1010.0\n4,SR05-05,380.0,480.0,940.0,1010.0\n5,SR06-06,500.0,600.0,940.0,1010.0\n6,SR07-07,620.0,720.0,940.0,1010.0\n7,SR08-08,740.0,840.0,940.0,1010.0\n8,SR09-09,860.0,960.0,940.0,1010.0\n9,SR10-10,860.0,960.0,855.0,925.0\n10,BY01-11,625.0,725.0,730.0,800.0\n11,BY01-12,745.0,845.0,730.0,800.0\n12,BY01-14,865.0,965.0,730.0,800.0\n13,BY01-16,625.0,725.0,645.0,715.0\n14,BY01-15,745.0,845.0,645.0,715.0\n15,BY02-17,745.0,845.0,520.0,590.0\n16,BY02-18,865.0,965.0,520.0,590.0\n17,BY02-21,625.0,725.0,435.0,505.0\n18,BY02-20,745.0,845.0,435.0,505.0\n19,BY02-19,865.0,965.0,435.0,505.0\n20,BY03-22,745.0,845.0,310.0,380.0\n21,BY03-23,865.0,965.0,310.0,380.0\n22,BY03-26,625.0,725.0,225.0,295.0\n23,BY03-25,745.0,845.0,225.0,295.0\n24,BY03-24,865.0,965.0,225.0,295.0\n25,BY04-27,625.0,725.0,100.0,170.0\n26,BY04-28,745.0,845.0,100.0,170.0\n27,BY04-29,865.0,965.0,100.0,170.0\n28,BY04-31,625.0,725.0,15.0,85.0\n29,BY04-30,745.0,845.0,15.0,85.0\n30,BY05-36,20.0,120.0,180.0,250.0\n31,BY05-35,20.0,120.0,95.0,165.0\n32,BY05-34,20.0,120.0,10.0,80.0\n33,BY05-33,140.0,240.0,10.0,80.0\n34,SR32-32,375.0,475.0,10.0,80.0\n'

into a GeoDataFrame

gxs = [{'bid': x['bid'], 
        'polygon': box(float(x['minx']), float(x['miny']), float(x['maxx']), float(x['maxy']))} 
       for x in csv.DictReader(StringIO(csv_data))]
gdf = GeoDataFrame(gxs)
gdf = gdf.set_geometry('polygon')

chart

bays = alt.Chart(gdf).mark_geoshape(
        fill='lightgray',
        stroke='white',
    ).properties(
        width=800,
        height=600
    ).project(type='identity', reflectY=True)
bays

renders
visualization

pn.pane.Vega(bays)
no output
JS Console:
TypeError: undefined has no properties in [main.min.js:396:2301]

pn.Row(bays)
also no output
JS Console:
TypeError: undefined has no properties in [main.min.js:396:2301]

Important
GeoShape marks render correctly when the data is not from a GeoDataFrame, for instance this example renders correctly when wrapped in a pd.Row and does not produce JS Console errors.

Environment
Firefox Developer 76
Python 3.8
Libs
altair==4.1.0
bokeh==2.0.2
geopandas==0.7.0
jupyter-client==6.1.3
notebook==6.0.3
panel==0.9.5

No error messages from Jupyter.

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label May 6, 2020
@philippjfr philippjfr added this to the v0.10.0 milestone May 19, 2020
@philippjfr philippjfr modified the milestones: v0.10.0, v0.9.6 Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants