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

Handle singular data object in Vega model #1201

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions panel/models/vega.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as p from "@bokehjs/core/properties"
import {isArray} from "@bokehjs/core/util/types"
import {HTMLBox, HTMLBoxView} from "@bokehjs/models/layouts/html_box"

export class VegaPlotView extends HTMLBoxView {
Expand Down Expand Up @@ -47,16 +48,18 @@ export class VegaPlotView extends HTMLBoxView {
}

_plot(): void {
if (!this.model.data || !(window as any).vegaEmbed)
const data = this.model.data
if ((data == null) || !(window as any).vegaEmbed)
return
if (this.model.data_sources && (Object.keys(this.model.data_sources).length > 0)) {
const datasets = this._fetch_datasets()
if ('data' in datasets) {
this.model.data.data['values'] = datasets['data']
data.data['values'] = datasets['data']
delete datasets['data']
}
if (this.model.data.data !== undefined) {
for (const d of this.model.data.data) {
if (data.data != null) {
const data_objs = isArray(data.data) ? data.data : [data.data]
for (const d of data_objs) {
if (d.name in datasets) {
d['values'] = datasets[d.name]
delete datasets[d.name]
Expand Down