A SandDance Explorer widget.
| 17 | } |
| 18 | |
| 19 | class Explorer(DOMWidget): |
| 20 | """A SandDance Explorer widget.""" |
| 21 | |
| 22 | # Name of the widget view class in front-end |
| 23 | _view_name = Unicode('SandDanceView').tag(sync=True) |
| 24 | |
| 25 | # Name of the widget model class in front-end |
| 26 | _model_name = Unicode('SandDanceModel').tag(sync=True) |
| 27 | |
| 28 | # Name of the front-end module containing widget view |
| 29 | _view_module = Unicode(module_name).tag(sync=True) |
| 30 | |
| 31 | # Name of the front-end module containing widget model |
| 32 | _model_module = Unicode(module_name).tag(sync=True) |
| 33 | |
| 34 | _view_module_version = Unicode(module_version).tag(sync=True) |
| 35 | _model_module_version = Unicode(module_version).tag(sync=True) |
| 36 | |
| 37 | data = Unicode(defaults['data']).tag(sync=True) |
| 38 | |
| 39 | width = Unicode(defaults['width']).tag(sync=True) |
| 40 | height = Unicode(defaults['height']).tag(sync=True) |
| 41 | snapshots = List([]).tag(sync=True) |
| 42 | pyversion = Unicode(__version__).tag(sync=False) |
| 43 | |
| 44 | def show(self, **kwargs): |
| 45 | self.width = kwargs.get('width', defaults['width']) |
| 46 | self.height = kwargs.get('height', defaults['height']) |
| 47 | display(self) |
| 48 | |
| 49 | def load(self, df): |
| 50 | self.load_dataframe(df) |
| 51 | |
| 52 | def load_dataframe(self, df): |
| 53 | self.data = df.to_json(orient='records') |
| 54 | |
| 55 | def load_records(self, records): |
| 56 | self.data = json.dumps(records) |