我一直在寻找方法来做到这一点,但我似乎没有得到任何有用的答案在网上,所以我不得不直接问这里。在
我想要的很简单:处理来自CSV的一些数据,将其绘制成图形并发布到我的HTML中。我不拥有任何网络域,HTML被放在一个共享驱动器中,可以被某些允许使用Chrome的人群查看。在
下面是我的python代码片段:import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from jinja2 import Environment, FileSystemLoader
import plotly as py
import numpy as np
import plotly.tools as plotly_tools
import plotly.plotly as py
from plotly.graph_objs import *
def dashboard_plot_graph():
html_template = __Html_path__.get_template("PublishPG.html")
curr_mcl_res = pd.read_csv(os.path.join(__Result_path__, __Chart_csv__))
print curr_mcl_res.head()
x = curr_mcl_res['TestSuite']
my_plot = curr_mcl_res.plot(x, kind='bar', stacked=True, title='Latest Trend')
fig = my_plot.get_figure()
fig.savefig("./my_img.png")
html_template_vars = {"curr_mcl_div_placeholder": curr_mcl_res.to_html()}
html_out = html_template.render(html_template_vars)
f = open ('file.html', 'w')
f.write( html_out )
f.close()
plt.show()
下面是我的HTML代码片段:
^{pr2}$
这是我希望在我的网页上看到的情节:
我试过:遵循在线教程,似乎说可以把绘图插入到HTML。。。但是失败了。。。我能做的就是
插入数据帧(表),如上面的代码段所示。在
我尝试了一些解决方法,比如将绘制的图形另存为图像,并尝试将图像插入到html中。但它不允许
出于安全原因,从本地驱动器获取映像。它只能
如果我把图片上传到云的某个地方,就拉图片/
web域。但这些数据不适合在任何社交网站上公开
媒体网站。在
有什么建议让我克服这个限制吗?在