mikedewar / d3py

a plottling library for python, based on D3
1.42k stars 202 forks source link

Server shuts down directly after fig.show() #23

Closed ghost closed 12 years ago

ghost commented 12 years ago

python test.py you can find your chart at http://localhost:8000/basic_example/basic_example.html Shutting down httpd Cleaning temp files

The browser window opens but the server is already shut down.

Source code:

import d3py
import pandas
import numpy as np
# some test data
T = 100
# this is a data frame with three columns (we only use 2)
df = pandas.DataFrame({
    "time" : range(T),
    "pressure": np.random.rand(T),
    "temp" : np.random.rand(T)
})
## build up a figure, ggplot2 style
# instantiate the figure object
fig = d3py.Figure(df, name="basic_example", width=300, height=300) 
# add some red points
fig += d3py.geoms.Point(x="pressure", y="temp", fill="red")
# writes 3 files, starts up a server, then draws some beautiful points in Chrome
fig.show()
mynameisfiber commented 12 years ago

This problem is being addressed in pull request #25. The reason you are seeing this behavior is because right now d3py is meant only to be run in interactive mode. Trying to run a d3py as a script will initiate everything properly, however the fig.show() command will return immediately, then the script is over and the server will be shut down.

The pull request turns interactive mode off by default (issuing a fig.show() will block until terminated by the user), giving the functionality you would expect. If you want to play around in interactive mode, you simply need to do one of the following:

Hope this helps!

PS: I will leave this issue open until the pull request goes through and I can get someone else to verify my solution is correct!

mynameisfiber commented 12 years ago

I'm going to call this issue closed!

mikedewar commented 12 years ago

Howdy all - just a quick update on this issue. I've made it so that by default, interactive is TRUE, so that if you're just nerding about in iTerm it'll behave interactively (with the aim that we are building an exploration tool). However, I've set interactive to FALSE when you use with which isn't very natural for the command line but is super awesome for writing scripts etc.

grkrthk commented 10 years ago

I just installed d3py and trying to execute the example given here "https://github.com/mikedewar/d3py". I am unable to see anything in the browser and I have the following message

grk@ubuntu:~$ python test.py You can find your chart at http://localhost:8000/basic_example.html Shutting down httpd

The above solution didn't help.

mikedewar commented 10 years ago

as you can probably tell, d3py is not an actively maintained project. Please see https://github.com/wrobstory/vincent or maybe http://ggvis.rstudio.com/.