Skip to content

Instantly share code, notes, and snippets.

View rodighiero's full-sized avatar

Dario Rodighiero rodighiero

View GitHub Profile
@rodighiero
rodighiero / canvasClickLocation.js
Created March 18, 2018 09:08 — forked from ogiermaitre/canvasClickLocation.js
[Canvas click location] #d3 #javascript
// when the user click on the map, find what objects are under the mouse pointer.
// inspired by: https://bl.ocks.org/mbostock/444757cc9f0fde320a5f469cd36860f4
clickSubject:()=>{
// check if data are loaded
if( internal.data.json ){
// compute the pointer position, relative to the canvas origin
let eventX = d3.event.x-internal.canvas.bb.left, eventY = d3.event.y-internal.canvas.bb.top
// if a zoom transformation has been applied, compute the mouse position in data space coordinates.
@rodighiero
rodighiero / Hexagonal force-directed graph
Last active April 2, 2024 02:39 — forked from mbostock/.block
Hexagonal force-directed graph
license: gpl-3.0
height: 500
border: no