Expose metrics to JS (#4654)

This commit is contained in:
Beto Dealmeida 2018-04-02 17:48:56 -07:00 committed by Maxime Beauchemin
parent 1ef856e57a
commit ab7ba20009
2 changed files with 7 additions and 2 deletions

View File

@ -22,6 +22,10 @@ export default function sandboxedEval(code, context, opts) {
Object.keys(sandboxContext).forEach(function (key) {
sandbox[key] = sandboxContext[key];
});
vm.runInNewContext(codeToEval, sandbox, opts);
return sandbox[resultKey];
try {
vm.runInNewContext(codeToEval, sandbox, opts);
return sandbox[resultKey];
} catch (error) {
return () => error;
}
}

View File

@ -2048,6 +2048,7 @@ class DeckScatterViz(BaseDeckGLViz):
def get_properties(self, d):
return {
'metric': d.get(self.metric),
'radius': self.fixed_value if self.fixed_value else d.get(self.metric),
'cat_color': d.get(self.dim) if self.dim else None,
'position': d.get('spatial'),