这两年开始毕业设计和毕业答辩的要求和难度不断提升,传统的毕设题目缺少创新和亮点,往往达不到毕业答辩的要求,这两年不断有学弟学妹告诉学长自己做的项目系统达不到老师的要求。
为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的是
基于大数据的公交数据分析与可视化系统
学长这里给一个题目综合评分(每项满分5分)
选题指导,项目分享:
https://gitee.com/yaa-dc/warehouse-1/blob/master/python/README.md
本项目采用B/S架构,利用前后端分离的方法来实现Web开发。同时采用加密的方法对数据进行脱敏,利用python对大数据处理的优势对数据进行整合和清洗,方便可视化时的数据拿取,利用Vue前端框架结合ECharts可视化组件进行前端可视化开发。我们从车辆正晚点、车辆运营情况、线路交通状况、站点客流、线路客流、车辆的满载率、OD客流分析这7个维度来分析公交数据。总体来说是利用某城市特殊的公交数据做出一套针对某城市的公交状况可视化分析系统。为解决某城市公共交通人员出行、道路拥堵、时刻表安排等问题的解决提供技术支持
前端UI设计
行车正晚点
线路运营
站点运营
线路客流
站点客流
OD客流
简介
Flask是一个基于Werkzeug和Jinja2的轻量级Web应用程序框架。与其他同类型框架相比,Flask的灵活性、轻便性和安全性更高,而且容易上手,它可以与MVC模式很好地结合进行开发。Flask也有强大的定制性,开发者可以依据实际需要增加相应的功能,在实现丰富的功能和扩展的同时能够保证核心功能的简单。Flask丰富的插件库能够让用户实现网站定制的个性化,从而开发出功能强大的网站。
本项目在Flask开发后端时,前端请求会遇到跨域的问题,解决该问题有修改数据类型为jsonp,采用GET方法,或者在Flask端加上响应头等方式,在此使用安装Flask-CORS库的方式解决跨域问题。此外需要安装请求库axios。
Flask框架图
相关代码:
import sqlalchemy
from flask import Flask, request, render_template,flash
import pymysql
from datetime import datetime
from flask_sqlalchemy import SQLAlchemy
from flask import jsonify
import json
import toolfun
app = Flask(__name__)
db = pymysql.connect("localhost", "root", "renshuaichen", "firstdatabase")
cursor = db.cursor()
app.secret_key='aaa'
# app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:[email protected]/firstdatabase'
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS ']=False
# db1=SQLAlchemy(app)
# @app.route('/')
# def get_data():
# db = pymysql.connect("localhost", "root", "renshuaichen", "firstdatabase")
# cursor=db.cursor()
# sql="select * from 1table"
# print(cursor.execute(sql))
# @app.route('/getdata')
# def get_data():
# sql = "select * from 趟次201811"
# cursor.execute(sql)
# data = cursor.fetchall()
# jsonify(data)
#------------------------------------------第一次的测试----------------------------
# @app.route('/',methods=['GET','POST'])
# def update_page():
# err="请填写条件"
# data="数据为空"
# bustime_p = []
# bustime_f = []
# turn=[]
# if request.method=='POST':
# input1 = request.form.get('input1')
# input2 = request.form.get('input2')
# if not all([input1,input2]):
# err='消息不完整'
# elif input1=='2'and input2=='1':
# sql = "select * from 到离站201812 where 趟次ID='149959264' and 线路ID='2576' and 线路名称='34路' and 进出站='2'"
# cursor.execute(sql)
# data=cursor.fetchall()
# time_a,sta_a=toolfun.by_time(data)
# print(time_a)
# return render_template("index.html",time_a=json.dumps(time_a),sta_a=json.dumps(sta_a))
# else:
# err=""
# sql = "select 排班时间 from 行车计划201812 where 线路名称='81路' and 排班时间 like '2018-12-02%'"
# cursor.execute(sql)
# data=cursor.fetchall()
# bustime_p=toolfun.get_time_plan(data)
# turn=toolfun.turn(data)
# print(data)
# sql="select 运营日期 from 趟次201812 where 线路名称='81路' and 运营日期 like '2018/12/2 %'"
# cursor.execute(sql)
# data = cursor.fetchall()
# print(data)
# bustime_f=toolfun.get_time(data)
# print(bustime_f)
# # return render_template('index.html',err=json.dumps(err),bustime_f=json.dumps(bustime_f),bustime_p=json.dumps(bustime_p),turn=json.dumps(turn))
# # return render_template('index.html')
# # sql = "select * from 趟次201811"
# # cursor.execute(sql)
# # data = cursor.fetchall()
# # jsonify(data)
# return render_template('on-schedule.html', err=json.dumps(err), bustime_f=json.dumps(bustime_f),
# bustime_p=json.dumps(bustime_p), turn=json.dumps(turn))
# # return render_template('index.html', err=json.dumps(err))
#---------------------------------------------------------------------------------------------
#----------------------------测试2-----------------------------------------
@app.route('/',methods=['GET','POST'])
def update_page():
err="请填写条件"
data="数据为空"
bustime_p = []
bustime_f = []
turn=[]
if request.method=='POST':
select1 = request.values.get('s1')
select2 = request.values.get('s2')
if select1=='0000-00-00' and select2=='0000-00-00':
err='消息不完整'
else:
err=""
sql = "select 排班时间 from 行车计划201812 where 线路名称='"+select1+"' and 排班时间 like '"+select2+"%'"
cursor.execute(sql)
data=cursor.fetchall()
bustime_p=toolfun.get_time_plan(data)
turn=toolfun.turn(data)
print(data)
sql="select 运营日期 from 趟次201812 where 线路名称='"+select1+"' and 运营日期 like '"+toolfun.change_data_from(select2)+" %'"
cursor.execute(sql)
data = cursor.fetchall()
print(data)
bustime_f=toolfun.get_time(data)
print(bustime_f)
# return render_template('index.html',err=json.dumps(err),bustime_f=json.dumps(bustime_f),bustime_p=json.dumps(bustime_p),turn=json.dumps(turn))
# return render_template('index.html')
# sql = "select * from 趟次201811"
# cursor.execute(sql)
# data = cursor.fetchall()
# jsonify(data)
return render_template('on-schedule.html', err=json.dumps(err), bustime_f=json.dumps(bustime_f),
bustime_p=json.dumps(bustime_p), turn=json.dumps(turn))
# return render_template('index.html', err=json.dumps(err))
#----------------------------------------------------------------------------
# @app.route('/',methods=['GET','POST'])
# def update_page():
# err="请填写条件"
# data="数据为空"
# bustime_p = []
# bustime_f = []
# turn=[]
# print('1')
# if request.method=='POST':
# select1 = request.values.get('s1')
# select2 = request.values.get('s2')
# print(select1)
# print(select2)
# if select1=='0000-00-00' and select2=='0000-00-00':
# err='消息不完整'
# else:
# err=""
# sql = "select 排班时间 from 行车计划201812 where 线路名称='"+str(select2)+"' and 排班时间 like '"+str(select1)+"%'"
# cursor.execute(sql)
# data=cursor.fetchall()
# bustime_p=toolfun.get_time_plan(data)
# turn=toolfun.turn(data)
# print(data)
# sql="select 运营日期 from 趟次201812 where 线路名称='"+str(select1)+"' and 运营日期 like '2018/12/2 %'"
# cursor.execute(sql)
# data = cursor.fetchall()
# print(data)
# bustime_f=toolfun.get_time(data)
# print(bustime_f)
# return render_template('on-schedule.html',err=json.dumps(err), bustime_f=json.dumps(bustime_f),bustime_p=json.dumps(bustime_p), turn=json.dumps(turn))
@app.route('/t_point',methods=['GET','POST'])
def t_point():
err="请填写条件"
data="数据为空"
time_a_1 = []
time_a_2 = []
time_a_3 = []
sta_a = []
turn=[]
if request.method=='POST':
select1 = request.values.get('s1')
select2 = request.values.get('s2')
if select1 == '0000-00-00' and select2 == '0000-00-00':
err='消息不完整'
else:
sql = "select 始发站名称 from 行车计划201812 where 线路名称='"+select1+"'"
cursor.execute(sql)
f_stop = cursor.fetchone()
print(f_stop[0])
sql="select 趟次ID from 到离站201812 where 线路名称='"+select1+"'and 到站时间 like '"+toolfun.change_data_from(select2)+" 7:0%' and 进出站='2' and 站点名称='"+f_stop[0]+"'"
# sql = "select * from 到离站201812 where 趟次ID='149959264' and 线路ID='2576' and 线路名称='34路' and 进出站='2'"
cursor.execute(sql)
trip_1=cursor.fetchone()
print(trip_1[0])
# sql="select 趟次ID from 到离站201812 where 线路名称='"+select1+"'and 到站时间 like '"+toolfun.change_data_from(select2)+" 12:0%' and 进出站='2' and 站点名称='"+f_stop[0]+"'"
# cursor.execute(sql)
# trip_2 = cursor.fetchone()
#
# sql = "select 趟次ID from 到离站201812 where 线路名称='" + select1 + "'and 到站时间 like '" + toolfun.change_data_from(select2) + " 18:0%' and 进出站='2' and 站点名称='" +f_stop[0] + "'"
# cursor.execute(sql)
# trip_3 = cursor.fetchone()
sql = "select * from 到离站201812 where 趟次ID='"+trip_1[0]+"' and 进出站='2'"
cursor.execute(sql)
data_1 = cursor.fetchall()
time_a_1,sta_a = toolfun.by_time(data_1)
# sql = "select * from 到离站201812 where 趟次ID='"+trip_2[0]+"'"
# cursor.execute(sql)
# data_2 = cursor.fetchone()
# time_a_2,sta_a = toolfun.by_time(data_2)
# sql = "select * from 到离站201812 where 趟次ID='"+trip_3[0]+"'"
# cursor.execute(sql)
# data_3 = cursor.fetchone()
# time_a_3,sta_a = toolfun.by_time(data_3)
return render_template("t_point.html", time_a_1=json.dumps(time_a_1), sta_a=json.dumps(sta_a), time_a_2=json.dumps(time_a_2), time_a_3=json.dumps(time_a_3))
# return render_template('t_point.html', err=json.dumps(err), bustime_f=json.dumps(bustime_f),
# bustime_p=json.dumps(bustime_p), turn=json.dumps(turn))
# return render_template('index.html', err=json.dumps(err))
@app.route('/page_one',methods=['GET','POST'])
def page_one():
return render_template('站点客流.html')
@app.route('/page_two',methods=['GET','POST'])
def page_two():
num,name=toolfun.sta_co_data()
return render_template('客流柱状图.html',num=json.dumps(num),name=json.dumps(name))
if __name__ == '__main__':
app.run()
ECharts(Enterprise Charts)是百度开源的数据可视化工具,底层依赖轻量级Canvas库ZRender。兼容了几乎全部常用浏览器的特点,使它可广泛用于PC客户端和手机客户端。ECharts能辅助开发者整合用户数据,创新性的完成个性化设置可视化图表。支持折线图(区域图)、柱状图(条状图)、散点图(气泡图)、K线图、饼图(环形图)等,通过导入 js 库在 Java Web 项目上运行。
选题指导,项目分享:
https://gitee.com/yaa-dc/warehouse-1/blob/master/python/README.md