English 中文(简体)
Example with discreteMapper
原标题:

I d like to use the discreteMapper of CytoscapeWeb 2.0 (that is, the jQuery-based CytoscapeWeb) but need some example code showing what exactly I have to do.

I already tried with some code taken from the Flash-based CytoscapeWeb and tried

var entityColorMapper = {
    attrName: "etype",
    entries: [ { attrValue: "protein", value: "#ff0000" },
               { attrValue: "compound", value: "#00ff00" },
               { attrValue: "group", value: "#0000ff" } 
             ]
};

and then in the "style" structure I have

    "node.E": {
        fillColor: {
            discreteMapper: entityColorMapper
        }
    }

but this does not seem to work.

最佳回答

It s different in Cytoscape Web 2: https://github.com/cytoscape/cytoscapeweb/wiki/StyleObject

  // example discrete mapper
  fillColor: {
    defaultValue: "grey",
    discreteMapper: {
      attr: "type", // field in ele.data() to map to
      mapped: {
        "foo": "red", // field value : visual property value
        "bar": "blue"
      }
    }
  }

You don t really need to use a discrete mapper, since you could be using selectors in your style:

"node[type= foo ]": { fillColor: "red", borderColor: "pink" },
"node[type= bar ]": { fillColor: "blue" }

It s better to use the second approach, since you can separate the style for [type= blah ] for several visual properties at once (e.g. borderColor), much like CSS.

Remember: Make sure to always work with the latest prerelease version while Cytoscape Web 2 until the first official release is made. https://github.com/cytoscape/cytoscapeweb/downloads

问题回答

暂无回答




相关问题
正在初始化 cytuscape

正在更新到 cytoscape 2, 我正跟随其中一个例子学习如何使用 API 。 我无法让它工作, 火虫报告以下信息: 组件返回...

Example with discreteMapper

I d like to use the discreteMapper of CytoscapeWeb 2.0 (that is, the jQuery-based CytoscapeWeb) but need some example code showing what exactly I have to do. I already tried with some code taken from ...

热门标签