首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >同时使用flot和bootstrap

同时使用flot和bootstrap
EN

Stack Overflow用户
提问于 2019-07-11 19:20:56
回答 2查看 225关注 0票数 0

我正在尝试使用flot.js来绘制一些电流f。问题是我不能在我的代码中使用flot.js。我使用的jquery版本是3.4.0。Flot版本为0.8.3

代码在没有包含flot库的情况下运行良好。

我的index.php

代码语言:javascript
复制
    <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

代码语言:javascript
复制
    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控制台中,我收到以下警告和错误消息

代码语言:javascript
复制
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)
EN

回答 2

Stack Overflow用户

发布于 2019-07-11 19:33:46

所以我明白问题很简单,您使用逗号(,)演示了浮动,并且应该是一个点(.)

代码语言:javascript
复制
//data2.push([time+i-14400000.25]);
票数 0
EN

Stack Overflow用户

发布于 2020-05-16 02:25:45

Flot要求数据集中包含两个元素的数组(x-value,y-value)。你给它一个由许多空数组组成的数组。您可能应该使用像这样的东西

代码语言:javascript
复制
data2.push([i, i]);

作为测试数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56988038

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档