I am creating a data visualisation program using d3, and I have encountered a performance problem while trying to set the opacity of lots of element.

I have event that is called, when the user is changing some data, when this event is fired I compute the opacity for each edges,nodes and text nodes and change them accordingly.

for example - 

```
function onEvent() {
  edges.style("opacity", computeOpacity);
  edges.style("stroke", computeStroke);

  nodes.style("opacity", computeOpacity);
  textNodes.style("opacity", computeOpacity);

}

```

When I have lot of elements (edges/nodes/text nodes counts are greater than 700), the UX is very sluggish and slow.

I checked chrome timeline - and see there is a recalculate style, after that a paint (which paints the all "svg" element) and 2/3 composite layers.

What I can do in order to improve the performance of my code?
The opacity and stroke computation for each edge/node/text node is very important, and is very cheap operation - checking some properties and doing simple Math.max calculation.