[英]Vega visualization - how to enable actions when using vega view
I am using vega charts in my django project.我在我的 django 项目中使用 vega 图表。 Until now I have used the vegaEmbed to show chart's on web page but now I would like to switch to vega view and I can't found anywhere how to enable actions when using vega view.
到目前为止,我一直使用 vegaEmbed 在 web 页面上显示图表,但现在我想切换到 vega 视图,但在任何地方都找不到如何在使用 vega 视图时启用操作。
This is my code with vegaEmbed:这是我的 vegaEmbed 代码:
`<script>
var {{ c.ident }} = {{ c.jSon|safe }}
var {{ c.ident }}_opt = {
actions: true
}
vegaEmbed('#{{ c.ident }}', {{ c.ident }}, {{ c.ident }}_opt);
vegaEmbed('#{{ c.ident }}', {{ c.ident }});
</script>`
And this code with vega view:这段代码带有 vega 视图:
`<script>
var vegaJson = {{ jSon|safe }};
var view = new vega.View(vega.parse(vegaJson))
.renderer('svg')
.initialize('#chartDiv')
.hover()
.run();
window.onresize = function (event) {
view.signal('width', event.target.innerWidth - 200)
.signal('height', event.target.innerHeight - 450)
.run('enter');
}
</script>`
Any idea how to enable actions when using vega view?知道如何在使用 vega 视图时启用操作吗?
The actions menu is not defined by the vega view API, it is defined within vega-embed.操作菜单不是由 vega 视图 API 定义的,它是在 vega-embed 中定义的。
Here is how vega-embed creates the actions menu. 以下是 vega-embed 如何创建操作菜单。
If you want to avoid using Vega-Embed and you still want an actions menu similar to what Vega-Embed implements, you would have to write similar code in your vega view script.如果你想避免使用 Vega-Embed 并且你仍然想要一个类似于 Vega-Embed 实现的操作菜单,你将不得不在你的 vega 视图脚本中编写类似的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.