问题
My nodes contain an attribute "classid". For every classid I would like to use a specific background-image. How can I map data to a node-attribute, like it was possible on cytoscapeweb by using the descretemapper (http://cytoscapeweb.cytoscape.org/documentation/mappers#section/DiscreteMapper)?
Here my code from cytoscapeweb:
var iconMapper = {
defaultValue: "icons/BMC_BASEELEMENT.png",
discreteMapper: {
attrName: "classid",
entries: [
{ attrValue: "BMC_CHASSIS", value: "icons/BMC_CHASSIS.png" },
{ attrValue: "BMC_CLUSTER", value: "icons/BMC_CLUSTER.png" },
{ attrValue: "BMC_ACTIVITY", value: "icons/BMC_ACTIVITY.png" },
(...)
{ attrValue: "BMC_COMPUTERSYSTEM", value: "icons/BMC_COMPUTERSYSTEM.png" }
]
}
};
回答1:
Use the data mapper:
e.g. "data(classid)"
http://cytoscape.github.io/cytoscape.js/#style/mappers
来源:https://stackoverflow.com/questions/16933384/how-to-use-a-descretemapper-like-on-cytoscapeweb