├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── demo.gif ├── historical_weather_display ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py ├── manage.py └── weather_display ├── __init__.py ├── admin.py ├── apps.py ├── migrations ├── 0001_initial.py └── __init__.py ├── models.py ├── static └── assets │ ├── css │ ├── alldata-display.css │ ├── bootstrap.css │ └── index-style.css │ ├── images │ └── videos │ │ ├── stormCloud-poster-thumb.jpg │ │ ├── stormCloud-poster.jpg │ │ ├── stormCloud.mp4 │ │ └── stormCloud.webm │ └── js │ ├── bootstrap.min.js │ ├── data-display │ ├── chinamap.js │ ├── line.js │ ├── map.js │ ├── pie-1.js │ ├── pie-2.js │ └── pie-3.js │ ├── echarts.min.js │ ├── jquery-3.3.1.min.js │ └── map-data │ ├── china.js │ ├── china.json │ └── world.json ├── templates ├── city-data-detial.html ├── city-data-display.html └── index.html ├── tests.py ├── urls.py └── views.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=Python 2 | *.css linguist-language=Python 3 | *.html linguist-language=Python -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .nox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *.cover 48 | .hypothesis/ 49 | .pytest_cache/ 50 | 51 | # Translations 52 | *.mo 53 | *.pot 54 | 55 | # Django stuff: 56 | *.log 57 | local_settings.py 58 | db.sqlite3 59 | 60 | # Flask stuff: 61 | instance/ 62 | .webassets-cache 63 | 64 | # Scrapy stuff: 65 | .scrapy 66 | 67 | # Sphinx documentation 68 | docs/_build/ 69 | 70 | # PyBuilder 71 | target/ 72 | 73 | # Jupyter Notebook 74 | .ipynb_checkpoints 75 | 76 | # IPython 77 | profile_default/ 78 | ipython_config.py 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # SageMath parsed files 87 | *.sage.py 88 | 89 | # Environments 90 | .env 91 | .venv 92 | env/ 93 | venv/ 94 | ENV/ 95 | env.bak/ 96 | venv.bak/ 97 | 98 | # Spyder project settings 99 | .spyderproject 100 | .spyproject 101 | 102 | # Rope project settings 103 | .ropeproject 104 | 105 | # mkdocs documentation 106 | /site 107 | 108 | # mypy 109 | .mypy_cache/ 110 | .dmypy.json 111 | dmypy.json 112 | 113 | # Pyre type checker 114 | .pyre/ 115 | 116 | # pycharm 117 | .idea/ 118 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # historical_weather_display 2 | 一个数据可视化使用ECharts框架,后端使用Django框架的历史天气数据展示项目 3 | 4 | ## 效果展示 5 | ![image](https://github.com/WoohTao/historical_weather_display/blob/master/demo.gif) 6 | 7 | ## 说明 8 | 1.前端使用了jQuery和Bootstrap框架。 9 | 10 | 2.数据可视化部分使用的是ECharts(真的很好用)。 11 | 12 | 3.Django models:因为使用的是之前用存入爬虫数据的数据库,所以对其models下的class Meta进行了设置,如果有需要可以进行修改。 13 | 14 | ## TODO 15 | 1.增加可以查看的城市数量 16 | 17 | 2.添加可以显示详细数据的页面 18 | 19 | 3.添加单元测试代码 20 | 21 | 4.优化数据库查询速度 22 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/demo.gif -------------------------------------------------------------------------------- /historical_weather_display/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/historical_weather_display/__init__.py -------------------------------------------------------------------------------- /historical_weather_display/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for historical_weather_display project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.1.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '_olol24ptywh944@u!-sogkcp6x#js%@h0&ihnd3kg#%*_*i%x' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'weather_display.apps.WeatherDisplayConfig' 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'historical_weather_display.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [os.path.join(BASE_DIR, 'weather_display/templates')] 59 | , 60 | 'APP_DIRS': True, 61 | 'OPTIONS': { 62 | 'context_processors': [ 63 | 'django.template.context_processors.debug', 64 | 'django.template.context_processors.request', 65 | 'django.contrib.auth.context_processors.auth', 66 | 'django.contrib.messages.context_processors.messages', 67 | ], 68 | }, 69 | }, 70 | ] 71 | 72 | WSGI_APPLICATION = 'historical_weather_display.wsgi.application' 73 | 74 | 75 | # Database 76 | # https://docs.djangoproject.com/en/2.1/ref/settings/#databases 77 | 78 | DATABASES = { 79 | 'default': { 80 | 'ENGINE': 'django.db.backends.mysql', 81 | 'NAME': '', 82 | 'USER': '', 83 | 'PASSWORD': '', 84 | 'HOST': '', 85 | 'PROT': '3306', 86 | 'CONN_MAX_AGE': 3600 87 | } 88 | } 89 | 90 | 91 | # Password validation 92 | # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators 93 | 94 | AUTH_PASSWORD_VALIDATORS = [ 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 100 | }, 101 | { 102 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 103 | }, 104 | { 105 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 106 | }, 107 | ] 108 | 109 | 110 | # Internationalization 111 | # https://docs.djangoproject.com/en/2.1/topics/i18n/ 112 | 113 | LANGUAGE_CODE = 'en-us' 114 | 115 | TIME_ZONE = 'UTC' 116 | 117 | USE_I18N = True 118 | 119 | USE_L10N = True 120 | 121 | USE_TZ = True 122 | 123 | 124 | # Static files (CSS, JavaScript, Images) 125 | # https://docs.djangoproject.com/en/2.1/howto/static-files/ 126 | 127 | STATIC_URL = '/static/' 128 | -------------------------------------------------------------------------------- /historical_weather_display/urls.py: -------------------------------------------------------------------------------- 1 | """historical_weather_display URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('', include('weather_display.urls')), 22 | ] 23 | -------------------------------------------------------------------------------- /historical_weather_display/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for historical_weather_display project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'historical_weather_display.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == '__main__': 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'historical_weather_display.settings') 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /weather_display/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/__init__.py -------------------------------------------------------------------------------- /weather_display/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /weather_display/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class WeatherDisplayConfig(AppConfig): 5 | name = 'weather_display' 6 | -------------------------------------------------------------------------------- /weather_display/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 2.1.2 on 2018-10-28 17:41 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='beijing', 16 | fields=[ 17 | ('weather_date', models.DateField(primary_key=True, serialize=False)), 18 | ('max_temp', models.CharField(max_length=10)), 19 | ('min_temp', models.CharField(max_length=10)), 20 | ('weather', models.CharField(max_length=30)), 21 | ('wind_direct', models.CharField(max_length=30)), 22 | ('wind_speed', models.CharField(max_length=30)), 23 | ], 24 | options={ 25 | 'db_table': 'beijing', 26 | 'managed': False, 27 | }, 28 | ), 29 | ] 30 | -------------------------------------------------------------------------------- /weather_display/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/migrations/__init__.py -------------------------------------------------------------------------------- /weather_display/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class PlaceDetail(models.Model): 5 | weather_date = models.DateField(primary_key=True) 6 | max_temp = models.CharField(max_length=10) 7 | min_temp = models.CharField(max_length=10) 8 | weather = models.CharField(max_length=30) 9 | wind_direct = models.CharField(max_length=30) 10 | wind_speed = models.CharField(max_length=30) 11 | 12 | class Meta: 13 | abstract = True 14 | 15 | def __str__(self): 16 | return str(self.weather_date) 17 | 18 | 19 | class beijing(PlaceDetail): 20 | class Meta: 21 | managed = False 22 | db_table = 'beijing' 23 | 24 | -------------------------------------------------------------------------------- /weather_display/static/assets/css/alldata-display.css: -------------------------------------------------------------------------------- 1 | /*.navbar > a{*/ 2 | /*color: #000000;*/ 3 | /*font-size: 40px;*/ 4 | /*font-family: 'Trebuchet MS'*/ 5 | /*}*/ 6 | 7 | /*.navbar-nav > li > a{*/ 8 | /*color: #000000;*/ 9 | /*font-size: 15px;*/ 10 | /*font-family: 'Trebuchet MS'*/ 11 | /*}*/ 12 | 13 | body { 14 | padding-top: 70px; 15 | } 16 | 17 | #pie{ 18 | margin-top: 50px; 19 | } -------------------------------------------------------------------------------- /weather_display/static/assets/css/index-style.css: -------------------------------------------------------------------------------- 1 | 2 | #back-ground{ 3 | position:absolute; 4 | left:0px; 5 | top:0px; 6 | width:100%; 7 | height: 100%; 8 | z-index:1; 9 | } 10 | 11 | #vedio{ 12 | width:100%; 13 | height:auto; 14 | object-fit: fill; 15 | } 16 | 17 | .navbar > a{ 18 | color:white; 19 | font-size: 40px; 20 | font-family: 'Trebuchet MS' 21 | } 22 | 23 | .navbar-nav > li > a{ 24 | color:white; 25 | font-size: 15px; 26 | font-family: 'Trebuchet MS' 27 | } 28 | 29 | #title{ 30 | position:absolute; 31 | top:300px; 32 | z-index:2; 33 | text-align:center; 34 | color:white; 35 | font-size:40px; 36 | font-weight:900; 37 | } 38 | 39 | #map-wrap{ 40 | position:relative; 41 | color:black; 42 | font-size: 40px; 43 | font-weight: 800; 44 | margin-top:-6px; 45 | border:0; 46 | padding:0; 47 | } -------------------------------------------------------------------------------- /weather_display/static/assets/images/videos/stormCloud-poster-thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/static/assets/images/videos/stormCloud-poster-thumb.jpg -------------------------------------------------------------------------------- /weather_display/static/assets/images/videos/stormCloud-poster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/static/assets/images/videos/stormCloud-poster.jpg -------------------------------------------------------------------------------- /weather_display/static/assets/images/videos/stormCloud.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/static/assets/images/videos/stormCloud.mp4 -------------------------------------------------------------------------------- /weather_display/static/assets/images/videos/stormCloud.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WoohTao/historical_weather_display/9e802f6213fdeed66556a20b23442584dc8eac51/weather_display/static/assets/images/videos/stormCloud.webm -------------------------------------------------------------------------------- /weather_display/static/assets/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v4.1.3 (https://getbootstrap.com/) 3 | * Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery"),require("popper.js")):"function"==typeof define&&define.amd?define(["exports","jquery","popper.js"],e):e(t.bootstrap={},t.jQuery,t.Popper)}(this,function(t,e,h){"use strict";function i(t,e){for(var n=0;nthis._items.length-1||t<0))if(this._isSliding)P(this._element).one(Q.SLID,function(){return e.to(t)});else{if(n===t)return this.pause(),void this.cycle();var i=ndocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},t._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},t._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=t.left+t.right
',trigger:"hover focus",title:"",delay:0,html:!(Ie={AUTO:"auto",TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"}),selector:!(Se={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"(number|string)",container:"(string|element|boolean)",fallbackPlacement:"(string|array)",boundary:"(string|element)"}),placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent"},we="out",Ne={HIDE:"hide"+Ee,HIDDEN:"hidden"+Ee,SHOW:(De="show")+Ee,SHOWN:"shown"+Ee,INSERTED:"inserted"+Ee,CLICK:"click"+Ee,FOCUSIN:"focusin"+Ee,FOCUSOUT:"focusout"+Ee,MOUSEENTER:"mouseenter"+Ee,MOUSELEAVE:"mouseleave"+Ee},Oe="fade",ke="show",Pe=".tooltip-inner",je=".arrow",He="hover",Le="focus",Re="click",xe="manual",We=function(){function i(t,e){if("undefined"==typeof h)throw new TypeError("Bootstrap tooltips require Popper.js (https://popper.js.org)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var t=i.prototype;return t.enable=function(){this._isEnabled=!0},t.disable=function(){this._isEnabled=!1},t.toggleEnabled=function(){this._isEnabled=!this._isEnabled},t.toggle=function(t){if(this._isEnabled)if(t){var e=this.constructor.DATA_KEY,n=pe(t.currentTarget).data(e);n||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),pe(t.currentTarget).data(e,n)),n._activeTrigger.click=!n._activeTrigger.click,n._isWithActiveTrigger()?n._enter(null,n):n._leave(null,n)}else{if(pe(this.getTipElement()).hasClass(ke))return void this._leave(null,this);this._enter(null,this)}},t.dispose=function(){clearTimeout(this._timeout),pe.removeData(this.element,this.constructor.DATA_KEY),pe(this.element).off(this.constructor.EVENT_KEY),pe(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&pe(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,(this._activeTrigger=null)!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},t.show=function(){var e=this;if("none"===pe(this.element).css("display"))throw new Error("Please use show on visible elements");var t=pe.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){pe(this.element).trigger(t);var n=pe.contains(this.element.ownerDocument.documentElement,this.element);if(t.isDefaultPrevented()||!n)return;var i=this.getTipElement(),r=Fn.getUID(this.constructor.NAME);i.setAttribute("id",r),this.element.setAttribute("aria-describedby",r),this.setContent(),this.config.animation&&pe(i).addClass(Oe);var o="function"==typeof this.config.placement?this.config.placement.call(this,i,this.element):this.config.placement,s=this._getAttachment(o);this.addAttachmentClass(s);var a=!1===this.config.container?document.body:pe(document).find(this.config.container);pe(i).data(this.constructor.DATA_KEY,this),pe.contains(this.element.ownerDocument.documentElement,this.tip)||pe(i).appendTo(a),pe(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new h(this.element,i,{placement:s,modifiers:{offset:{offset:this.config.offset},flip:{behavior:this.config.fallbackPlacement},arrow:{element:je},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(t){t.originalPlacement!==t.placement&&e._handlePopperPlacementChange(t)},onUpdate:function(t){e._handlePopperPlacementChange(t)}}),pe(i).addClass(ke),"ontouchstart"in document.documentElement&&pe(document.body).children().on("mouseover",null,pe.noop);var l=function(){e.config.animation&&e._fixTransition();var t=e._hoverState;e._hoverState=null,pe(e.element).trigger(e.constructor.Event.SHOWN),t===we&&e._leave(null,e)};if(pe(this.tip).hasClass(Oe)){var c=Fn.getTransitionDurationFromElement(this.tip);pe(this.tip).one(Fn.TRANSITION_END,l).emulateTransitionEnd(c)}else l()}},t.hide=function(t){var e=this,n=this.getTipElement(),i=pe.Event(this.constructor.Event.HIDE),r=function(){e._hoverState!==De&&n.parentNode&&n.parentNode.removeChild(n),e._cleanTipClass(),e.element.removeAttribute("aria-describedby"),pe(e.element).trigger(e.constructor.Event.HIDDEN),null!==e._popper&&e._popper.destroy(),t&&t()};if(pe(this.element).trigger(i),!i.isDefaultPrevented()){if(pe(n).removeClass(ke),"ontouchstart"in document.documentElement&&pe(document.body).children().off("mouseover",null,pe.noop),this._activeTrigger[Re]=!1,this._activeTrigger[Le]=!1,this._activeTrigger[He]=!1,pe(this.tip).hasClass(Oe)){var o=Fn.getTransitionDurationFromElement(n);pe(n).one(Fn.TRANSITION_END,r).emulateTransitionEnd(o)}else r();this._hoverState=""}},t.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},t.isWithContent=function(){return Boolean(this.getTitle())},t.addAttachmentClass=function(t){pe(this.getTipElement()).addClass(Te+"-"+t)},t.getTipElement=function(){return this.tip=this.tip||pe(this.config.template)[0],this.tip},t.setContent=function(){var t=this.getTipElement();this.setElementContent(pe(t.querySelectorAll(Pe)),this.getTitle()),pe(t).removeClass(Oe+" "+ke)},t.setElementContent=function(t,e){var n=this.config.html;"object"==typeof e&&(e.nodeType||e.jquery)?n?pe(e).parent().is(t)||t.empty().append(e):t.text(pe(e).text()):t[n?"html":"text"](e)},t.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},t._getAttachment=function(t){return Ie[t.toUpperCase()]},t._setListeners=function(){var i=this;this.config.trigger.split(" ").forEach(function(t){if("click"===t)pe(i.element).on(i.constructor.Event.CLICK,i.config.selector,function(t){return i.toggle(t)});else if(t!==xe){var e=t===He?i.constructor.Event.MOUSEENTER:i.constructor.Event.FOCUSIN,n=t===He?i.constructor.Event.MOUSELEAVE:i.constructor.Event.FOCUSOUT;pe(i.element).on(e,i.config.selector,function(t){return i._enter(t)}).on(n,i.config.selector,function(t){return i._leave(t)})}pe(i.element).closest(".modal").on("hide.bs.modal",function(){return i.hide()})}),this.config.selector?this.config=l({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},t._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},t._enter=function(t,e){var n=this.constructor.DATA_KEY;(e=e||pe(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),pe(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusin"===t.type?Le:He]=!0),pe(e.getTipElement()).hasClass(ke)||e._hoverState===De?e._hoverState=De:(clearTimeout(e._timeout),e._hoverState=De,e.config.delay&&e.config.delay.show?e._timeout=setTimeout(function(){e._hoverState===De&&e.show()},e.config.delay.show):e.show())},t._leave=function(t,e){var n=this.constructor.DATA_KEY;(e=e||pe(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),pe(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusout"===t.type?Le:He]=!1),e._isWithActiveTrigger()||(clearTimeout(e._timeout),e._hoverState=we,e.config.delay&&e.config.delay.hide?e._timeout=setTimeout(function(){e._hoverState===we&&e.hide()},e.config.delay.hide):e.hide())},t._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},t._getConfig=function(t){return"number"==typeof(t=l({},this.constructor.Default,pe(this.element).data(),"object"==typeof t&&t?t:{})).delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),Fn.typeCheckConfig(ve,t,this.constructor.DefaultType),t},t._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},t._cleanTipClass=function(){var t=pe(this.getTipElement()),e=t.attr("class").match(be);null!==e&&e.length&&t.removeClass(e.join(""))},t._handlePopperPlacementChange=function(t){var e=t.instance;this.tip=e.popper,this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},t._fixTransition=function(){var t=this.getTipElement(),e=this.config.animation;null===t.getAttribute("x-placement")&&(pe(t).removeClass(Oe),this.config.animation=!1,this.hide(),this.show(),this.config.animation=e)},i._jQueryInterface=function(n){return this.each(function(){var t=pe(this).data(ye),e="object"==typeof n&&n;if((t||!/dispose|hide/.test(n))&&(t||(t=new i(this,e),pe(this).data(ye,t)),"string"==typeof n)){if("undefined"==typeof t[n])throw new TypeError('No method named "'+n+'"');t[n]()}})},s(i,null,[{key:"VERSION",get:function(){return"4.1.3"}},{key:"Default",get:function(){return Ae}},{key:"NAME",get:function(){return ve}},{key:"DATA_KEY",get:function(){return ye}},{key:"Event",get:function(){return Ne}},{key:"EVENT_KEY",get:function(){return Ee}},{key:"DefaultType",get:function(){return Se}}]),i}(),pe.fn[ve]=We._jQueryInterface,pe.fn[ve].Constructor=We,pe.fn[ve].noConflict=function(){return pe.fn[ve]=Ce,We._jQueryInterface},We),Jn=(qe="popover",Ke="."+(Fe="bs.popover"),Me=(Ue=e).fn[qe],Qe="bs-popover",Be=new RegExp("(^|\\s)"+Qe+"\\S+","g"),Ve=l({},zn.Default,{placement:"right",trigger:"click",content:"",template:''}),Ye=l({},zn.DefaultType,{content:"(string|element|function)"}),ze="fade",Ze=".popover-header",Ge=".popover-body",$e={HIDE:"hide"+Ke,HIDDEN:"hidden"+Ke,SHOW:(Je="show")+Ke,SHOWN:"shown"+Ke,INSERTED:"inserted"+Ke,CLICK:"click"+Ke,FOCUSIN:"focusin"+Ke,FOCUSOUT:"focusout"+Ke,MOUSEENTER:"mouseenter"+Ke,MOUSELEAVE:"mouseleave"+Ke},Xe=function(t){var e,n;function i(){return t.apply(this,arguments)||this}n=t,(e=i).prototype=Object.create(n.prototype),(e.prototype.constructor=e).__proto__=n;var r=i.prototype;return r.isWithContent=function(){return this.getTitle()||this._getContent()},r.addAttachmentClass=function(t){Ue(this.getTipElement()).addClass(Qe+"-"+t)},r.getTipElement=function(){return this.tip=this.tip||Ue(this.config.template)[0],this.tip},r.setContent=function(){var t=Ue(this.getTipElement());this.setElementContent(t.find(Ze),this.getTitle());var e=this._getContent();"function"==typeof e&&(e=e.call(this.element)),this.setElementContent(t.find(Ge),e),t.removeClass(ze+" "+Je)},r._getContent=function(){return this.element.getAttribute("data-content")||this.config.content},r._cleanTipClass=function(){var t=Ue(this.getTipElement()),e=t.attr("class").match(Be);null!==e&&0=this._offsets[r]&&("undefined"==typeof this._offsets[r+1]||t 点击查看天气详情' 66 | }, 67 | legend: { 68 | orient: 'vertical', 69 | y: 'bottom', 70 | x:'right', 71 | data:['城市'], 72 | textStyle: { 73 | color: '#fff' 74 | } 75 | }, 76 | geo: { 77 | map: 'china', 78 | label: { 79 | emphasis: { 80 | show: false 81 | } 82 | //emphasis: { 83 | //backgroundColor:'', 84 | //position: 'top', 85 | //borderColor: '#fff', 86 | //borderWidth: 1 87 | //} 88 | }, 89 | itemStyle: { 90 | normal: { 91 | areaColor: '#323c48', 92 | borderColor: '#111' 93 | }, 94 | emphasis: { 95 | areaColor: '#2a333d' 96 | } 97 | } 98 | }, 99 | series: [ 100 | { 101 | name: '城市', 102 | type: 'scatter', 103 | coordinateSystem: 'geo', 104 | data: convertData([ 105 | {name:"北京",value:'beijing'}, 106 | {name:"天津",value:'tianjin'}, 107 | {name:"上海",value:'shanghai'}, 108 | {name:"重庆",value:'chongqing'}, 109 | {name:"石家庄",value:'shijiazhuang'}, 110 | {name:"沈阳",value:'shenyang'}, 111 | {name:"哈尔滨",value:'haerbin'}, 112 | {name:"杭州",value:'hangzhou'}, 113 | {name:"福州",value:'fuzhou'}, 114 | {name:"济南",value:'jinan'}, 115 | {name:"广州",value:'guangzhou'}, 116 | {name:"武汉",value:'wuhan'}, 117 | {name:"成都",value:'chengdu'}, 118 | {name:"昆明",value:'kunming'}, 119 | {name:"兰州",value:'lanzhou'}, 120 | {name:"南宁",value:'nanning'}, 121 | {name:"银川",value:'yinchun'}, 122 | {name:"太原",value:'taiyuan'}, 123 | {name:"长春",value:'changchun'}, 124 | {name:"南京",value:'nanjing'}, 125 | {name:"合肥",value:'hefei'}, 126 | {name:"南昌",value:'nanchang'}, 127 | {name:"郑州",value:'zhengzhou'}, 128 | {name:"长沙",value:'changsha'}, 129 | {name:"海口",value:'haikou'}, 130 | {name:"贵阳",value:'guiyang1'}, 131 | {name:"西安",value:'xian'}, 132 | {name:"西宁",value:'xining'}, 133 | {name:"呼和浩特",value:'huhehaote'}, 134 | {name:"拉萨",value:'lasa'}, 135 | {name:"乌鲁木齐",value:'wulumuqi'} 136 | ]), 137 | symbolSize: 12, 138 | label: { 139 | normal: { 140 | show: false 141 | }, 142 | emphasis: { 143 | show: false 144 | } 145 | }, 146 | itemStyle: { 147 | color: '#ffbbcf', 148 | emphasis: { 149 | borderColor: '#fff', 150 | borderWidth: 1 151 | } 152 | } 153 | } 154 | ] 155 | }; 156 | myChart.setOption(option); 157 | var MapSize = document.getElementById("map-wrap"); 158 | var MapWidth = MapSize.clientWidth||MapSize.offsetWidth; 159 | MapContainer.style.width = MapWidth+'px'; 160 | MapContainer.style.height = MapWidth*0.6+'px'; 161 | myChart.resize(); -------------------------------------------------------------------------------- /weather_display/static/assets/js/data-display/pie-1.js: -------------------------------------------------------------------------------- 1 | MapContainer = document.getElementById('pie-1'); 2 | myChart = echarts.init(MapContainer); 3 | let weather_list = JSON.parse(document.getElementById("weather_list").textContent); 4 | let weather_data = JSON.parse(document.getElementById("weather_data").textContent); 5 | let weather_SeriesData = Series_data(weather_data); 6 | let weather_SelectData = Select_data(weather_list); 7 | // let weather_SelectData={"多云转阴": 0, 8 | // "阴转晴": 1, 9 | // "晴": 2, 10 | // "霾转多云": 3, 11 | // "晴转阴": 4, 12 | // "阴": 5 13 | // }; 14 | option = { 15 | title : { 16 | text: '天气统计', 17 | x:'center' 18 | }, 19 | tooltip : { 20 | trigger: 'item', 21 | formatter: "{a}
{b} : {c} ({d}%)" 22 | }, 23 | legend: { 24 | type: 'scroll', 25 | orient: 'vertical', 26 | right: 10, 27 | top: 20, 28 | bottom: 20, 29 | data: weather_list, 30 | selected:weather_SelectData 31 | }, 32 | series : [ 33 | { 34 | name: '天气(天)', 35 | type: 'pie', 36 | radius : '55%', 37 | center: ['40%', '50%'], 38 | data: weather_SeriesData, 39 | itemStyle: { 40 | emphasis: { 41 | shadowBlur: 10, 42 | shadowOffsetX: 0, 43 | shadowColor: 'rgba(0, 0, 0, 0.5)' 44 | } 45 | } 46 | } 47 | ] 48 | }; 49 | 50 | 51 | function Series_data(weather_data){ 52 | var weather_SeriesData=[]; 53 | for(var key in weather_data){ 54 | weather_SeriesData.push({ 55 | name:key, 56 | value:weather_data[key] 57 | }); 58 | } 59 | return weather_SeriesData; 60 | } 61 | 62 | function Select_data(weather_list){ 63 | var weather_SelectData={}; 64 | for(var i=0;i{b} : {c} ({d}%)" 16 | }, 17 | legend: { 18 | type: 'scroll', 19 | orient: 'vertical', 20 | right: 10, 21 | top: 20, 22 | bottom: 20, 23 | data: wind_direct_list, 24 | selected: wind_direct_SelectData 25 | }, 26 | series : [ 27 | { 28 | name: '风向(天)', 29 | type: 'pie', 30 | radius : '55%', 31 | center: ['40%', '50%'], 32 | data: wind_direct_SeriesData, 33 | itemStyle: { 34 | emphasis: { 35 | shadowBlur: 10, 36 | shadowOffsetX: 0, 37 | shadowColor: 'rgba(0, 0, 0, 0.5)' 38 | } 39 | } 40 | } 41 | ] 42 | }; 43 | 44 | 45 | function Series_data(weather_data){ 46 | var weather_SeriesData=[]; 47 | for(var key in weather_data){ 48 | weather_SeriesData.push({ 49 | name:key, 50 | value:weather_data[key] 51 | }); 52 | } 53 | return weather_SeriesData; 54 | } 55 | 56 | function Select_data(weather_list){ 57 | var weather_SelectData={}; 58 | for(var i=0;i{b} : {c} ({d}%)" 16 | }, 17 | legend: { 18 | type: 'scroll', 19 | orient: 'vertical', 20 | right: 10, 21 | top: 20, 22 | bottom: 20, 23 | data: wind_speed_list, 24 | selected: wind_speed_SelectedData 25 | }, 26 | series : [ 27 | { 28 | name: '风力(天)', 29 | type: 'pie', 30 | radius : '55%', 31 | center: ['40%', '50%'], 32 | data: wind_speed_SeriesData, 33 | itemStyle: { 34 | emphasis: { 35 | shadowBlur: 10, 36 | shadowOffsetX: 0, 37 | shadowColor: 'rgba(0, 0, 0, 0.5)' 38 | } 39 | } 40 | } 41 | ] 42 | }; 43 | 44 | 45 | function Series_data(weather_data){ 46 | var weather_SeriesData=[]; 47 | for(var key in weather_data){ 48 | weather_SeriesData.push({ 49 | name:key, 50 | value:weather_data[key] 51 | }); 52 | } 53 | return weather_SeriesData; 54 | } 55 | 56 | function Select_data(weather_list){ 57 | var weather_SelectData={}; 58 | for(var i=0;i 2 | 3 | 4 | 5 | 详细数据 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /weather_display/templates/city-data-display.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 数据展示 8 | 9 | 10 | 38 | {{ place_name|json_script:"name" }} 39 | {{ date|json_script:"data_line" }} 40 | {{ max_temp|json_script:"max_temp" }} 41 | {{ min_temp|json_script:"min_temp" }} 42 | {{ weather_list|json_script:"weather_list" }} 43 | {{ weather_data|json_script:"weather_data" }} 44 | {{ wind_direct_list|json_script:"wind_direct_list" }} 45 | {{ wind_direct_data|json_script:"wind_direct_data" }} 46 | {{ wind_speed_list|json_script:"wind_speed_list" }} 47 | {{ wind_speed_data|json_script:"wind_speed_data" }} 48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /weather_display/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | map 8 | 9 | 10 | 44 | 45 |
46 | 49 |
50 |
51 | 52 |
53 | 中国历史天气数据 54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /weather_display/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /weather_display/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | 5 | urlpatterns = [ 6 | path('', views.index, name='index'), 7 | path('', views.place_detail) 8 | ] 9 | -------------------------------------------------------------------------------- /weather_display/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from . import models 3 | # from django.http import HttpResponse 4 | 5 | 6 | def index(request): 7 | return render(request, 'index.html') 8 | 9 | 10 | def place_detail(request, place_name='null'): 11 | date = [] 12 | max_temp = [] 13 | min_temp = [] 14 | '''气候数据''' 15 | weather = [] 16 | weather_1 = [] 17 | weather_data = {} 18 | '''风向''' 19 | wind_direct = [] 20 | wind_direct_1 = [] 21 | wind_direct_data = {} 22 | '''风力''' 23 | wind_speed = [] 24 | wind_speed_1 = [] 25 | wind_speed_data ={} 26 | if place_name == 'beijing': 27 | beijing_data = models.beijing.objects.all() 28 | # beijing_data_month = beijing_data.filter(weather_date__year=2014, weather_date__month=4) 29 | 30 | # 从Queryset中获取数据并序列化 31 | for e in beijing_data: 32 | date.append(str(e.weather_date)) 33 | max_temp.append(e.max_temp) 34 | min_temp.append(e.min_temp) 35 | weather.append(e.weather) 36 | wind_direct.append(e.wind_direct) 37 | wind_speed.append(e.wind_speed) 38 | if e.weather not in weather_1: 39 | weather_1.append(e.weather) 40 | if e.wind_direct not in wind_direct_1: 41 | wind_direct_1.append(e.wind_direct) 42 | if e.wind_speed not in wind_speed_1: 43 | wind_speed_1.append(e.wind_speed) 44 | 45 | weather_data.fromkeys(weather_1) 46 | wind_direct_data.fromkeys(wind_direct_1) 47 | wind_speed_data.fromkeys(wind_speed_1) 48 | # 统计数据 49 | for i in weather_1: 50 | weather_data[i] = weather.count(i) 51 | for i in wind_direct_1: 52 | wind_direct_data[i] = wind_direct.count(i) 53 | for i in wind_speed_1: 54 | wind_speed_data[i] = wind_speed.count(i) 55 | 56 | context = { 57 | 'place_name': '北京', 58 | 'date': date, 59 | 'max_temp': max_temp, 60 | 'min_temp': min_temp, 61 | 'weather_list': weather_1, 62 | 'weather_data': weather_data, 63 | 'wind_direct_list': wind_direct_1, 64 | 'wind_direct_data': wind_direct_data, 65 | 'wind_speed_list': wind_speed_1, 66 | 'wind_speed_data': wind_speed_data 67 | } 68 | return render(request, 'city-data-display.html', context) 69 | --------------------------------------------------------------------------------