File size: 537 Bytes
c211499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as d3 from 'd3';
import * as _ from 'lodash-es';
import * as util from './util.js';

export { positionEdgeLabels };

function positionEdgeLabels(selection, g) {
  var created = selection.filter(function () {
    return !d3.select(this).classed('update');
  });

  function translate(e) {
    var edge = g.edge(e);
    return _.has(edge, 'x') ? 'translate(' + edge.x + ',' + edge.y + ')' : '';
  }

  created.attr('transform', translate);

  util.applyTransition(selection, g).style('opacity', 1).attr('transform', translate);
}