probmods / webppl-viz

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

"kindPrinter[dfKind] is not a function" for distributions on pairs of integers #68

Closed stuhlmueller closed 7 years ago

stuhlmueller commented 7 years ago

In a previous version of webppl-viz, this code resulted in a table with colored cells:

viz.auto(Infer({ 
  model() {
    return {
      x: randomInteger(2),
      y: randomInteger(2)
    }
  }}));

Now, I get:

kindPrinter[dfKind] is not a function
longouyang commented 7 years ago

I'm slowly (1) transitioning to use just viz and (2) changing the auto layout choices.

So using viz instead of viz.auto works on your example, though it shows a colored bar chart instead of the colored matrix (the new behavior is to show a matrix when a bar chart would be too hard to read -- when each component has more than 5 levels)

stuhlmueller commented 7 years ago

viz doesn't work either for me (running the code on agentmodels, which uses http://cdn.webppl.org/webppl-viz-0.7.10.js).

longouyang commented 7 years ago

Ah, I believe you're hitting a bug that was fixed in b7279208cbb470fa57498bfd44df7b44875b6638 -- try using the latest version on the cdn, webppl-viz-818a17e.js

stuhlmueller commented 7 years ago

Thanks, that worked. Is there any way to still get the colored matrix? For visualizing tic-tac-toe moves, it was a perfect fit.

longouyang commented 7 years ago

For the moment, no, but I think fixing #23 will make the colored matrix possible again.

You'll have to manually pass in the vega spec, something like this:

viz.vegaLite(distribution,
             {
               data: {values: data},
               mark: "text",
               encoding: {
                 row: {field: 'x', type: 'nominal'},
                 column: {field: 'y', type: 'nominal'},
                 color: {field: 'prob', type: 'quantitative'},
                 text: {field: 'prob', type: 'quantitative'}
               },
               config: {mark: {applyColorToBackground: true}, numberFormat: ".1e",
                        scale: {textBandWidth: 40}
                       }
             })