不能强制HighCharts速度计为零
Can't force HighCharts Speedometer to Zero
我正在使用highcharts速度计。我基本上是在装一个连接表。如果有一个良好的连接,那么仪表将在30和100之间跳动。如果连接返回任何(Ajax调用)而不是4 &200,应该会降到0。我的电话正在接通…当服务器启动时,一切正常。当我关闭Apache时,它不会归零。我在函数(图表)上测试了几个场景,看看它是否很简单(我确信它仍然是,我只是没有看到它)。什么都没起作用。我把图表的点设为0。但它仍然不会趋近于0。有什么建议吗?上帝啊,我希望如此。我希望明天能把它完成,然后我就可以在工作中使用它了。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" >
<title>Sales Meter</title>
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
var flag;
var xmlhttp;
var url="http://192.168.0.5/ajax_info.txt"+'?_dc='+(new Date()).getTime();
//ajax call
function loadXMLDoc(url, cfunc){
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else {
xmlhttp=new ActiveObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url, true);
xmlhttp.send();
}
function myFunction(){
loadXMLDoc(url, function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
flag = 1;
}
});
}
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
title: {
text: 'Sales-O-Meter'
},
pane: {
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF'],
[1, '#333']
]
},
borderWidth: 0,
outerRadius: '109%'
}, {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#333'],
[1, '#FFF']
]
},
borderWidth: 1,
outerRadius: '107%'
}, {
// default background
}, {
backgroundColor: '#DDD',
borderWidth: 0,
outerRadius: '105%',
innerRadius: '103%'
}]
},
// the value axis
yAxis: {
min: 0,
max: 100,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 2.5,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 15,
tickWidth: 1,
tickPosition: 'inside',
tickLength: 5,
tickColor: '#666',
labels: {
step: 5,
rotation: 'auto'
},
title: {
text: 'sales/min'
},
plotBands: [{
from: 0,
to: 10,
color: '#DF5353' // green
}, {
from: 10,
to: 20,
color: '#DDDF0D' // yellow
}, {
from:20,
to: 100,
color: '#55BF3B' // red
}]
},
series: [{
name: 'Speed',
data: [80],
tooltip: {
valueSuffix: ' sales/sec'
}
}]
},
// Add some life
function (chart) {
flag = 0;
myFunction();
setInterval(function () {
if(flag==1){
var point = chart.series[0].points[0],
newVal,
inc = Math.round((Math.random() - .5) * 20);
newVal = point.y + inc;
if (newVal < 0 || newVal > 100) {
newVal = point.y - inc;
}
point.update(newVal);
}
else{
var point = chart.series[0].points[0],
newVal = 0,
inc = 0;
point.update(newVal);
}
}, 1000);
});
});
</script>
</head>
<body>
<script src="highcharts.js"></script>
<script src="highcharts-more.js"></script>
<!--<script src="exporting.js"></script>-->
<div id="container" style="width: 500px; height: 400px; margin: 0 auto"></div>
</body>
</html>
看起来你需要在SETI热函数中调用我的函数,因为它需要被调用来设置标志。
function (chart) {
flag = 0;
setInterval(function () {
myFunction();
if(flag==1){
相关文章:
- 在Web应用程序中使用Highcharts javascript
- Wacom stu-430签名捕获速度太慢
- 在Highcharts中,我们可以通过任何方式在渲染图表之前获得plotWidth和plotHeight
- HighCharts长标题文本在某些元素上重叠
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- 如何在速度模板中获取LiferayPortlet实例id
- Highcharts-如何在自定义格式化程序中获得默认的y轴标签格式化程序
- Highcharts仪表未显示
- Highcharts-图表外的图例定位
- 我想放慢html中进程栏的速度
- Highcharts动态烛台
- 在highcharts.js中向点弹出窗口动态添加文本
- Highcharts 3d调整zindex错误
- 构建多个图表时,HighCharts加载数据的速度较慢
- 如何减缓Highcharts的绘图速度
- 如何从excel文件中输入,并在速度计上显示输出
- 我们可以只测量垂直鼠标速度使用光标计
- 不能强制HighCharts速度计为零
- 如何保持航海图速度计在范围内
- 测量速度计