I should point out that the div is *outside* of the interact.  This is
because when one changes the contents of the interact, it's choppy.
However, if you do all your work in the fixed size div, there's no
choppiness at all, it just suddenly changes.  No flashing, no jumping,
no nothing.  To get this to be usable, we'll need to make it so plots
are somehow registered with the interact.  Ideas?  I'm not sure how to
do this.

On Tue, Feb 24, 2009 at 5:39 PM, William Stein <wst...@gmail.com> wrote:
> On Tue, Feb 24, 2009 at 5:30 PM, Tom Boothby <tomas.boot...@gmail.com> wrote:
>> I've made a little proof-of-concept from the timer interact widget and
>> this -- I think it's pretty awesome:
>>
>> 1) apply  http://sage.math.washington.edu/home/boothby/timer.patch
>> 2) upload jquery.flot_r135.js into the data directory of a worksheet
>> 3) paste the attached into a worksheet (in edit mode)
>> 4) Press "start"
>>
>> Currently, changing more than one @interact widget at a time
>> "forgets", everything but the first. So, to play with the slider while
>> the timer is running, you might have to change the "t=timer(1000)" in
>> the @interact to "t=timer(2000)" or bigger, depending on processor
>> speed / network latency.
>
> For the very lazy, I attached a screenshot.  Imagine the tangent line moving
> along the curve.  Drag the slider to control how smoothly it moves
> (how many steps).
>
> William
>
>>
>> >
>>
>>
>> {{{id=0|
>> def flot(F,x,L):
>>    d = []
>>
>>    for f in F:
>>        d.append([f(t) for t in x])
>>    return "<script>setTimeout(%r)</script>"%flotData(x,d,L)
>>
>> def flotData(xdata, Y, L):
>>
>>    s = 'var splot = ['
>>    s+= ",".join(['{ data:'+str([[a,b] for a,b in zip(xdata,ydata)])+',label: 
>> "'+l+'"}' for ydata,l in zip(Y,L)])
>>    s+= '];'
>>
>>    s+= r"""
>>
>> var options1 = {
>>    crosshair: { mode: "xy", color: "#ff0000" },
>>    lines: { show: true  },
>>    xaxis: { ticks: 6 },
>>    yaxis: { ticks: 4, tickDecimals: 0, min: -2, max:2 },
>>    selection: { mode: "xy" },
>>    grid: { hoverable: true, clickable: true , color: "#999"}
>> };
>>
>>    var placeholdermag = \$("#placeholdermag");
>>    var plotm = \$.plot(placeholdermag, splot, options1);
>> """
>>    return s
>> ///
>> }}}
>>
>> {{{id=4|
>> html("<script src='data/jquery.flot_r135.js'></script>")
>> }}}
>>
>> {{{id=1|
>> from sage.server.notebook.interact import timer
>> from math import sin
>> print html('<div id="placeholdermag" 
>> style="width:750px;height:300px;"></div>')
>>
>> @interact
>> def _(t=timer(1000),steps=(5..100)):
>>    p = 2*float(pi)
>>    t = p*(t%steps)/steps
>>    def f1(s):
>>        return sin(s)
>>    def f2(s):
>>        m = cos(t)
>>        return f1(t) + (s-t)*m
>>
>>    print html(flot([f1,f2],[0,.1,..,p], ["sin(x)","L(x)"] ))
>> }}}
>>
>
>
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to