本文整理汇总了TypeScript中vega-embed.vega类的典型用法代码示例。如果您正苦于以下问题:TypeScript vega类的具体用法?TypeScript vega怎么用?TypeScript vega使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vega类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: vegaEmbed
return this._resolver.getDownloadUrl(path).then(baseURL => {
const loader = vega.loader({
baseURL,
http: { credentials: 'same-origin' }
});
const options: EmbedOptions = {
actions: true,
defaultStyle: true,
...embedOptions,
mode,
loader
};
const el = document.createElement('div');
this.node.innerHTML = ''; // clear the output before attaching a chart
this.node.appendChild(el);
return vegaEmbed(el, data, options).then(result => {
// Add png representation of vega chart to output
if (!model.data['image/png']) {
return result.view.toImageURL('png').then(imageData => {
const data = { ...model.data, 'image/png': imageData.split(',')[1] };
model.setData({ data });
});
}
return void 0;
});
});
示例2: vegaEmbed
return this._resolver.getDownloadUrl(path).then(baseURL => {
const loader = vega.loader({ baseURL });
const options = {
mode,
loader,
actions: true
};
return vegaEmbed(this.node as HTMLBaseElement, data, options).then(result => {
// Add png representation of vega chart to output
if (!model.data['image/png']) {
return result.view.toImageURL('png').then(imageData => {
const data = { ...model.data, 'image/png': imageData.split(',')[1] };
model.setData({ data });
});
}
return void 0;
}).catch(error => {
// Add stderr message to output
const stderr = `Javascript Error: ${error.message}. This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.`;
const data = { 'application/vnd.jupyter.stderr': stderr };
model.setData({ data });
// Manually append stderr message to output and modify node attributes
this.node.innerHTML = `<pre>Javascript Error: ${error.message}. This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.</pre>`;
this.addClass('jp-RenderedText');
this.removeClass(VEGA_COMMON_CLASS);
this.node.setAttribute('data-mime-type', 'application/vnd.jupyter.stderr');
return void 0;
});
});
示例3: vegaEmbed
return this._resolver.getDownloadUrl(path).then(baseURL => {
const loader = vega.loader({ baseURL });
const options = {
actions: true,
...embedOptions,
mode,
loader
};
return vegaEmbed(this.node as HTMLBaseElement, data, options).then(result => {
// Add png representation of vega chart to output
if (!model.data['image/png']) {
return result.view.toImageURL('png').then(imageData => {
const data = { ...model.data, 'image/png': imageData.split(',')[1] };
model.setData({ data });
});
}
return void 0;
});
});