echarts折线图-心电图,主要动画效果-线条慢慢的画
echarts吧
全部回复
仅看楼主
level 1
qa13536514711 楼主
怎么实现啊
2016年11月11日 04点11分 1
level 1
option = {
title : {
text: '动态数据',
subtext: '纯属虚构'
},
tooltip : {
trigger: 'axis'
},
legend: {
data:['最新成交价', '预购队列']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: true}
}
},
dataZoom : {
show : false,
start : 0,
end : 100
},
xAxis : [
{
type : 'category',
boundaryGap : true,
show:false,
data : (function (){
var now = new Date();
var res = [];
var len = 100;
while (len--) {
res.unshift(now.toLocaleTimeString().replace(/^\D*/,''));
now = new Date(now - 2000);
}
return res;
})()
}
],
yAxis : [
{
type : 'value',
scale: true,
show:false,
name : '价格',
boundaryGap: [0.2, 0.2]
}
],
series : [
{
name:'预购队列',
type:'line',
data:(function (){
var res = [];
var len = 100;
while (len--) {
res.push(Math.round(Math.random() * 1000));
}
return res;
})()
}
]
};
var lastData = 11;
var axisData;
clearInterval(timeTicket);
timeTicket = setInterval(function (){
lastData += Math.random() * ((Math.round(Math.random() * 10) % 2) == 0 ? 1 : -1);
lastData = lastData.toFixed(1) - 0;
axisData = (new Date()).toLocaleTimeString().replace(/^\D*/,'');
// 动态数据接口 addData
myChart.addData([
[
0, // 系列索引
Math.round(Math.random() * 1000), // 新增数据
false, // 新增数据是否从队列头部插入
false // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头
],
[
1, // 系列索引
lastData, // 新增数据
false, // 新增数据是否从队列头部插入
false, // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头
axisData // 坐标轴标签
]
]);
}, 2100);
把上面的代码拷到echarts官网任意一个示例里,运行就能结果
2017年04月13日 03点04分 2
好像不能
2018年09月07日 08点09分
嗯,没法动态执行
2018年12月11日 10点12分
1