CustomJSTransform on Annotation

Hi. I’m wondering if there is currently a way to drive the parameters of an annotation via CustomJSTransform.

Something like:

main_src = ColumnDataSource({'x':[1,2,3,4]})
#transform that calcs the average x of src
tr = CustomJSTransform(args=dict(src=src)
                       return['x'].reduce((a, b) => a + b, 0) /['x'].length;
sl = Slope(gradient=tr # or transform(field_name='dum',transform=tr) ?? also doesn't work
           ,y_intercept=0, #etc.

Am I missing something obvious? The gradient runs off a singular value (I think that means “non vectorized”), and the transform returns a singular value, but I’m definitely missing something in how to assign the transform to it (or if that is even possible)…


I don’t think it’s currently possible, AFAICT the gradient property just accepts a number. With the move towards glyph-ification [1] this seems like a reasonable thing to support so I’d suggest making a GitHub Issue around supporting transforms for non-vectorized properties. cc @mateusz

  1. goal: “annotation” is something you do with standard objects, not a different class of objects ↩︎

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.