#PAGE放图,这个正常的做就可以了
page = Page(page_title='BI_测试')
page.add(bar3D,c)
page.render('page.html')
#page.render_notebook()
'''<meta name=”viewport” content=”width=device-width, initial-scale=1″ />
做成BI大屏的时候,要把HTML文件改成自适应屏幕,
需要添加上面这个meta,并且所有涉及px的,都需要改成百分比'''
from bs4 import BeautifulSoup
with open("page.html", "r+", encoding='utf-8') as html:
html_bf = BeautifulSoup(html, 'lxml')
meta=html_bf.find('meta')
meta['name']="viewport"
meta['content']="width=device-width, initial-scale=1"
divs = html_bf.select('.chart-container')
divs[0]["style"] = "width:60%;height:80%;position:absolute;top:5%;left:0%;border-style:solid;border-color:#444444;border-width:1%;"
divs[1]['style'] = "width:30%;height:80%;position:absolute;top:5%;left:65%;border-style:solid;border-color:#444444;border-width:1%;"
body = html_bf.find("body")
body["style"] = "background-color:#333333;"
div_title="<div align=\"center\" style=\"width:100%;\">\n<span style=\"font-size:150%;font face=\'黑体\';color:#FFFFFF\"><b>测试0129</b></div>"
#修改页面背景色、追加标题
body.insert(0,BeautifulSoup(div_title,"lxml").div)
html_new = str(html_bf)
html.seek(0, 0)
html.truncate()
html.write(html_new)
html.close()