NVD3.js.를 사용하여 작성된 간단한 선형 차트가 있습니다. 나는, 타이머를 기반으로 간단한 다시 그리기를 작성 내가 본 예에서 가져온,하지만 난 오류실시간 데이터가있는 NVD3 선형 차트
catch되지 않은 형식 오류 얻을 것 : 정의되지 않은
JS의 'Y'속성을 읽을 수 없습니다를
var data = [{
"key": "Long",
"values": getData()
}];
var chart;
nv.addGraph(function() {
chart = nv.models.cumulativeLineChart()
.x(function (d) { return d[0] })
.y(function (d) { return d[1]/100 })
.color(d3.scale.category10().range());
chart.xAxis
.tickFormat(function (d) {
return d3.time.format('%x')(new Date(d))
});
chart.yAxis
.tickFormat(d3.format(',.1%'));
d3.select('#chart svg')
.datum(data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
function redraw() {
d3.select('#chart svg')
.datum(data)
.transition().duration(500)
.call(chart);
}
function getData() {
var arr = [];
var theDate = new Date(2012, 01, 01, 0, 0, 0, 0);
for (var x = 0; x < 30; x++) {
arr.push([theDate.getTime(), Math.random() * 10]);
theDate.setDate(theDate.getDate() + 1);
}
return arr;
}
setInterval(function() {
var long = data[0].values;
var next = new Date(long[long.length - 1][0]);
next.setMonth(next.getMonth() + 1)
long.shift();
long.push([next.getTime(), Math.random() * 100]);
redraw();
}, 1500);
입니다 (주석 후)
문제를 나타내는 jsfiddle을 추가 할 수 있습니까? –
http://jsfiddle.net/khp9d/ –
@JaimalChohan 어떻게 해결 했습니까? – Sajeetharan