Skip to content

Commit

Permalink
Expose metrics to JS (#4654)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored and mistercrunch committed Apr 3, 2018
1 parent 1ef856e commit ab7ba20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions superset/assets/javascripts/modules/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ def get_metrics(self):

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'),
Expand Down

0 comments on commit ab7ba20

Please sign in to comment.