Open smacleod opened 8 years ago
I'm definitely in favor of the motivation and concept. Two questions:
One interim solution is not to refactor the ModualServer architecture, but to create a parallel visualization architecture that does this.
To answer your questions:
I've hacked together a Visualizer
class which can use the current VisualizationElement
s as is to inject them into the notebook and render using JS. The only change I needed to make to them was having the JS inject the canvas elements into a specific div I create, rather than the body. This can all be fixed though by the refactoring I layout here, and will only require a small update to the ModualServer
template.
It would be nice to refactor both the front-end javascript and the back-end rendering code of a
VisualizationElement
, so that they aren't coupled as tightly to the Tornado server setup and its template.Motivation
The motivation for this issue is to allow the front-end visualizations written in javascript to be used in situations where the webserver is not needed (or wanted). Examples would include the inside of a Jupyter notebook output cell, or a static HTML page where the data for a model run could be saved statically and replayed.
Current Code
Currently the javascript visualization code makes assumptions about the template it is loaded into, injecting into the body tag. Some of the visualizations also send along canvas commands, rather than data which should be left to the javascript to make use of.
Each individual visualization also uses a
js_code
property to specify initialization code, which must deal with specifying arguments itself.Proposed Changes
js_code
with an initialization function name e.g.ChartModule
, and always pass a provided dictionary as the single argument containing any of the options. This will ensure new modules are written in a way which doesn't make assumptions about the type of front-end environment it will be run in and also allows the tornado webserver or notebook extension to change options as needed (possibly change dimensions?).