2
我正在使用網絡佈局,並且我希望以六邊形的形狀顯示節點,爲此,我在lib/network/shapes.js中的代碼片段中添加了以下內容我們如何在網絡中創建六邊形形狀vis.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文件呢?