[IPython-dev] experiment - remote execution of jquery and d3 code into the browser via ipython

Brian Granger ellisonbg@gmail....
Mon Mar 19 19:51:13 CDT 2012


On Mon, Mar 19, 2012 at 5:27 PM, hugo <hugo@continuum.io> wrote:
> ah - interesting, I didn't quite understand it at first.
>
> I think that would work, however in the d3 case, I think performance
> would be an issue, d3 uses callbacks for everything.  for a scatter
> plot, each circle needs at least 2 callbacks, one for x coordinate, one
> for y coordinate, that would be one round trip communication per point!
> for local work, this might be ok, but it probably won't work in a
> traditional client server setup, especially if you get many points.
>
> I think for me - the complexity involved in this is enough to convince
> me that this is the wrong approach.  It was an interesting experiment
> but I'm going to give up on this path, I think a preferable route is to
> implement higher level plots (scatter, lines, image plots, etc..) which
> only take json serialiseable data as args, and then just call those from
> ipython.

I strongly agree with this assessment.  In general we are -1 on adding
new web socket connections and trying to manage Javascript/Python
communications at a fine grained level.  Things like interactive plots
should simply take JSON data at the beginning and they work with it on
the client side.


>>
>> fawce's suggestion sounds very intriguing--make the websockets message
>> passing two-way between python and javascript.  The way I understand the
>> suggestion, what about (in python):
>>
>> def mycallback(d):
>>       return d3.axis(d['x'])
>>
>> d3.selectAll('circle').attr('cx', callback(mycallback));
>>
>> This gets translated to the javascript code:
>>
>> d3.selectAll('circle'.attr('cx', function(){
>> var results= send_message('mycallback', arguments);
>> return interpret_results(results);})
>>
>> send_message sends a message back through websockets to call the
>> mycallback python function with some sort of proxy object d that knows
>> how to generate json messages describing the attribute accesses, etc.
>> In the python side, inside mycallback, d['x'] generates the javascript
>> code to access arguments[0]['x'], so what is passed back is some sort of
>> javascript code like 'd3.axis(arguments[0]['x'])'.  interpret_results
>> then runs this code and returns the result.
>>
>> Thanks,
>>
>> Jason
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev@scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com


More information about the IPython-dev mailing list