Writing a small prototype using D3js, I wrapped out the playground into an Game
object:
var Game = function(){
this.svg = d3.select( "body").append( "svg")
.attr( "width", 500)
.attr( "height", 500)
;
_this = this;
this.svg.on( 'click', function(){ _this.click()});
To capture mouse clicks on the SVG I want to use D3's methods:
Game.prototype.click = function(){
var M = d3.mouse( this.svg[0][0]);
console.log( "Clicked: "+M[0]+':'+M[1]);
}
I really doubt that this.svg[0][0]
, that I came up to after experiments, is the intended way of passing the container object in this case.
Question: what's the right way of passing the container to d3.mouse()
function in D3js, having a varialbe holding the element?