赞
踩
Django 版本 | Python 版本 |
---|---|
1.8 | 2.7, 3.2 , 3.3, 3.4, 3.5 |
1.9, 1.10 | 2.7, 3.4, 3.5 |
1.11 | 2.7, 3.4, 3.5, 3.6 |
2.0 | 3.4, 3.5, 3.6, 3.7 |
2.1, 2.2 | 3.5, 3.6, 3.7 |
- INSTALLED_APPS = [
- 'django.contrib.admin',
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.messages',
- 'django.contrib.staticfiles',
- 'my_report',
- ]
-
- DATABASES = {
- 'default': {
- 'ENGINE': 'django.db.backends.oracle',
- 'NAME': 'devdb',
- 'USER': 'hysh',
- 'PASSWORD': 'hysh',
- 'HOST': '192.168.191.3',
- 'PORT': '1521',
- }
- }
-
- STATIC_URL = '/static/'
- STATICFILES_DIRS = (
- os.path.join(BASE_DIR, 'static'),
- )
- from django.contrib import admin
- from django.urls import path
- from month_report import views
-
- urlpatterns = [
- path('admin/', admin.site.urls),
- path('guo/', views.guo_report, name='index'),
- ]
- from django.shortcuts import render
- from django.db import connection
- from django.http import HttpResponse
- from django.template import loader
- from pyecharts import Bar, Geo
-
-
- def exc_sql(sql):
- cursor = connection.cursor()
- cursor.execute(sql)
- result = cursor.fetchall()
- return result
-
-
-
- def guo_report(request):
- # select province, difi_re_num from REPORT_REG
- ret = """select city, difi_re_num from REPORT_REG a, province_to_city b where a.province=b.province"""
- data_list = exc_sql(ret)
- attr = [i[0] for i in data_list]
- value = [i[1] for i in data_list]
- geo = Geo("全国各地用户注册图", width=1200, height=600)
- geo.add("各省注册量", attr, value, type="effectScatter", border_color="#ffffff", symbol_size=2,
- is_label_show=True, label_text_color="#00FF00", label_pos="inside", symbol_color="yellow",
- geo_normal_color="#006edd", geo_emphasis_color="#0000ff")
- data = {'data': geo.render_embed()}
- return render(request, 'guo_report.html', data)
- <!-- myfirstvis/templates/myfirstvis/pyecharts.html -->
- <!DOCTYPE html>
- <html>
-
- <head>
- <meta charset="utf-8">
- <title>MY-ECharts</title>
- <script src="http://oog4yfyu0.bkt.clouddn.com/echarts.min.js"></script>
- <script src="http://oog4yfyu0.bkt.clouddn.com/echarts-gl.js"></script>
- <script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
- <script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
- <script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/wordcloud.js"></script>
- </head>
-
- <body>
- {{data|safe}}
- </body>
-
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。