당신은 이미 목록에있는 데이터를 가지고 있기 때문에 http://www.d3noob.org/2012/12/starting-with-basic-d3-line-graph.html
귀하의 경우에도 간단 여기에 모습을 가질 수 있습니다. 두 개의 배열로 나누지 마십시오. [{date : ..., value : ...}, {date : ..., value : ...} ...] 하나의 목록을 갖는 것이 좋습니다.
init d3 (x 축에 "시간"범위가 있음을 알 수 있듯이이를 사용하는 경우 d3.time.format ("% d- % b- % y") .parse 함수) : 다음
var margin = {top: 30, right: 20, bottom: 30, left: 50},
width = 600 - margin.left - margin.right,
height = 270 - margin.top - margin.bottom;
var x = d3.time.scale().range([0, width]);
var y = d3.scale.linear().range([height, 0]);
var xAxis = d3.svg.axis().scale(x)
.orient("bottom").ticks(5);
var yAxis = d3.svg.axis().scale(y)
.orient("left").ticks(5);
/* ---------------------- This is your line --------------------- */
var valueline = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.value); });
/* -------------------------------------------------------------- */
var svg = d3.select("body")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
과 데이터의 목록을 광고 (추가 {날짜 ...를 값 ...}
svg.append("path") // Add the valueline path.
.attr("d", valueline(data));
svg.append("g") // Add the X Axis
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g") // Add the Y Axis
.attr("class", "y axis")
.call(yAxis);
PS : I 사용 여기에 "가치"가 있지만 질문에서 "가치"를 사용하십시오.
[예제 제공 : Mike Bostock] (http://bl.ocks.org/mbostock/raw/3883245/)을 참조하십시오. –