almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.86k stars 1.48k forks source link

Network - Edge tail and edge head position #4213

Open jrmie opened 5 years ago

jrmie commented 5 years ago

Is it possible to add edge options to set position of the tail and the head instead of the node center? In graphviz, edge attributes headport and tailport allow to set position of the edge on the node's border with cardinal points.

image

The second edge is an example of what I would like to display.

mojoaxel commented 5 years ago

@Jrmie Thanks for the nice visualisation. As far as I know this is not possible, yet :disappointed:

D31T4 commented 5 years ago

I tried to modify this function in vis.js, but I don't know how to declare and define the x_offset attribute.

  (0, _createClass3['default'])(StraightEdge, [{
    key: '_line',
    value: function _line(ctx, values) {
      // draw a straight line
      ctx.beginPath();
      ctx.moveTo(this.fromPoint.x, this.fromPoint.y);
      var deltaX;
        if (this.toPoint.x_offset === undefined || this.toPoint.x_offset === null) {
          deltaX = 0;
        }
        else {
          deltaX = this.toPoint.x_offset;
          window.alert(deltaX);
        }
      ctx.lineTo(this.toPoint.x + deltaX, this.toPoint.y);
      // draw shadow if enabled
      this.enableShadow(ctx, values);
      ctx.stroke();
      this.disableShadow(ctx, values);
    }