javascript - 一起使用 flot 和 bootstrap
问题描述
我正在尝试使用 flot.js 绘制一些电流 f。问题是我无法在我的代码中使用 flot.js。我使用的 jquery 版本是 3.4.0 。Flot 版本为 0.8.3
该代码在不包含 flot 库的情况下工作正常。
我的 index.php
<html>
<head>
<title>Jupiter</title>
<link rel="icon" href="./pics/jupiter.png">
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/frontend.css">
<link rel="stylesheet" href="./css/bootstrap-toggle.min.css">
<link rel="stylesheet" href="./css/jquery-confirm.min.css">
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/bootstrap-toggle.min.js"></script>
<script src="./js/bootbox.min.js"></script>
<script src="./js/jquery-confirm.min.js"></script>
<script src="./js/jquery.flot.min.js"></script>
<script src="./js/jquery.flot.time.js"></script>
<script src="./js/jquery.flot.tooltip.js"></script>
</head>
<body>
Main content here
<div id="RFD_curent_1"></div>
</body>
<script src='./js/index.js'></script>
</html>
我的 index.js
function initialize_currents(){
var time=(new Date).getTime();
for(var i=0;i<14400;i++){
//data1.push([time+i-14400000,32]);
data1.push([]);
}
for(var i=0;i<14400;i++){
//data2.push([time+i-14400000,25]);
data2.push([]);
}
//data.push([time,0]);
var dataset = [{label: "0xbb36",data: data1},{label:"0xc563",data:data2}];
$.plot($("#RFD_curent_1"), dataset, options);
}
$(document).ready(function() {
initialize_currents();
}
我在 Chrome 控制台中收到以下警告和错误消息
jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'toLowerCase' of undefined TypeError: Cannot read property 'toLowerCase' of undefined
at Object.t.color.extract
(http://192.168.0.170/js/jquery.flot.min.js:1:695)
at _ (http://192.168.0.170/js/jquery.flot.min.js:1:27080)
at W (http://192.168.0.170/js/jquery.flot.min.js:1:13848)
at new e (http://192.168.0.170/js/jquery.flot.min.js:2:1045)
at Function.t.plot (http://192.168.0.170/js/jquery.flot.min.js:2:3828)
at initialize_currents (http://192.168.0.170/js/index.js:109:11)
at HTMLDocument.<anonymous> (http://192.168.0.170/js/index.js:434:9)
at e (http://192.168.0.170/js/jquery.min.js:2:29453)
at t (http://192.168.0.170/js/jquery.min.js:2:29755) undefined
jquery.min.js:2 Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
at Object.t.color.extract (jquery.flot.min.js:1)
at _ (jquery.flot.min.js:1)
at W (jquery.flot.min.js:1)
at new e (jquery.flot.min.js:2)
at Function.t.plot (jquery.flot.min.js:2)
at initialize_currents (index.js:109)
at HTMLDocument.<anonymous> (index.js:434)
at e (jquery.min.js:2)
at t (jquery.min.js:2)
解决方案
所以我明白问题很简单,你用逗号(,)演示了浮点数,应该是一个点(。)
//data2.push([time+i-14400000.25]);
推荐阅读
- r - 如何处理 dplyr 中 min_rank 的变化
- audio - 在 Lambda 中预加载 MP3 音频 URL(Alexa 技能)
- html - 使用 VBA 在 Gmail 中发送文件路径超链接
- log4j - Log4j 文件名
- python - 无法理解递归函数如何在没有 Python 中的 return 语句的情况下工作
- android - BLE 在 onLeScan 上发送垃圾数据
- java - 使用多个线程访问时无法锁定同步方法
- angular - 反应形式一系列其他反应形式
- sql - 如何增加 Google Cloud SQL 的每分钟查询次数?
- java - Excel Alt+Enter 是否与换行符 \n 相同?