Open maartenbreddels opened 7 years ago
We were thinking of having a js container run an arbitrary js transformation specified in a third transform
argument, a bit like in traitlets' link. Security is tricky, but can probably be achieved.
Been discussing with @SylvainCorlay about transformations, Similar to traitlets, would be nice to have:
jsdlink((slider1, 'index'), (floattext, 'value'), transformation='log(value)')
We probably don't want to use eval, so that leave us to choose a library for parsing that: From http://stackoverflow.com/questions/2276021/evaluating-a-string-as-a-mathematical-expression-in-javascript I found these:
Another option I would like to see, is sth similar, but instead of a math transformation, it's is a non-linear mapping, but an option from say a dict:
animation_delay_toggle_button = widgets.ToggleButtons(
options=['None', 'Fast, 'Regular', 'Slow'],
description='Delay:',
)
jsdlink((animation_delay_toggle_button, 'index'), (figure, 'animation_delay'), \
choice={0:0, 1:100, 2:500, 3:1000})
Using a dict it would also be possible to map strings to values.
Having this in jslink would also be nice, but lets wait the discussion/PR here
Hi, sorry for digging up this topic, but I stumbled upon it when i searched for linking between a checkbox and a stack
Do you know if there have been some work on extending jslink, especially with the dict mapping ?
I know I can use the observe
or interactive_output
methods, but these require an active python kernel, and I would like it to be available for static widgets, because the notebook is part of a documentation that gets compiled with sphinx.
For now I'm using ToggleButtons that have an index that I can link with my stack, but having a selector only for 2 values is a bit overkill in my case.
jslink is really useful for having some frontend only communication, however there are more use cases I can think of that would be useful. I wonder if some thought went already into this, if not maybe it is useful to discuss some use cases that could be implemented simply.
jslinkf((widget1, 'value', 'Math.log(value)'), (widget2, 'value', 'Math.exp(value)'
.index
to get the child from the list, and then assign it to a target.jslinkXXX((selector, 'index'), (some_widget, 'children'), (visible_panel_proxy, 'child'))
. I hope this example is clear.scatter.style
changes, you want to linkscatter.style["color"]
tobar.selected_style["color"]
, e.g.jslinkYYY((scatter, 'style', 'color'), (bar, 'selected_style', 'color'))
.