Trying to retrieve the x-value from a x-coordinate on a d3.js SVG graph -
i'm little stuck on something, , hoping maybe point me in correct direction solution. running searches on google isn't helping me out due wording of searches.
what i'm trying 'value' of x-position on graph. on graph, x-axis made of dates. so, if know plotted x co-ordinate point on graph 200 example, i'd date label x-position 200. there lots of tutorials , examples demonstrate how retrieve x-coordinate (200), not x-coordinate value (date object x-position 200).
what i'm going build user notes feature allows user select x-position on graph , make note @ point. i'll need store object note containing x , y value of coordinates, , since points on graph mapped , remapped applying date object .x, need date points plot on graph can recorded , re-applied, , moved if user decides move note tool around.
anyway, i'm kind of looking way reverse-engineer this...
function getdatex(x, data) { var datex = x(data.date); return datex; }
...but instead of, in case, getting x-coordinate position back, date based on provided x-coordinate position.
any pointers toward solution provide me appreciated. time.
var x = d3.scale.linear() .domain([0,200]) .range([new date("2000-01-01"), new date("2001-01-01")]); new date(x(150)) // sun oct 01 2000 21:00:00 gmt+0900 (東京 (標準時))
or, if have scale date -> number
var x = d3.time.scale() .range([0,200]) .domain([new date("2000-01-01"), new date("2001-01-01")]); x.invert(150) // sun oct 01 2000 21:00:00 gmt+0900 (東京 (標準時))
Comments
Post a Comment