MCPcopy Create free account
hub / github.com/holoviz/hvplot / __init__

Method __init__

hvplot/ui.py:552–631  ·  view source on GitHub ↗
(self, df, **params)

Source from the content-addressed store, hash-verified

550 return self._layout
551
552 def __init__(self, df, **params):
553 x, y = params.get('x'), params.get('y')
554 if 'y' in params:
555 params['y_multi'] = params.pop('y') if isinstance(params['y'], list) else [params['y']]
556 statusbar_params = {k: params.pop(k) for k in params.copy() if k in StatusBar.param}
557 opts_kwargs = params.pop('opts', {})
558 converter = _hvConverter(
559 df, x, y, **{k: v for k, v in params.items() if k not in ('x', 'y', 'y_multi')}
560 )
561 params['opts'] = opts_kwargs
562 # Collect kwargs passed to the constructor but meant for the controls
563 extras = {k: params.pop(k) for k in params.copy() if k not in self.param}
564 super().__init__(**params)
565 self._data = df
566 self._converter = converter
567 groups = {group: KINDS[group] for group in self._groups}
568 # Create pane for the main controls as done by the Controls instances.
569 self._controls = _create_param_pane(
570 self,
571 parameters=['kind', 'x', 'y', 'groupby', 'by'],
572 widgets_kwargs={'kind': {'options': [], 'groups': groups}},
573 )
574 self.param.watch(self._toggle_controls, 'kind')
575 self.param.watch(self._check_y, 'y_multi')
576 self.param.watch(self._check_by, 'by')
577 self._populate()
578 self._control_tabs = pn.Tabs(tabs_location='left')
579 self.statusbar = StatusBar(**statusbar_params)
580 self._statusbar = pn.Param(
581 self.statusbar, show_name=False, default_layout=pn.Row, margin=(5, 56, 0, 56)
582 )
583 controls = [
584 p.class_
585 for p in self.param.objects().values()
586 if isinstance(p, param.ClassSelector) and issubclass(p.class_, Controls)
587 ]
588 controller_params = {}
589 for cls in controls:
590 controller_params[cls] = {k: extras.pop(k) for k in extras.copy() if k in cls.param}
591 if extras:
592 raise TypeError(f'__init__() got keyword(s) not supported by any control: {extras}')
593 self._controllers = {
594 cls.name.lower(): cls(df, explorer=self, **cparams)
595 for cls, cparams in controller_params.items()
596 }
597 self.param.update(**self._controllers)
598 self.param.watch(self._refresh, list(self.param))
599 for controller in self._controllers.values():
600 controller.param.watch(self._refresh, list(controller.param))
601 self.statusbar.param.watch(self._refresh, list(self.statusbar.param))
602 self._alert = pn.pane.Alert(
603 alert_type='danger', visible=False, sizing_mode='stretch_width'
604 )
605 self._hv_pane = pn.pane.HoloViews(
606 sizing_mode='stretch_both',
607 min_height=250,
608 margin=(5, 5, 5, 20),
609 widget_location='bottom',

Callers

nothing calls this directly

Calls 4

_populateMethod · 0.95
_create_param_paneFunction · 0.85
StatusBarClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected