|
112 | 112 |
|
113 | 113 | from .converter import HoloViewsConverter
|
114 | 114 | from .util import (
|
115 |
| - _flatten, is_tabular, is_xarray, is_xarray_dataarray, |
| 115 | + _flatten, bokeh3, is_tabular, is_xarray, is_xarray_dataarray, |
116 | 116 | _convert_col_names_to_str,
|
117 | 117 | )
|
118 | 118 |
|
@@ -709,6 +709,11 @@ def layout(self, **kwargs):
|
709 | 709 | to the center and widget location specified in the
|
710 | 710 | interactive call.
|
711 | 711 | """
|
| 712 | + if bokeh3: |
| 713 | + return self._layout_bk3(**kwargs) |
| 714 | + return self._layout_bk2(**kwargs) |
| 715 | + |
| 716 | + def _layout_bk2(self, **kwargs): |
712 | 717 | widget_box = self.widgets()
|
713 | 718 | panel = self.output()
|
714 | 719 | loc = self._loc
|
@@ -751,6 +756,49 @@ def layout(self, **kwargs):
|
751 | 756 | components = [Column(panel, widgets)]
|
752 | 757 | return Row(*components, **kwargs)
|
753 | 758 |
|
| 759 | + def _layout_bk3(self, **kwargs): |
| 760 | + widget_box = self.widgets() |
| 761 | + panel = self.output() |
| 762 | + loc = self._loc |
| 763 | + center = self._center |
| 764 | + alignments = { |
| 765 | + 'left': (Row, ('start', 'center'), True), |
| 766 | + 'right': (Row, ('end', 'center'), False), |
| 767 | + 'top': (Column, ('center', 'start'), True), |
| 768 | + 'bottom': (Column, ('center', 'end'), False), |
| 769 | + 'top_left': (Column, 'start', True), |
| 770 | + 'top_right': (Column, ('end', 'start'), True), |
| 771 | + 'bottom_left': (Column, ('start', 'end'), False), |
| 772 | + 'bottom_right': (Column, 'end', False), |
| 773 | + 'left_top': (Row, 'start', True), |
| 774 | + 'left_bottom': (Row, ('start', 'end'), True), |
| 775 | + 'right_top': (Row, ('end', 'start'), False), |
| 776 | + 'right_bottom': (Row, 'end', False) |
| 777 | + } |
| 778 | + layout, align, widget_first = alignments[loc] |
| 779 | + widget_box.align = align |
| 780 | + if not len(widget_box): |
| 781 | + if center: |
| 782 | + components = [HSpacer(), panel, HSpacer()] |
| 783 | + else: |
| 784 | + components = [panel] |
| 785 | + return Row(*components, **kwargs) |
| 786 | + |
| 787 | + items = (widget_box, panel) if widget_first else (panel, widget_box) |
| 788 | + sizing_mode = kwargs.get('sizing_mode') |
| 789 | + if not center: |
| 790 | + if layout is Row: |
| 791 | + components = list(items) |
| 792 | + else: |
| 793 | + components = [layout(*items, sizing_mode=sizing_mode)] |
| 794 | + elif layout is Column: |
| 795 | + components = [HSpacer(), layout(*items, sizing_mode=sizing_mode), HSpacer()] |
| 796 | + elif loc.startswith('left'): |
| 797 | + components = [widget_box, HSpacer(), panel, HSpacer()] |
| 798 | + else: |
| 799 | + components = [HSpacer(), panel, HSpacer(), widget_box] |
| 800 | + return Row(*components, **kwargs) |
| 801 | + |
754 | 802 | def holoviews(self):
|
755 | 803 | """
|
756 | 804 | Returns a HoloViews object to render the output of this
|
|
0 commit comments