Skip to content

Commit

Permalink
Merge pull request #14 from holoviz/master
Browse files Browse the repository at this point in the history
Serialize list of data in Vega spec (holoviz#873)
  • Loading branch information
sthagen committed Dec 16, 2019
2 parents 1f4a286 + 6b9dd1b commit 5cc6d93
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions panel/pane/vega.py
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 5cc6d93

Please sign in to comment.