| 132 | } |
| 133 | |
| 134 | img_send_message(event_name, data) { |
| 135 | // For the moment, use a custom function instead of overriding the |
| 136 | // event_dispatcher from Mark.js. The data you want from an image |
| 137 | // click is very different than other marks. We are not trying to |
| 138 | // to find out which image was clicked in the way that Scatter |
| 139 | // or Lines returns returns the position of the dot or line on |
| 140 | // (or near) which the user clicked. |
| 141 | // |
| 142 | // Here we want to return the location of the mouse click. |
| 143 | const event_data = this.event_metadata[event_name]; |
| 144 | const data_message = { |
| 145 | click_x: this.scales.x.invert(d3.mouse(this.el)[0]), |
| 146 | click_y: this.scales.y.invert(d3.mouse(this.el)[1]), |
| 147 | }; |
| 148 | // how to get access to raw event: data.data.clientY}; |
| 149 | // for (var datum in data.data) { |
| 150 | // data_message[datum] = data.data[datum]; |
| 151 | // } |
| 152 | this.send({ event: event_data.msg_name, data: data_message }); |
| 153 | } |
| 154 | |
| 155 | draw(animate?) { |
| 156 | this.set_ranges(); |