Pyecharts做BI大屏如何自适应屏幕大小

#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()

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值