Django中从mysql数据库中获取数据传到echarts方式
作者:笛在月明 时间:2024-01-22 02:06:25
尝试了几种方法,感觉过于复杂,于是自己写了一个方法。
(1)首先在要绘图的页面传入从数据库中提取的参数,这一步通过views可以实现;
(2)然后是页面加载完成时执行的函数ready,调用方法f;
(3)在函数f中获取参数,此时是string类型,需要将其转换为json对象,使用eval即可;
(4)json对象的每一个元素均为string(可以使用typeof()判断),需要取出每一个成员将其转换为json对象;
(5)在echarts模块函数中调用函数f,获取所需的数据
补充知识:django从MySQL获取当天的数据(ORM)
如下所示:
QueuedrecordRealTime.objects.filter(date_take__gte=datetime.datetime.now().date(),device=db.device,department__status=1,department__dept_name=dept_name).order_by("date_take")
检索条件里面加
date_take__gte=datetime.datetime.now().date()
date_take是DateTimeField类型的字段。
来源:https://blog.csdn.net/IqqIqqIqqIqq/article/details/50736943
标签:Django,mysql,echarts
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
ADO.Net对oracle数据库操作的实例代码
2024-01-18 02:00:41
基于jquery自己写tab滑动门(通用版)
2024-04-22 22:21:09
vuex新手进阶篇之actions的使用方法
2024-04-27 16:13:54
![](https://img.aspxhome.com/file/2023/5/132935_0s.jpg)
TensorFlow实现模型评估
2023-10-15 22:36:51
![](https://img.aspxhome.com/file/2023/6/124196_0s.jpg)
关于mysql基础知识的介绍
2024-01-18 10:57:28
selenium + python 获取table数据的示例讲解
2021-02-20 11:57:46
PHP PDOStatement::setAttribute讲解
2023-06-04 02:48:47
python环境下安装opencv库的方法
2022-03-22 10:11:24
![](https://img.aspxhome.com/file/2023/0/84930_0s.png)
LZ77 算法的JS实现
2010-04-11 22:32:00
Django def clean()函数对表单中的数据进行验证操作
2023-08-16 00:31:47
javascript 删除dom对象的事件函数代码
2024-04-19 09:48:02
python反转(逆序)字符串的6种方法详细
2023-03-14 10:38:41
Python实现矩阵转置的方法分析
2023-07-03 21:56:46
![](https://img.aspxhome.com/file/2023/3/112043_0s.png)
Python os.mkdir()与os.makedirs()的使用区别
2023-08-19 20:01:56
python数据预处理 :样本分布不均的解决(过采样和欠采样)
2023-08-10 07:03:14
JS中检测数据类型的几种方式及优缺点小结
2024-04-16 09:14:41
使用setup.py安装python包和卸载python包的方法
2023-01-31 02:20:47
Python+OpenCV之图像轮廓详解
2023-08-10 18:59:42
![](https://img.aspxhome.com/file/2023/1/62001_0s.png)
如何通过神经网络实现线性回归的拟合
2023-04-24 06:15:07
![](https://img.aspxhome.com/file/2023/7/64267_0s.jpg)
Python的Flask框架中web表单的教程
2023-05-17 06:11:06
![](https://img.aspxhome.com/file/2023/4/86634_0s.jpg)