gpt4 book ai didi

javascript - 如何减慢 Highcharts 绘图速度

转载 作者:行者123 更新时间:2023-11-27 23:05:46 26 4
gpt4 key购买 nike

1.你好,我想知道你的意见。我试图绘制从数据库中获取的一些信号。一切运行良好,我想在 10 秒窗口内绘制心电图信号。我一次采集 2500 个样本,通过 Json 发送并绘制而不是通过 Highcharts JS 发送。问题是渲染 JS 默认绘制时间为 500 毫秒。我希望它的情节更像是医院的监控......以放慢速度。如何做呢?

2.请问您是否知道是否有可能将 X 轴设置为计数器,以便在每次渲染新图表时标记值?就像每渲染 1250 个值一样,它会在 X 轴上显示 5,2500 后它将是 10.......我想将其从计数值更改为时间轴......值的频率是 250 毫秒

这是代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script>

var ID = 1;

$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'line',
animation: 'false'
},
series: [{marker: {
enabled: false
}}]
};

function posielanie () {
$.getJSON("data.php",{posielam : ID}, function(data) {
options.series[0].data = data;
console.log(data);
var chart = new Highcharts.Chart(options);
ID = ID+2500;
});
setTimeout(posielanie, 2000);
}
posielanie ();
});


</script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<div id="container" style="height: 300px"></div>
</body>
</html>

和data.php

<?php

header('Content-Type: application/json');

$con = mysqli_connect("ADRESS","USER","PSW","TBL");


$a= $_GET['posielam'];

if (mysqli_connect_errno($con))
{
echo "Failed to connect to DataBase: " . mysqli_connect_error();
}else
{
$result = mysqli_query($con, "SELECT * FROM samples LIMIT $a, 2500 ");
while ( $row= mysqli_fetch_array($result)){
$out[]=$row['sample'];
}

echo json_encode($out, JSON_NUMERIC_CHECK);
}
mysqli_close($con);

?>

最佳答案

您需要像这样使用plotOptions.series.animation选项:

    plotOptions: {
series: {
animation: {
duration: 1000
}
}
},

Example fiddle - 尝试更改持续时间以查看不同的渲染时间

Link to relevant Highcharts docs

关于javascript - 如何减慢 Highcharts 绘图速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36602676/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com