作者:军魂永驻1971 | 来源:互联网 | 2023-01-05 17:59
HowdoIconvertabokehcharttoanimagethatIcansendtothewebclientfromdjango?如何将散景图转换为
How do I convert a bokeh chart to an image that I can send to the web client from django?
如何将散景图转换为可以从django发送到Web客户端的图像?
Here's my views.py
这是我的views.py
from bokeh.charts import TimeSeries
def stock_chart(request):
pdata = DataReader('GOOG', 'yahoo', datetime(2015,1,1), datetime(2015,1,15))
xyvalues = pd.DataFrame(dict(
price=pdata['Adj Close'],
Date=pdata.index.values,
))
pt = TimeSeries(xyvalues, index='Date', legend=True,
title=symbol , ylabel='Stock Prices', width=400, height=200)
#fig=pt.savefig()??????????? Here i need to convert pt to an image.
return HttpResponse(fig)
urls.py
urlpatterns = patterns('',
url(r'^stock_chart/$', views.stock_chart, name="stock_chart"),
)
2 个解决方案