Thanks Kyle. Is there ever a need to "re-order" the scope of the elements and, if so, what's the best way to do so?
On Mon, Apr 23, 2012 at 1:22 PM, Kyle Foreman <kylef...@gmail.com> wrote:
Well, SVG does not have a z-index that you can alter, so it's all based on element ordering in the DOM. So, the simplest way is adding elements to the DOM starting with the lowest (I.e. background) layer. E.g.:svg = d3.select('body').append('svg')svg.append('rect').attr('id', 'layer1')svg.append('circle').attr('id', 'layer2')
Or if you need to do things more dynamically insert() allows you to add elements places other, than the end. E.g.:
On Jan 8, 2013 1:05 AM, "Shreeram Kushwaha" <ram90...@gmail.com> wrote:
>
> Suppose I have rectangle elements each inside a <g> tag. And on mouseover I want to bring the rectangle in FRONT. Then how I have to call the moveToFront().
>
Have you tried using the .on()?
May be d3.selectAll("rect").on("mouseover", moveToFront)
Cheers,
Sajjad
(handheld)
On Jan 8, 2013 4:00 AM, "Shreeram Kushwaha" <ram90...@gmail.com> wrote:
I am not talking about dragging. I am talking about this type of move to front.
I know. My example is about moving to front while dragging. This is the move to front part: this.parentNode.appendChild(this); You just have to apply it to the g element like this: