Hello community,
I am relatively new to Panel, and I’m struggling to understand how to configure objects to lay out my components in the way that I want.
I’m using the react template, and I’m getting unexpected behavior (in my mind, at least) when I assign objects to the main grid. Perhaps I’m misunderstanding how the react template works, but I expected that something like
pn.extension(sizing_mode='stretch_both')
react = pn.template.ReactTemplate()
react.main[:, :6] = obj1
react.main[:, 6:] = obj2
would place obj1 and obj2 in a single row across 6 columns each. However, in practice, these elements sometimes get stacked on top of one another in two rows. See the below minimal example where simply toggling the sidebar between collapsed states causes the objects to reorient in the react grid.
import numpy as np
import pandas as pd
import holoviews as hv
import panel as pn
import param
hv.extension('bokeh')
pn.extension(sizing_mode = 'stretch_both')
class Test(param.Parameterized):
df = param.DataFrame()
def __init__(self, **params):
super(Test, self).__init__(**params)
self.plot()
def plot(self):
N = 8
node_indices = np.arange(N, dtype=np.int32)
source = np.zeros(N, dtype=np.int32)
target = node_indices
simple_graph = hv.Graph(((source, target),))
return simple_graph.opts(responsive=True)
test = Test(df=pd.DataFrame([np.random.randint(0, 100, size=25), np.random.randint(0, 100, size=25)], columns = range(25), index = ['x', 'y']))
react = pn.template.ReactTemplate()
react.sidebar.append(pn.Column())
react.main[:, :6] = test.plot
react.main[:, 6:] = pn.Param(test, parameters = ['df'], widgets = {'df': {'fit_columns': True, 'sizing_mode': 'stretch_both', 'autosize_mode':'fit_columns'}})
react.show()
Can anyone help me better understand how to work with laying out objects in the react grid and controlling their responsive properties (i.e. width, height, aspect, etc.).
Thanks!!