Closed puhoshville closed 5 years ago
Fix by changing the function, refresh, into:
def refresh(self, data):
"""Generate a new image, then tell the page to change the src"""
h = hashlib.md5(str(data.__dict__)).hexdigest()
print h
outfile = os.path.join(self.plot_dir, h + "." + self.extension)
if not os.path.exists(outfile):
if self.plotter == "custom":
kwargs["__outfile"] = outfile
if self.plotter == "matplotlib":
from matplotlib import pyplot as plt
plt.clf()
ret = self.plot(data)
if ret is None:
# don't change the plot at all
return {self.name: {}}
# after
if self.plotter == "matplotlib":
plt.savefig(outfile)
elif self.plotter == "ggplot":
ret.save(outfile) ## fixed to updated ggplot save function instead of phased out ggsave function
# turn into a URL, add a dummy param to avoid browser caching
url = outfile.replace(os.path.sep, "/")
url = url + "?dummy=" + str(random.random())
return {self.name: {"src": url}}
For solving this problem I'm reinstall to ggplot v. 0.6.8:
pip remove ggplot
pip install ggplot==0.6.8
Problem is in the lack of
ggsave
function in last versions.