• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Django显示可视化图表的实践

python 搞代码 4年前 (2022-01-07) 17次浏览 已收录 0个评论
文章目录[隐藏]

这篇文章主要介绍了Django显示可视化图表的实践,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

一 实战

1 Django_lab\urls.py

 # -*- coding: utf-8 -*- from django.conf.urls import url,include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), # 定义图表url url(r'^chart/', include('chart.urls')), ]

2 在settings.py中添加图表应用

 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # 图表应用 'chart', ]

3 chart\urls.py

 # -*- coding: utf-8 -*- from django.conf.urls import url,include from . import views urlpatterns = [ # 折线图的url url(r'^linediagram/$', views.showlinediagram), ]

4 views.py

 # -*- coding: utf-8 -*- from django.shortcuts import render from django.http import HttpResponse from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg from matplotlib.dates import DateFormatter import matplotlib.pyplot as plt import random import datetime # 折线图对应的的模板 def showlinediagram(request): return render(request, 'chart/showlinediagram.html')

5 模板showlinediagram.html

   <title>Highcharts 教程 | 菜鸟教程(runoob.com)</title> <div id="container" style="width: 550px;height: 400px;margin: 0 auto"></div>

二 测试结果

1 浏览器输入:http://localhost:8000/chart/linediagram

2 结果显示结果

三 参考

https://blog.gaodaimna/Temanm/article/details/54141759

https://my.oschina.net/jastme/blog/357142

https://www.hcharts.cn/demo/highcharts/

h来源gaodaima#com搞(代@码网ttp://www.runoob.com/highcharts/highcharts-configuration-syntax.html

到此这篇关于Django显示可视化图表的实践的文章就介绍到这了,更多相关Django 可视化图表内容请搜索gaodaima搞代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持gaodaima搞代码网

以上就是Django显示可视化图表的实践的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Django显示可视化图表的实践

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址