I am working with mxgraph and using the mxgraph ports example as a starting point for my application. https://jgraph.github.io/mxgraph/javascript/examples/ports.html
The example passes the content of each cell through the value
property of an mxcell
object. The display content is an html label which is then rendered inside the cell. Example code below shows the creation of an draggable icon on the sidebar the parameters are graph, sidebar, label, image
.
addSidebarIcon(graph, sidebar,
'<h1 style="margin:0px;">Website</h1><br>'+
'<img src="images/icons48/earth.png" width="48" height="48">'+
'<br>'+
'<a href="http://www.jgraph.com" target="_blank">Browse</a>',
'images/icons48/earth.png');
The addSideBarIcon
function then creates the vertex by passing it's label
argument as the value
property of the MxCell.
v1 = graph.insertVertex(parent, null, label, x, y, 120, 120);
I would like to be able to add a JSON object to store non display data along with the html label for display purposes in the value
property of each cell. I would like to do this without modifying the underlying prototypes.
addSidebarIcon(graph,
sidebar, {
display: '<h1 style="margin:0px;">Process</h1><br>' +
'<img src="images/icons48/gear.png" width="48" height="48">' +
'<br><select><option>Value1</option><option>Value2</option></select><br>',
data: {
key1: val1
},
}
When I do this he code is interpreting the value
as an html label. where as I would like it to interpret only value.display
as the label. I'm not sure how to go about combining the html label and json data together and would love some suggestions.