Skip to content

Commit

Permalink
Serialize list of data in Vega spec (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Dec 16, 2019
1 parent a331d61 commit 6b9dd1b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions panel/pane/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def _to_json(cls, obj):
if isinstance(obj, dict):
json = dict(obj)
if 'data' in json:
json['data'] = dict(json['data'])
data = json['data']
if isinstance(data, dict):
json['data'] = dict(data)
elif isinstance(data, list):
json['data'] = [dict(d) for d in data]
return json
return obj.to_dict()

Expand All @@ -83,9 +87,15 @@ def _get_sources(self, json, sources):
sources[name] = ColumnDataSource(data=data)
else:
sources[name] = ColumnDataSource(data=ds_as_cds(data))
data = json.get('data', {}).pop('values', {})
if data:
sources['data'] = ColumnDataSource(data=ds_as_cds(data))
data = json.get('data', {})
if isinstance(data, dict):
data = data.pop('values', {})
if data:
sources['data'] = ColumnDataSource(data=ds_as_cds(data))
elif isinstance(data, list):
for d in data:
sources[d['name']] = ColumnDataSource(data=ds_as_cds(d['values']))



@classmethod
Expand Down

0 comments on commit 6b9dd1b

Please sign in to comment.