当前位置:   article > 正文

运用django制作全国各地用户注册图大屏可视化_使用python django框架建立可视化地图平台

使用python django框架建立可视化地图平台

 一、Django版本对应的Python版本

Django 版本Python 版本
1.82.7, 3.2 , 3.3, 3.4, 3.5
1.9, 1.102.7, 3.4, 3.5
1.112.7, 3.4, 3.5, 3.6
2.03.4, 3.5, 3.6, 3.7
2.1, 2.23.5, 3.6, 3.7

1. setttins.py 添加自己创建的app名称,和静态文件的路径

  1. INSTALLED_APPS = [
  2. 'django.contrib.admin',
  3. 'django.contrib.auth',
  4. 'django.contrib.contenttypes',
  5. 'django.contrib.sessions',
  6. 'django.contrib.messages',
  7. 'django.contrib.staticfiles',
  8. 'my_report',
  9. ]
  10. DATABASES = {
  11. 'default': {
  12. 'ENGINE': 'django.db.backends.oracle',
  13. 'NAME': 'devdb',
  14. 'USER': 'hysh',
  15. 'PASSWORD': 'hysh',
  16. 'HOST': '192.168.191.3',
  17. 'PORT': '1521',
  18. }
  19. }
  20. STATIC_URL = '/static/'
  21. STATICFILES_DIRS = (
  22. os.path.join(BASE_DIR, 'static'),
  23. )

2.urls.py

  1. from django.contrib import admin
  2. from django.urls import path
  3. from month_report import views
  4. urlpatterns = [
  5. path('admin/', admin.site.urls),
  6. path('guo/', views.guo_report, name='index'),
  7. ]

 3.views.py

  1. from django.shortcuts import render
  2. from django.db import connection
  3. from django.http import HttpResponse
  4. from django.template import loader
  5. from pyecharts import Bar, Geo
  6. def exc_sql(sql):
  7. cursor = connection.cursor()
  8. cursor.execute(sql)
  9. result = cursor.fetchall()
  10. return result
  11. def guo_report(request):
  12. # select province, difi_re_num from REPORT_REG
  13. ret = """select city, difi_re_num from REPORT_REG a, province_to_city b where a.province=b.province"""
  14. data_list = exc_sql(ret)
  15. attr = [i[0] for i in data_list]
  16. value = [i[1] for i in data_list]
  17. geo = Geo("全国各地用户注册图", width=1200, height=600)
  18. geo.add("各省注册量", attr, value, type="effectScatter", border_color="#ffffff", symbol_size=2,
  19. is_label_show=True, label_text_color="#00FF00", label_pos="inside", symbol_color="yellow",
  20. geo_normal_color="#006edd", geo_emphasis_color="#0000ff")
  21. data = {'data': geo.render_embed()}
  22. return render(request, 'guo_report.html', data)

4.guo_report.html

  1. <!-- myfirstvis/templates/myfirstvis/pyecharts.html -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <title>MY-ECharts</title>
  7. <script src="http://oog4yfyu0.bkt.clouddn.com/echarts.min.js"></script>
  8. <script src="http://oog4yfyu0.bkt.clouddn.com/echarts-gl.js"></script>
  9. <script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
  10. <script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
  11. <script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/wordcloud.js"></script>
  12. </head>
  13. <body>
  14. {{data|safe}}
  15. </body>
  16. </html>

5.效果图

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/164903
推荐阅读
相关标签
  

闽ICP备14008679号