Reputation: 1
I 'm new in the world of mxGraph and I have a few questions.
1 - It's possible to insert a "div" in a vertex ? If yes, how ?
2 - Can we draw a background grid which scale when we zoom on our graph ? For the moment, I just have a picture of a grid for my background.
3 - When we write text in a vertex, how can we change the size of the box in function of the text length ?
Thank you all for your response :)
Upvotes: 0
Views: 290
Reputation: 819
Yes, yes, yes.
You have loads of examples there to do all you need : https://jgraph.github.io/mxgraph/javascript/
1 - You need to override the renderer of boxes (I think the function is getLabel
) and render your own HTML instead of just the "text" of the box as most examples do. I think this is the most relevant : https://jgraph.github.io/mxgraph/javascript/examples/htmllabel.html
2 - https://jgraph.github.io/mxgraph/javascript/examples/grid.html
3 - There may be several way of doing that. The way I did is override function getPreferredSizeForCell
and I recalculate the size of the cell. Specifically; I generate the HTML (as mentioned in question 1), I 'measure' it and apply the size to the boxes. There is probably a better way of doing but this does the job.
Upvotes: 1