D3 brush does not function properly under css transform scale. When svg is under div element, and div element is transformed using CSS scale, the brush operation shows wrong coordinates.
To demonstrate this case, here is the jsFiddle.
It is simple modification from Bostock's Brushable Network example.
What I did was simply putting SVG in the div element and made div element zoom 50% using CSS transform scale(0.5). And the brushing coordinates are not updating because of zooming.
#test {
transform: scale(0.5);
}
Thanks.
Deok
If you use an svg based transform:
Then it'll play nice with the brush:
Updated fiddle.
To fix the calculations you need two things.
1.) Scale the extent rect opposite the div:
2.) Fix the extent calculations:
New example here.
If you use CSS transform you should apply it to all the classes that related by nodes:
When you add
transform: scale(0.5);
you can brush all the node. Try from left to right over node position.Complete jsfiddle here.