javascript - D3JS — my X axis grid line isn't showing up -


i'm @ loss why x axis lines showing fine, not y. ideas?

i'm 99% sure has

.attr("transform", "translate(0," + height + ")") 

line since every time adjust show x axis pieces, in wrong space.

entire code follows:

<html>  <head>  <style>  /* set css */  body { font: 12px arial;}  path {         stroke: steelblue;         stroke-width: 2;         fill: none; }  .axis path, .axis line {         fill: none;         stroke: grey;         stroke-width: 1;         shape-rendering: crispedges; }  .grid .tick {     stroke: lightgrey;     opacity: 0.7; } .grid path {       stroke: lightgrey;       stroke-width: 0; }  </style>  </head>  <body>  <!-- load d3.js library --> <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>  <h1>temperature chart on time</h1>  <script> // set dimensions of canvas / graph var     margin = {top: 30, right: 20, bottom: 30, left: 50},         width = 800 - margin.left - margin.right,         height = 270 - margin.top - margin.bottom;  // display date , time var     parsedate = d3.time.format("%y-%m-%d %h:%m:%s").parse;  // set x , y axis ranges var     x = d3.time.scale().range([0, width]); var     y = d3.scale.linear().range([height, 0]);  // define x , y axes var     xaxis = d3.svg.axis().scale(x)         .orient("bottom").ticks(10);  var     yaxis = d3.svg.axis().scale(y)         .orient("left").ticks(10);  // define line var     valueline = d3.svg.line()         .x(function(d) { return x(d.measurementtime); })         .y(function(d) { return y(d.temperature); });          // adds svg canvas 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 + ")");  //draw x axis grid tick marks function make_x_axis() {     return d3.svg.axis()         .scale(x)          .orient("bottom")          .ticks(5) }  //draw y axis grid tick marks function make_y_axis() {     return d3.svg.axis()         .scale(y)         .orient("left")         .ticks(5) }  //draw x axis grid lines svg.append("g")         .attr("class", "grid")         .attr("transform", "translate(0," + height + ")")         .call(make_x_axis()             .ticksize(-height, 0, 0)             .tickformat("")         ) //draw y axis grid lines     svg.append("g")         .attr("class", "grid")         .call(make_y_axis()             .ticksize(-width, 0, 0)             .tickformat("")         )  // data d3.json("data.php", function(error, data) {         data.foreach(function(d) {                 d.measurementtime = parsedate(d.measurementtime);                 d.temperature = +d.temperature;         });          // center line on graph         x.domain(d3.extent(data, function(d) { return d.measurementtime; }));         y.domain([60, d3.max(data, function(d) { return d.temperature; })+10]);           // add valueline path         svg.append("path")                 .attr("class", "line")                 .attr("d", valueline(data));          // add x axis         svg.append("g")                 .attr("class", "x axis")                 .attr("transform", "translate(0," + height + ")")                 .call(xaxis);          // add y axis         svg.append("g")                 .attr("class", "y axis")                 .call(yaxis);  });  </script>  </html> 


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -