简体   繁体   中英

Vega visualization - how to enable actions when using vega view

I am using vega charts in my django project. 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.

This is my code with 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:

        `<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?

vegaEmbed 中的操作

The actions menu is not defined by the vega view API, it is defined within vega-embed.

Here is how vega-embed creates the actions menu.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM