Exporting ggvis plot with grouped data

2019-02-25 18:24发布

I've experienced a problem when exporting a ggvis plot (by using vg2png).

A simple case works nicely:

library(ggvis)
mtcars %>% ggvis(x = ~hp, y = ~mpg) %>% export_png()

However, if I want to export grouped data, I get the following error:

mtcars %>% ggvis(x = ~hp, y = ~mpg) %>% group_by(cyl) %>% export_png()

/usr/local/lib/node_modules/vega/vega.js:4799
  var tx = vg.data[def.type]();
                            ^
TypeError: Property 'treefacet' of object #<Object> is not a function
    at vg.parse.transform (/usr/local/lib/node_modules/vega/vega.js:4799:29)
    at Array.map (native)
    at Object.vg.parse.dataflow (/usr/local/lib/node_modules/vega/vega.js:4261:34)
    at /usr/local/lib/node_modules/vega/vega.js:4234:27
    at Array.forEach (native)
    at Object.vg.parse.data (/usr/local/lib/node_modules/vega/vega.js:4223:16)
    at parse (/usr/local/lib/node_modules/vega/vega.js:4788:22)
    at Object.vg.parse.spec (/usr/local/lib/node_modules/vega/vega.js:4794:23)
    at Object.vg.headless.render (/usr/local/lib/node_modules/vega/vega.js:7248:12)
    at render (/usr/local/lib/node_modules/vega/bin/vg2png:55:15)

Could you suggest me any solution of this? This issue has bee reported here but still no solution/workaround. Any help will be highly appreciated. Thanks in advance for your help.

Edited

The function export_png exports a PNG or SVG from a ggvis object and requires that the external program vg2png is installed. This is part of the vega node.js module. This information is obtained from ?export_png.

0条回答
登录 后发表回答