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

hugo hugo@continuum...
Mon Mar 19 19:27:05 CDT 2012

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 

> 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

More information about the IPython-dev mailing list