首页 > 解决方案 > 一起使用 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)

标签: javascriptbootstrap-4flot

解决方案


所以我明白问题很简单,你用逗号(,)演示了浮点数,应该是一个点(。)

//data2.push([time+i-14400000.25]);

推荐阅读