我使用MetricsGraphics库和D3绘制curveStep时间序列图。当附加数据可用时,将重绘图。
下面是代码,这里是小提琴:https://jsfiddle.net/5kbr5mk5/
var mydata = [];
var intervalID = setInterval( function addsample() {
var newval = Math.random() * 10;
var mysample = {
timestamp: new Date(),
value: newval };
mydata.push( mysample );
console.log("sample count: " + mydata.length);
if (mydata.length == 100) clearInterval(intervalID);
MG.data_graphic({
title: "Time Series Plot",
data: mydata,
interpolate: d3.curveStep,
chart_type: 'line',
height: 400,
width: 600,
xax_count: 3,
x_accessor: 'timestamp',
y_accessor: 'value',
area: false,
target: '#chart'
});},1000);
当剧情正在更新时,奇怪的动画(变形)来自何处,我该如何抑制它?