Draw A Vertical Line Representing The Current Date In D3 Gantt Chart
hi this maybe very easy for you guys i just need to draw a vertical line that represents the current date in my d3 gantt chart. i already figure out the values for my y i just havi
Solution 1:
Just get the date today. No need to get its date, month, and year because it will return a string.
All you have to do is put the date in your x
variable to jive with its domain
var today = new Date();
var dd = today.getDate(); //<<===== no need
var mm = today.getMonth()+1; //January is 0! //<<===== no need
var yyyy = today.getFullYear(); //<<===== no need
svg.append("line")
.attr("x1", x(today)) //<<== change your code here
.attr("y1", 0)
.attr("x2", x(today)) //<<== and here
.attr("y2", height - margin.top - margin.bottom)
.style("stroke-width", 2)
.style("stroke", "red")
.style("fill", "none");
Post a Comment for "Draw A Vertical Line Representing The Current Date In D3 Gantt Chart"