probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link

viz fails on Mac OS 10.13 #90

Open JerryLingjieMei opened 6 years ago

JerryLingjieMei commented 6 years ago

When I was trying to run the following code on webppl:

var viz = webpplViz;

//viz.bar(['a','b','c'], [1,2,3])
viz.bar(['a','b','c'], [1,2,3], {fileName: 'bar.svg'})
viz.hist(repeat(4,flip), {fileName: 'hist.svg'})
viz.scatter([1,2,3],[4,5,6], {fileName: 'scatter.svg'})

with command line

webppl src/prior.wppl --require webppl-viz

The webppl interpreter tells me that

/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:18
  return g2D || (g2D = canvas.instance(1,1).getContext('2d'));

The backtraces are as follows:

TypeError: Cannot read property 'getContext' of null
    at context (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:18:44)
    at textMark (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:169:11)
    at Object.itemBounds [as item] (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-scenegraph/src/util/bound.js:259:3)
    at /Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega/src/scene/Bounder.js:36:13
    at Array.forEach (<anonymous>)
    at Bounder.proto.evaluate (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega/src/scene/Bounder.js:35:15)
    at Model.prototype.evaluate (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-dataflow/src/Graph.js:329:16)
    at Builder.proto.evaluate (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega/src/scene/Builder.js:227:26)
    at Model.prototype.evaluate (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-dataflow/src/Graph.js:329:16)
    at Model.prototype.propagate (/Users/jerrymei/.webppl/node_modules/webppl-viz/node_modules/vega-dataflow/src/Graph.js:161:22)

Can you help me with this issue

longouyang commented 5 years ago

Can you tell me what version of Vega your npm is using?

smilli commented 5 years ago

I'm having the same issue; my installation is vega 2.6.5 (with vega-scenegraph 1.1.0).

longouyang commented 5 years ago

What version of the canvas library do you guys have installed? IIRC, there are issues with using anything above 1.6.4.

smilli commented 5 years ago

Ah, yea I was on the latest version of canvas, just switched to 1.6.4 and it started working. Thanks, Long!