var topleft = svg.append("g"); d3.csv("test.csv", function(data) { //Hand CSV data off to global variable so it's accessible later. dataset = data; var y = d3.scale.linear().domain([0,d3.max(dataset,function(d){return +d.lw;})]).range([h-cmargin.bottom,cmargin.top]); var yAxis = d3.svg.axis() .scale(y) .orient('left') .ticks(3); var xAxis = d3.svg.axis() .scale(x2) .tickFormat(format) .ticks(3) .orient('bottom'); var lineA = d3.svg.line() .interpolate("basis") .x(function(d, i) { return x(d.hour); }) .y(function(d, i) { return y(+d.lw); }); var lineB = d3.svg.line() .interpolate("basis") .x(function(d, i) { return x(d.hour); }) .y(function(d, i) { return y(+d.yest); }); var lineC = d3.svg.line() .interpolate("basis") .x(function(d, i) { return x(d.hour); }) .y(function(d, i) { return y(+d.tod); }); //1st widget //last week topleft.append("path") .datum(dataset) .attr("class", "line") .style("stroke","grey") .style("fill","none") .style("opacity",0.4) .style("stroke-width",4) //.style("stroke-dasharray", ("14, 3")) .attr("d", lineA) .append("title") .text("Last Week"); //yesterday topleft.append("path") .datum(dataset) .attr("class", "line") .style("stroke","black") .style("fill","none") .style("opacity",0.4) .style("stroke-width",4) .attr("d", lineB) .append("title") .text("Yesterday"); //today topleft.append("path") .datum(dataset.filter(function(d) {return d.hour < 11;})) //.filter(function(dataset) {return d.hour<6;}) .attr("class", "line") .style("stroke","#18bdff") .style("fill","none") .style("opacity",1) .style("stroke-width",4) .attr("d", lineC) .append("title") .text("Today"); topleft.append('g') .attr('class', 'y axis') .attr('transform', 'translate('+cmargin.left+',0)') .call(yAxis); topleft.append('g') .attr('class', 'x axis') .attr('transform', 'translate(0,'+(h-(cmargin.bottom))+')') .call(xAxis); });