javascriptmxgraphjgraph

How to set minimum size of an mxGraph vertex (so tooltips work on smallest ones)?


I've got an mxGraph that has very small vertices, in terms of their label, because it starts with 1, 2, 3. The default size of those less-than-10 vertices is too small for a tooltip rollover. How can I set the minimum size of vertices so I get some extra width on the smallest ones and tooltips will be fired on rollovers?

enter image description here


Solution

  • 2 options.

    You can set the size of a mxCell with the "geometry", or you look at Style.

    You can register as many custom styles as you need. Refer to this example : https://jgraph.github.io/mxgraph/javascript/examples/stylesheet.html

    for a vertex, pseudo code would look like this :

    var defaultVertexStyle = this.getDefaultVertexStyle(); // "this" is mxStyleSheet
    var myCustomStyle = defaultVertexStyle.clone();
    myCustomStyle["width"] = 100px; 
    this.putCellStyle("myStyle", myCustomStyle);
    

    and then you can add "myStyle" to any cell you want. You can customize shape, color, everything.