jQuery setInterval显示违规警告

时间:2018-12-22 06:14:51

标签: jquery setinterval amcharts

我正在使用amChart.js来显示一些图表。所以我想通过setInterval刷新图表。添加setInterval后,它将在控制台中显示无限警告错误。

警告错误为:

  

amcharts.js:1 [违规]向滚动阻止的“ mousewheel”事件添加了非被动事件侦听器。考虑将事件处理程序标记为“被动”,以使页面更具响应性。参见https://www.chromestatus.com/feature/5745543795965952

     

[Violation]“加载”处理程序花费了1223ms

     

50 [Violation]在执行JavaScript时强制重排花费了ms   fav-1.png:1 GET http://localhost/doha-oasis/wp-content/uploads/2018/10/fav-1.png 404(未找到)

     

98 [Violation]'setInterval'处理程序花费了ms   amcharts.js:1 [违规]

的“ mousewheel”输入事件的处理被延迟      

3574毫秒,因为主线程忙。考虑将事件处理程序标记为“被动”,以使页面更具响应性。

脚本:

<script type="text/javascript">
CompleteF9();

function CompleteF9() {
    fetchdata3();

    function fetchdata3() {
        var htHum_det = jQuery.ajax({
            url: '<?php bloginfo('
            template_directory ')?>/ajax-wellness.php',
            type: 'post',
            data: {
                'table_name1': 'table1',
                'table_name2': 'table2',
                'table_name3': 'table3',
                'table_name4': 'table4',
                'table_name5': 'table5',
                'table_name6': 'table6',
                'table_name7': 'table7',
                'table_name8': 'table8',
                'table_name9': '',
                'flag': 'eight'
            },
            dataType: 'json',
            async: false,
            success: function(result) {
                bCO2Call3(result.dataProvider);
            },
            error: function(ts) {
                alert("Error:" + ts.responseText);
            }
        });
    }

    $(document).ready(function() {
        setInterval(fetchdata3, 2000);
    });
    var chart = AmCharts.makeChart("htHum", {
        "type": "serial",
        "theme": "black",
        "dataProvider": "",
        "mouseWheelZoomEnabled": true,
        "zoomOutOnDataUpdate": false,
        "valueAxes": [{
            "logarithmic": true,
            "dashLength": 1,
            "gridAlpha": 0.2,
            "guides": [

                {
                    "dashLength": 6,
                    "label": "AVERAGE(65%RH)",
                    "fontSize": 10,
                    "inside": true,
                    "position": "right",
                    "lineColor": "#fff",
                    "lineAlpha": 1,
                    "value": 65,
                }
            ],
            position: "left"
        }],
        "gridAboveGraphs": true,
        "startDuration": 0.2,
        "graphs": [{
            "title": "Hotel Tower F5",
            "theme": "light",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value1"
        }, {
            "title": "Hotel Tower F23",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value2"
        }, {
            "title": "Hotel Tower F24",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value3"
        }, {
            "title": "Hotel Tower F25",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value4"
        }, {
            "title": "Hotel Tower F26",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value5"
        }, {
            "title": "Hotel Tower F27",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value6"
        }, {
            "title": "Hotel Tower TF1",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value7"
        }, {
            "title": "Hotel Tower TF2",
            "balloonText": "[[title]]: <b>[[value]]%RH</b>",
            "valueField": "value8"
        }],
        "chartCursor": {
            "categoryBalloonDateFormat": "YYYY-MM-DD JJ:NN:SS",
            "cursorPosition": "mouse",
            "selectWithoutZooming": false,
            "oneBalloonOnly": true
        },
        "dataDateFormat": "YYYY-MM-DD JJ:NN:SS",
        "categoryField": "category",
        "categoryAxis": {
            minPeriod: "ss",
            "parseDates": true
        },
        "titles": [{
            "text": "Hotel Tower Humidity",
            "size": 15
        }],
        "legend": {
            "color": "#fff",
            "valueText": "[[value]]%RH",
            "position": "right",
            "pulled": true,
            "align": "left",
            "labelText": "[[title]]",
            "rollOverGraphAlpha": 20,
            "markerLabelGap": 20
        }
    });

    function bCO2Call3(data) {
        var dataProvider = [];
        chart.dataProvider = data;
        chart.validateData();
    }
}
</script>

我正在将同一脚本的副本用于其他图表。

0 个答案:

没有答案