基礎編 セルの挿入
記事作成日: 2020-12-16
セルを追加するにはmxGraphModelのaddメソッドでも可能ですが、コアパブリックAPIであるmxGraph.insertVertex()およびmxGraph.insertEdge()を使用するのが一般的です。
insertVertex
新しい頂点を作成してモデルに挿入します。
mxGraph.prototype.insertVertex = function(parent,id,value,x,
y,width,height,style,relative)
| parent | 新しい頂点の親を指定するmxCell |
| id | 新しい頂点のIDを定義するstring(オプション) |
| value | ユーザーオブジェクトとして使用されるobject |
| x | 頂点のx座標を定義するinteger |
| y | 頂点のy座標を定義するinteger |
| width | 頂点の幅を定義するinteger |
| height | 頂点の高さを定義するinteger |
| style | セルスタイルを定義するstring(オプション) |
| relative | ジオメトリが相対的かどうかを指定するboolean 。デフォルトはfalse(オプション) |
insertEdge
新しいエッジを作成してモデルに挿入します。
mxGraph.prototype.insertEdge = function(parent,id,value,source,target,style)
| parent | 新しいエッジの親を指定するmxCell |
| id | 新しいエッジのIDを定義するinteger(オプション) |
| value | ユーザオブジェクトとして使用されるobject |
| source | エッジのsourceを定義するmxCell |
| target | エッジのtargetを定義するmxCell |
| style | エッジのstyleを定義するstring(オプション) |