sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.17k stars 216 forks source link

the coordinates in clickable interacts are wrong #1459

Closed williamstein closed 1 week ago

williamstein commented 7 years ago

Put this code in a worksheet, then observe the coordinates -- they don't match:

@interact
def f0(fun=x*sin(x^2), mousemove='', click='(0,0)'):
    click = sage_eval(click)
    g = plot(fun, (x,0,5), zorder=0) + point(click, color='red', pointsize=100, zorder=10)
    ymax = g.ymax(); ymin = g.ymin()
    m = fun.derivative(x)(x=click[0])
    b =  fun(x=click[0]) - m*click[0]
    g += plot(m*x + b, (click[0]-1,click[0]+1), color='red', zorder=10)
    def h(p):
        f0.mousemove = p
    def c(p):
        f0(click=p)
    show(g, events={'click':c, 'mousemove':h}, svg=True, gridlines='major', ymin=ymin, ymax=ymax)

as you can see (the mouse cursor isn't visible, but the y-coordinate is clearly not 22...!):

screen shot 2017-01-07 at 2 58 21 am
williamstein commented 7 years ago

@rbeezer

williamstein commented 7 years ago

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2017-01-07-clickable-interacts.sagews

williamstein commented 1 month ago

Tagging this as wontfix, because it will be fixed indirectly by creating a sage worksheet style mode (and kernel) for Jupyter notebooks. That will be https://github.com/sagemathinc/cocalc/issues/6374.

In this case ipywidgets will then get used and it has correct coordinates for clicking built in.

WORKAROUND: use jupyter with ipywidgets