mikedewar / d3py

a plottling library for python, based on D3
1.41k stars 205 forks source link

host agnostic #55

Open andrewcstewart opened 11 years ago

andrewcstewart commented 11 years ago

It'd be nice to let this work on non-localhosts (like ec2 instances). Right now d3py/d3py_template.html has localhost hard coded, ie:

<script type="text/javascript" charset="utf-8" src="localhost:{{ port }}/static/d3.js"></script>',</code>

It would be nice if this was templated to

<script type="text/javascript" charset="utf-8" src="{{ host }}:{{ port }}/static/d3.js"></script>',

...And anywhere else that change would have to be made.

mikedewar commented 11 years ago

yes! This would let us (finally) plot remotely without any X-window forwarding nonsense.

andrewcstewart commented 11 years ago

I'm happy to do the fork. Would that change to d3py_template.html and a couple edits to .show() do it you think?

I was playing around with this on an ec2 hosted notebook and I was getting the strangest behavior. I replaced every instance of 'localhost' I could find with the public IP of the instance but the html generated by d3py still referred to localhost in the url references.

On a possibly related note, 9 times out of 10 running fig.show() would fire up SimpleHTTPServer but then hang the cell.

Perhaps a slightly simpler solution here would be to allow the d3py object to directly print html? Although the json would have to be served some how.

mikedewar commented 11 years ago

I imagine d3py_template and .show() and ._serve() should do it! Don't know what's up with the EC2 instance - let me know when your pull request is ready for review!

We have (or at least, had) a .save() method that might do what you want for the notebook...

andrewcstewart commented 11 years ago

I have it working https://github.com/andrewcstewart/d3py

Once thing I'm not happy about is not being able to run IPython.core.display.HTML inside a function (figure.display()).

mikedewar commented 11 years ago

Make a pull request and we'll get the process going to fold it into the main repo!