Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 线连接动画不适用于ECG_Javascript_Jquery_Jquery Animate - Fatal编程技术网

Javascript 线连接动画不适用于ECG

Javascript 线连接动画不适用于ECG,javascript,jquery,jquery-animate,Javascript,Jquery,Jquery Animate,我需要将线与值连接起来,最初工作正常,但在某个点之后动画不工作。它应该类似于ECG图形。图形应该继续,而不停止切片数据 var continueAnimation=true; $(文档).ready(函数(){ sendArray(); }); 变量ecgVAlues=[51, 59, 61, 66, 76, 88, 103, 110, 122, 132, 139, 154, 166, 178, 193, 210, 232, 254, 273, 286, 286, 278, 256, 212,

我需要将线与值连接起来,最初工作正常,但在某个点之后动画不工作。它应该类似于ECG图形。图形应该继续,而不停止切片数据

var continueAnimation=true;
$(文档).ready(函数(){
sendArray();
});
变量ecgVAlues=[51, 59, 61, 66, 76, 88, 103, 110, 122, 132, 139, 154, 166, 178, 193, 210, 232, 254, 273, 286, 286, 278, 256, 212, 164, 122, 83, 51, 34, 15, 12, 2, 2, 5, 7, 0, -5, 0, 5, 0, 2, 5, 5, 5, 10, 12, 17, 17, 20, 22, 20, 22, 17, 17, 15, 12, 10, 7, 10, 12, 7, 5, 7, 7, 10, 5, 10, 12, 17, 17, 22, 20, 17, 20, 20, 22, 34, 46, 44, 49, 61, 51, 42, 32, 24, 10, 0, -2, -5, 0, 0, 2, -5, 56, 381, 884, 784, -12, -208, -22, -27, 7, -10, 2, 2, 7, 10, 10, 10, 17, 20, 29, 42, 46, 56, 66, 71, 81, 93, 112, 125, 149, 168, 186, 198, 205, 200, 173, 127, 83, 39, 2, -27, -56, -71, -81, -88, -95, -93, -90, -95, -100, -95, -100, -100, -105, -103, -105, -110, -110, -115, -117, -122, -129, -129, -139, -144, -149, -161, -168, -171, -181, -183, -186, -188, -193, -190, -193, -190, -190, -193, -193, -193, -195, -198, -195, -188, -188, -186, -181, -176, -161, -149, -142, -137, -112, -107, -117, -112, -117, -122, -127, -127, -122, -112, -105, -95, -88, -51, 190, 674, 793, 56, -291, -134, -110, -56, -81, -61, -61, -49, -46, -42, -34, -27, -12, 2, 12, 29, 44, 61, 78, 103, 127, 151, 176, 200, 229, 247, 264, 283, 288, 283, 259, 222, 195, 164, 139, 132, 122, 129, 132, 137, 144, 159, 154, 161, 168, 166, 171, 178, 186, 193, 190, 188, 193, 188, 183, 181, 181, 176, 171, 178, 178, 168, 164, 164, 166, 164, 161, 159, 154, 156, 154, 154, 146, 139, 139, 137, 134, 129, 129, 127, 137, 144, 156, 149, 159, 166, 146, 139, 129, 120, 107, 103, 95, 98, 103, 103, 100, 95, 242, 679, 1079, 593, -51, -22, 81, 85, 83, 88, 83, 95, 100, 100, 107, 105, 110, 120, 122, 129, 144, 149, 151, 159, 171, 188, 208, 234, 264, 288, 310, 325, 327, 310, 276, 232, 181, 132, 88, 61, 44, 32, 24, 17, 12, 7, 12, 20, 2, -2, 0, -7, -20, -27, -27, -32, -44, -59, -71, -78, -78, -78, -78, -78, -90, -103, -117, -129, -134, -134, -132, -129, -120, -112, -110, -105, -107, -103, -100, -103, -105, -107, -110, -103, -88, -73, -73, -66, -44, -46, -54, -59, -68, -81, -90, -93, -93, -88, -85, -85, -88, -56, 195, 701, 862, 81, -293, -100, -95, -51, -68, -49, -44, -29, -17, -7, -2, 7, 20, 34, 51, 71, 78, 95, 110, 127, 144, 156, 178, 193, 215, 234, 244, 247, 237, 215, 166, 112, 61, 17, -20, -42, -56, -66, -66, -66, -68, -66, -59, -59, -63, -59, -54, -56, -61, -56, -61, -63, -61, -61, -63, -66, -66, -68, -71, -76, -81, -88, -93, -100, -107, -115, -122, -127, -132, -134, -137, -142, -142, -149, -149, -151, -156, -159, -161, -159, -149, -137, -132, -132, -112, -103, -115, -117, -129, -144, -154, -161, -159, -156, -154, -144, -146, -132, 49, 522, 811, 161, -327, -215, -161, -112, -125, -110, -105, -93, -88, -78, -73, -66, -56, -44, -34, -24, -12, 2, 7, 17, 39, 59, 78, 100, 117, 139, 154, 161, 164, 142, 103, 61, 15, -24, -59, -83, -98, -105, -110, -107, -105, -103, -100, -95, -93, -85, -83, -73, -68, -61, -56, -49, -42, -39, -34, -32, -27, -24, -22, -20, -22, -17, -17, -17, -17, -12, -7, -7, -5, -5, -2, -2, 0, 0, 0, 0, 5, 10, 12, 15, 17, 24, 42, 54, 51, 68, 88, 81, 76, 71, 56, 49, 44, 42, 49, 54, 59, 63, 61, 149, 505, 952, 769, 17, -125, 51, 49, 83, 71, 83, 88, 95, 100, 105, 105, 117, 127, 134, 146, 156, 166, 178, 186, 200, 215, 227, 249, 266, 288, 303, 317, 317, 310, 283, 237, 186, 146, 105, 71, 54, 44, 34, 27, 24, 24, 27, 29, 24, 22, 29, 29, 32, 34, 39, 42, 44, 46, 49, 49, 51, 51, 49, 49, 44, 44, 44, 39, 34, 34, 34, 32, 29, 29, 32, 29, 27, 27, 24, 22, 22, 24, 22, 22, 22, 22, 22, 24, 34, 46, 54, 56, 71, 73, 61, 61, 51, 34, 27, 15, 15, 20, 20, 22, 17, 34, 220, 703, 996, 361, -166, -63, 2, 27, 17, 27, 27, 37, 39, 44, 44, 51, 59, 71, 83, 90, 105, 122, 129, 144, 159, 173, 193, 215, 242, 261, 276, 286, 286, 271, 232, 181, 137, 100, 54, 24, 12, -2, -5, -12, -12, -17, -17, -7, -17, -20, -10, -10, -10, -5, -2, 0, 0, 2, 7, 7, 5, 5, 2, 0, 0, -7, -5, -12, -17, -17, -22, -22, -20, -24, -22, -20, -24, -22, -22, -17, -17, -22, -17, -20, -20, -17, -22, -17, -15, -2, 10, 7, 15, 32, 27, 17, 12, 2, -12, -20, -22, -22, -15, -12, -15, -17, 37, 330, 847, 884, 56, -232, -34, -44, -5, -27, -7, -10, 0, 2, 5, 10, 17, 27, 39, 54, 66, 83, 95, 110, 129, 139, 161, 181, 203, 227, 249, 264, 269, 264, 242, 205, 154, 110, 66, 29, 5, -15, -20, -29, -39, -49, -54, -46, -51, -61, -61, -59, -56, -49, -44, -34, -27, -22, -20, -15, -7, -5, 0, 2, 0, 5, 0, 2, 7, 2, 0, 2, 0, -2, -7, -12, -20, -27, -37, -44, -54, -59, -59, -66, -68, -71, -73, -71, -61, -56, -59, -61, -44, -56, -76, -83, -98, -112, -120, -132, -134, -129, -127, -125, -129, -88, 171, 691, 786, -12, -337, -166, -154, -110, -132, -117, -110, -100, -98, -93, -88, -76, -66, -54, -42, -27, -12, -5, 7, 27, 42, 61, 83, 105, 132, 154, 171, 178, 176, 154, 115, 63, 15, -29, -71, -100, -120, -137, -144, -151, -154, -159, -159, -164, -166, -161, -161, -161, -161, -156, -161, -156, -156, -159, -156, -159, -159, -164, -161, -166, -173, -173, -178, -181, -178, -178, -178, -178, -176, -168, -171, -164, -156, -149, -142, -139, -132, -122, -110, -105, -93, -76, -59, -39, -34, -12, 2, 2, 7, 7, 2, 7, 7, 17, 32, 44, 59, 63, 71, 215, 635, 1016, 557, -51, -34, 78, 107, 112, 127, 137, 149, 154, 161, 161, 159, 166, 176, 183, 188, 198, 208, 217, 227, 234, 249, 261, 276, 291, 308, 322, 325, 320, 305, 271, 220, 171, 122, 78, 49, 24, 15, 7, 2, 0, -7, -2, -2, -15, -12, -2, 0, 0, 10, 17, 22, 24, 34, 34, 34, 39, 37, 34, 34, 34, 34, 34, 32, 34, 37, 34, 39, 39, 39, 39, 37, 37, 32, 27, 27, 22, 10, 7, 5, -5, 0, -2, 2, 12, 17, 10, 17, 24, 7, 2, -2, -15, -22, -22, -22, -17, -10, -5, -5, -10, 83, 449, 920, 754, -37, -188, 0, -22, 5, -5, 0, 2, 10, 7, 12, 10, 17, 27, 39, 54, 66, 73, 83, 98, 107, 120, 134, 154, 173, 193, 210, 217, 217, 208, 176, 132, 78, 32, -10, -49, -73, -95, -107, -122, -129, -13
var constant=351;
        function animate() {

            if (x > data.length - 1) {
                return;
            }

            if (continueAnimation) {
                requestAnimationFrame(animate);
            }

            if (x++ < panAtX) {

                var temp = data[x];
                var final = constant-(temp);
                ctx.fillRect(x, final, 1, 1);
                ctx.lineTo(x, final);
                ctx.stroke();
            } else {

                ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.beginPath();  // reset the path


                for (var xx = 0; xx < panAtX; xx++) {
                    var y = data[x - panAtX + xx];
                    var final = constant - (y);
                    ctx.fillRect(xx, final, 1, 1);
                    ctx.lineTo(xx, final);                        
                }
                ctx.stroke();
            }
        }