当前位置: 首页 > backend >正文

【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts) 视频教程 - 主页-评论用户时间占比环形饼状图实现

大家好,我是java1234_小锋老师,最近写了一套【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts)视频教程,持续更新中,计划月底更新完,感谢支持。今天讲解主页-评论用户时间占比环形饼状图实现

视频在线地址:

2026版【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts+爬虫) 视频教程 (火爆连载更新中..)_哔哩哔哩_bilibili

课程简介:

本课程采用主流的Python技术栈实现,Mysql8数据库,Flask后端,Pandas数据分析,前端可视化图表采用echarts,以及requests库,snowNLP进行情感分析,词频统计,包括大量的数据统计及分析技巧。

实现了,用户登录,注册,爬取微博帖子和评论信息,进行了热词统计以及舆情分析,以及基于echarts实现了数据可视化,包括微博文章分析,微博IP分析,微博评论分析,微博舆情分析。最后也基于wordcloud库实现了词云图,包括微博内容词云图,微博评论词云图,微博评论用户词云图等功能。

主页-评论用户时间占比环形饼状图实现

首先commentDao实现获取7天用户评论量

def getCommentAmount():"""获取7天用户评论量:return:"""con = Nonetry:con = dbUtil.getCon()cursor = con.cursor()sql = "select DATE_FORMAT(created_at, '%Y-%m-%d') as commentDate,count(text_raw) as commentTotal from t_comment group by DATE_FORMAT(created_at, '%Y-%m-%d')  order by commentDate desc limit 0,7"cursor.execute(sql)return cursor.fetchall()except Exception as e:print(e)con.rollback()return Nonefinally:dbUtil.closeCon(con)

page.py的home()方法里,调用commentDao获取数据,然后转发到主页面

# 获取评论数量(最近7天)commentData = []commentAmountList = commentDao.getCommentAmount()for comment in commentAmountList:commentData.append({'value': comment[1], 'name': comment[0]})
​return render_template('index.html',xAxis7ArticleData=xAxis7ArticleData,yAxis7ArticleData=yAxis7ArticleData,arcTypeData=arcTypeData,commentData=commentData)

index.html里 定义图表对象,用得是饼状图,设置数据对象。

var chartDom = document.getElementById('commentUserZb');var myChart = echarts.init(chartDom);var option;
​option = {tooltip: {trigger: 'item'},legend: {top: '5%',left: 'center'},series: [{name: '评论用户时间占比',type: 'pie',radius: ['40%', '70%'],avoidLabelOverlap: false,itemStyle: {borderRadius: 10,borderColor: '#fff',borderWidth: 2},label: {show: false,position: 'center'},emphasis: {label: {show: true,fontSize: 40,fontWeight: 'bold'}},labelLine: {show: false},data: {{ commentData | tojson }}}]};
​option && myChart.setOption(option);

运行系统:

http://www.xdnf.cn/news/16262.html

相关文章:

  • 编程语言Java——核心技术篇(三)异常处理详解
  • Springboot+activiti启动时报错XMLException: Error reading XML
  • 深度学习day02--神经网络(前三节)
  • Elasticsearch-8.17.0 centos7安装
  • Ubuntu 环境下创建并启动一个 MediaMTX 的 systemd 服务
  • 栈与队列:数据结构核心解密
  • 链表反转算法详解
  • Fluent自动化仿真(TUI命令脚本教程)
  • springboot(3.4.8)整合mybatis
  • 【图像理解进阶】如何对图像中的小区域进行细粒度的语义分割?
  • WAIC2025预告|英码深元AI一体机将亮相华为昇腾展区,以灵活部署的能力赋能行业智能化转型
  • Nginx简单介绍
  • Java-Properties类和properties文件详解
  • 图论:最小生成树
  • classgraph:Java轻量级类和包扫描器
  • linux C — udp,tcp通信
  • 【Chrome】下载chromedriver的地址
  • 深入解析浏览器存储方案:Cookie、localStorage和sessionStorage特性与应用
  • GPU 服务器ecc报错处理
  • Java排序算法之<冒泡排序>
  • 单片机(STM32-ADC模数转换器)
  • 优思学院|QC七大手法之一的检查表应如何有效使用?
  • CSS 盒子模型学习版的理解
  • 数据结构 二叉树(1)
  • yarn在macOS上的安装与镜像源配置:全方位指南
  • 从 SQL Server 到 KingbaseES V9R4C12,一次“无痛”迁移与深度兼容体验实录
  • Orbbec开发---数据流与数据流操作
  • ZLMediaKit 源代码入门
  • Spring 策略模式实现
  • 【DeepRare】疾病识别召回率100%