3

cytoscapeweb 2 は初めてなので、API の使用方法を学ぶために提供された例の 1 つに従っています。私はそれを機能させることができず、firebug は次のメッセージを報告します:

コンポーネントがエラー コードを返しました: 0x80004005 (NS_ERROR_FAILURE) var n = this.nodesGroup.getBBox();

私のhtmlドキュメントでは、cytoscapeweb divがjqueryタブウィジェットに埋め込まれています(コンテキストを提供するためだけです)

my.html のどこかに

<div id="tabs">
    <ul>
      <li><a href="#tabs-1">Interactors Selection</a></li>
      <li><a href="#tabs-2">Interactome Builder</a></li>      
    </ul>
    <div id="tabs-1">
      <p>Tab 1 content</p>
    </div>
    <div id="tabs-2">
      <p>Tab 2 content</p>
       <div id="cy"></div>
    </div>
 </div>

そしてfoo.jsで

function cytoscapeInit() {
    alert ("intializing cytoscape");

    // create a mapper for node size
    var nodeSizeMapper = {
        continuousMapper: {
            attr: {
                name: "weight",
                min: 0,
                max: 100
            },
            mapped: {
                min: 15,
                max: 30
            }
        }
    };
 // call cytoscape web on the `cy` div
    $("#cy").cytoscapeweb({
                              // define the elements in the graph
    elements: {
        nodes: [
            { data: { id: "a", weight: 43 }, classes: "foo" },
            { data: { id: "b", weight: 2 }, classes: "bar" },
            { data: { id: "c", weight: 88 }, classes: "foo bar" }
        ],

        edges: [
            { data: { id: "ab", source: "a", target: "b", weight: 32 }, classes: "foo" },
            { data: { id: "bc", source: "b", target: "c", weight: 12 }, classes: "bar baz" },
            { data: { id: "ca", source: "c", target: "a", weight: 96 }, classes: "baz foo" },
            { data: { id: "ac", source: "a", target: "c", weight: 65 }, classes: "bar" }
        ]
    },

    // define the layout to use
    layout: {
        name: "preset",
        positions: {
            "a": { x: 30, y: 30 },
            "b": { x: 125, y: 131 },
            "c": { x: 200, y: 50 } 
        },
        fit: false,
        stop: function(){
            cy.reset();
            cy.center();
        }
    },

    // define the visual style (like css) of the graph
    style: {
        selectors: {
            "node":{
                shape: "ellipse",
                fillColor: "#888",
                height: nodeSizeMapper,
                width: nodeSizeMapper,
                labelText: {
                    passthroughMapper: "id"
                }
            },
            ".yay": {
                fillColor: "red",
                lineColor: "red",
                targetArrowColor: "red"
            },
            "edge": {
                lineColor: "#ccc",
                targetArrowColor: "#ccc",
                width: {
                    continuousMapper: {
                        attr: {
                            name: "weight"
                        },
                        mapped: {
                            min: 2,
                            max: 5
                        }
                    }
                },
                targetArrowShape: "triangle"
            },
            "node:selected": {
                fillColor: "#333"
            },
            "edge:selected":{
                lineColor: "#666",
                targetArrowColor: "#666"
            }
        }
    },

    // define the callback for when cytoscape web is ready
    ready: function( cy ){
        window.cy = cy;
    }
});

明らかな何かを見逃しましたか?

もしそうなら、すべての謝罪。

4

2 に答える 2

3

(1) テスト中であっても、そのようなコードにアラートを入れないでください。Cytoscape Web の初期化や AJAX 呼び出しの実行など、非同期コードを壊す可能性があります。console.log()代わりに使用してください。

(2) Cytoscape Web div をcyタブで隠している可能性があります。display: none;Cytoscape Web ビューポートが 0x0 px になるため、を使用しないでください。position: absolute; left: -9999px;隠すために似たようなものを試してください。これには、jQuery が非表示のタブに使用するクラス名 (おそらく.ui-state-hiddenまたは類似のもの) を変更する必要があります。

(3) 非表示の Cytoscape Web div に対するレンダラー コードの耐性を高めることを検討します。

于 2012-05-28T14:58:09.980 に答える