用pyecharts做图表大屏展示

效果是这个样子,就是一个交互的图表集成展示
在这里插入图片描述
先把你自己画的所有图片添到里page() ,Page记得要导入一下和Bar,Pie那些pyecharts.charts类里。(画图的代码就省略了太多了,我这里就是举个例子)。把我add的这些图换成你自己。

page = (Page().add(pie1).add(pie2).add(pie3).add(pie4).add(pie5).add(pie6)
        .add(pie7).add(pie8).add(pie9).add(pie10).add(pie11).add(pie12).add(pie13).add(pie14).add(pie15)
        .add(line1).add(bar1).add(bar2)
       )
page.render('用户流失因素EDA.html')

然后

from bs4 import BeautifulSoup
with open("用户流失因素EDA.html", "r+", encoding='utf-8') as html:
    html_bf = BeautifulSoup(html, 'lxml')
    divs = html_bf.select('.chart-container')
    divs[0]["style"] = "width:500px;height:250px;position:absolute;top:50px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[1]['style'] = "width:500px;height:250px;position:absolute;top:50px;left:500px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[2]["style"] = "width:500px;height:250px;position:absolute;top:50px;left:1000px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[3]["style"] = "width:500px;height:250px;position:absolute;top:300px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[4]["style"] = "width:500px;height:250px;position:absolute;top:300px;left:500px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[13]["style"] = "width:500px;height:250px;position:absolute;top:300px;left:1000px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[5]["style"] = "width:750px;height:200px;position:absolute;top:550px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[6]["style"] = "width:750px;height:200px;position:absolute;top:550px;left:750px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[7]["style"] = "width:750px;height:200px;position:absolute;top:750px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[8]["style"] = "width:750px;height:200px;position:absolute;top:750px;left:750px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[9]["style"] = "width:750px;height:200px;position:absolute;top:950px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[10]["style"] = "width:750px;height:200px;position:absolute;top:950px;left:750px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[11]["style"] = "width:750px;height:200px;position:absolute;top:1150px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[12]["style"] = "width:750px;height:200px;position:absolute;top:1150px;left:750px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[14]["style"] = "width:600px;height:600px;position:absolute;top:1350px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[15]["style"] = "width:900px;height:600px;position:absolute;top:1350px;left:600px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[16]["style"] = "width:750px;height:500px;position:absolute;top:1950px;left:0px;border-style:solid;border-color:#444444;border-width:3px;"
    divs[17]["style"] = "width:750px;height:500px;position:absolute;top:1950px;left:750px;border-style:solid;border-color:#444444;border-width:3px;"
    body = html_bf.find("body")
    body["style"] = "background-color:#333333;"
    div_title="<div align=\"center\" style=\"width:1500px;\">\n<span style=\"font-size:32px;font face=\'黑体\';color:#FFFFFF\"><b>用户流失因素探索</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()

div这个列表里就是你所有的图,我这里有18个图,按顺序对应div列表第0到17个元素(按道理应该是这样,但是我这里5和13顺序乱了,做完记得注意一下就行)

divs[x][“style”] 按顺序指定的分别是图宽度,高度,与上边距距离,与左边距距离,边框的颜色,边框的粗细

body[“style”] 就是整个页面的背景色,最好和你的图背景色一样吧,好看点

成品具体效果展示

  • 8
    点赞
  • 57
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值