highchart动态添加点,并改变点的颜色为红色
2016-04-15 12:30
417 查看
highchart动态改变点的颜色
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.2.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
$(function () {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
// var flag = "true";
$('#container').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
// var x = , // current time
//y = Math.random();
//{x: 1343862840000, y: 4, marker:{ fillColor: 'red'} },
series.addPoint({x:(new Date()).getTime(), y:Math.random(), marker: {fillColor: '#FF0000',
lineColor: '#FF0000',
states:{
hover:{
fillColor: '#FF0000',
lineColor: '#FF0000'
}
}
}}, true, true);
}, 1000);
}
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: (function() {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -5; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
})()
}]
});
});
});
</script&
4000
gt;
</head>
<body>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.2.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
$(function () {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
// var flag = "true";
$('#container').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
// var x = , // current time
//y = Math.random();
//{x: 1343862840000, y: 4, marker:{ fillColor: 'red'} },
series.addPoint({x:(new Date()).getTime(), y:Math.random(), marker: {fillColor: '#FF0000',
lineColor: '#FF0000',
states:{
hover:{
fillColor: '#FF0000',
lineColor: '#FF0000'
}
}
}}, true, true);
}, 1000);
}
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: (function() {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -5; i <= 0; i++) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
})()
}]
});
});
});
</script&
4000
gt;
</head>
<body>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>
相关文章推荐
- nmon性能统计工具使用-初认识
- Android小程序-Walker注册页面(三)
- 仿QQ切换按钮,纯代码实现,告别图片
- 添加打印机出现错误代码:0x000006d9
- 地理空间距离计算优化
- Java内存访问重排序的研究
- 百度业务重构,李彦宏是想学谷歌吗?
- hello objective-c
- 通配符的使用方法
- UIViewAnimationOptions类型
- java对象之间相互循环引用实例
- 性能监控系统的搭建(转)
- 进度条第七周
- dfs实现迷宫
- 美团推荐算法实践
- Linux下显示IP地理位置信息的小工具-nali
- 贪心算法知识(一)
- 如何成为一个架构师
- C#中CopyTo()和Clone()的区别
- locationInView