我正在使用网络布局,我想以六边形显示节点,为此,我在 lib/network/shapes.js 的代码片段中添加了以下内容
/**
Draw a Hexagon shape with 6 sides
@Param {Number} x horizontal center
@Param {Number} y vertical center
@Param {Number} r radius
*/
CanvasRenderingContext2D.prototype.hexagon = function(x, y, r) {
var a = Math.PI2 / 6;
this.beginPath();
this.translate(x, y);
this.moveTo(radius, 0);
for (var i = 1; i < sides; i++) {
this.lineTo(radiusMath.cos(ai), radiusMath.sin(ai));
}
this.closePath();
};
我也需要更新 vis.js 文件吗?