2016-12-15 4 views
1

私はTreant.jsライブラリを使用してグラフを描画していますが、すべて問題ありませんが、別のノードを取得してグラフを再ロードするよう要求すると、グラフでは、データが正しい形式で返されることに注意してください。ajaxを使用してtreant.jsを使用してツリーグラフを破棄して再読み込みします

私はこの問題について検索し、私はこれが見つかりました:木のための「ストア」からデータを削除する 必要です。..ツリーを破壊するのに十分ではない、新たにロードされたデータを作成するには

を TreeStoreのその後あなたがこの方法でのカウンタIDをリセットする必要があり JSONconfig

に「作る」に私はこの構成オブジェクトを使用しています:

var config = { 
    container: "#OrganiseChart8", 
    levelSeparation: 50, 
    siblingSeparation: 40, 
    nodeAlign: "BOTTOM", 
    connectors: { 
     type: "bCurve", // step 
     style: { 
      "stroke-width": 1, 
      "stroke": "#000", 
      "stroke-dasharray": "", 
      "arrow-end": "classic-wide-long", 
     } 
    } 
}; 
短い言葉で

、私は次の操作を実行したい:

Tr = new Treant(tree_structure); 
Tr.destroy(); 
how to remove the data from the store in TreeStore ? 
how to reset the counter id ? 
ajax call() 
Tr = new Treant(tree_structure); 

ツリーが表示されていません!

提案がありますか?

ありがとうございました。

答えて

0

あなたがツリー全体を破壊し、新しいもの

を追加したい場合はAjaxのデータが

let ajaxNodeData = { 
    text: {name: 'Fifteen'}, 
    HTMLid: 'fifteenID', 
    position: 'center' 
}; 

新しいノード

let nodeToAdd = $('#oneID'); 
testTree.tree.addNode(nodeToAdd.data('treenode'), ajaxNodeData); 

を追加取得

let testTree = new Treant(chartConfig, null, $); 

でツリーを作成します。

testTree.destroy(); 
testTree = new Treant(simple_chart_config, null, $); 
関連する問題