panel
panel copied to clipboard
Is there a way to directly call jslink from param?
Right now I have to instantiate panel objects.
import param
import panel as pn
import holoviews as hv
pn.extension()
class Test(param.Parameterized):
alpha = param.Number(default=1, bounds=(0, 1), step=0.01)
def __init__(self, **params):
super(Test, self).__init__(**params)
def view(self):
return hv.Curve(([0, 1, 2], [3, 4, 5]))
def panel(self):
curve = self.view()
slider = pn.panel(self.param["alpha"])
slider.jslink(curve, value="glyph.line_alpha")
return pn.Row(slider, curve)
test = Test()
test.panel()
Param will never introduce any UI specific code, so I've moved this to Panel. We can consider providing a mechanism in Panel though, but probably not as a method on Parameterized, more likely something like pn.jslink.
Right. There shouldn't be a need to instantiate a widget, but the code for this does need to live in Panel, as Param does not even know JS exists!
From the other issue:
import param
import panel as pn
import holoviews as hv
pn.extension()
class Test(param.Parameterized):
alpha = param.Number(default=1, bounds=(0, 1), step=0.01)
def __init__(self, **params):
super(Test, self).__init__(**params)
def view(self):
curve = hv.Curve(([0, 1, 2], [3, 4, 5]))
pn.jslink(self.param["alpha"], curve, value="glyph.alpha")
return curve
test = Test()
test.view()