N
N
Ninja Mate2016-04-29 11:23:08
JavaScript
Ninja Mate, 2016-04-29 11:23:08

Is it possible to somehow select an SVG (D3) element by setting a function not from the svg itself?

I made a chart on d3.js and there is a mouse hover event

var myChart = d3.select(this.refs.chart).append("svg")
.selectAll("rect")
.on('mouseover', function(d){
                
                ...
                d3.select(this)//хочу так же но из функции на странице
                    .style('opacity', 0.5)
            })

On the page there is a table in which you need to hover over a row with values ​​and so that the corresponding column is highlighted. Can the index be used in .data(dataArray) or something else...
How to select an element through a function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2016-04-29
@victorzadorozhnyy

The SVG element is a full page element and any of its child elements can be accessed via selectors.
Once you have the desired element, you can assign event handlers to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question