I'm doing this:

graph.insertVertex(parent, null, '', 100, 100, 40, 40, 'shape=ellipse;strokeColor=black;fillColor=white');

I would like to do something like this:

graph.insertVertex(parent, null, '', 100, 100, 40, 40, 'shape=mxgraph.bpmn.general_start;strokeColor=black;fillColor=white');

But a square is shown!

Should I load something to to that? Or there is a way to combine the basic shapes and create a custom shape, and use via the insertVertex function?

asked 05 Sep '12, 15:27

PhillipSpring's gravatar image

PhillipSpring
26116
accept rate: 33%

edited 09 Sep '12, 05:33

David's gravatar image

David
4.9k21831


The solution is in stencils.html, but your answer helped to figure out how to do it! :)

I took bpmn.xml from one of the examples, copied to my prototype, then I loaded the shapes:

var req = mxUtils.load('bpmn.xml');
var root = req.getDocumentElement();
var shape = root.firstChild;

while (shape != null) {
    if (shape.nodeType == mxConstants.NODETYPE_ELEMENT) {
        mxStencilRegistry.addStencil(shape.getAttribute('name'), new mxStencil(shape));
    }
    shape = shape.nextSibling;
}

Thus, I could use the BPMN shapes like this: var CE = graph.insertVertex(parent, null, '', 100, 100, 40, 40, 'shape=Cancel End');

link

answered 06 Sep '12, 13:07

PhillipSpring's gravatar image

PhillipSpring
26116
accept rate: 33%

edited 09 Sep '12, 05:33

David's gravatar image

David
4.9k21831

See shape.html example. The example demonstrates how to add new shapes if you write them in JavaScript. If you want to add an XML stencil shape, see the stencil.html example

link

answered 06 Sep '12, 08:12

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

edited 09 Sep '12, 05:33

David's gravatar image

David
4.9k21831

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×228
×39
×22
×2
×1

Asked: 05 Sep '12, 15:27

Seen: 15,993 times

Last updated: 09 Sep '12, 05:33