Change Diagram Title

Hello,

Is it possible to place a title for the Diagram in GoJs ? In the top right/left corner of the Canvas.
I have been looking for this since hours now I did not find any example in the documentation.

Any ideas,?
Thanks in advance !

Ben,

Just use a Part or a Node for the title. FlowChart does that, using the “Comment” category/template. You will want to set its Part.position yourself, and if you have a Diagram.layout and do not want that Layout to affect your title Part, set Part.isLayoutPositioned to false in that template.

Also the “Virtualized…” samples such as http://gojs.net/latest/samples/virtualizedTree.html make use of a temporary Part that says “Loading…” while the huge tree is being initialized. That Part is then removed when the tree initialization is finished.

Now such Parts are just part of the regular document that the Diagram is showing, so if the user scrolls around, those Parts will move. If you want such Parts to stay at a fixed viewport position while scrolling, you will need to update their document position to counteract the movement. http://gojs.net/temp/fixedTitle.html provides an example of that.

Thank you Walter for your prompt reply.

I was able to use Part for the title and used the code from [EDIT: now an Introduction page] http://gojs.net/latest/intro/legends.html to make it fix.
The problem is that I am getting a weird beahvior of my diagram (which using TreeLayout). When the page loads, the diagram is not centered (even though myDiagram.initialContentAlignment = go.Spot.Center;), it got pushed down for some reason. Is there a way to make the title and diagram on completely different layers may be? or can you suggest any better way of doing this?

Thanks in Advance,
Ben

Set { isInDocumentBounds: false } on your title Part.

Actually, you’ll probably also want to set Part.isLayoutPositioned to false also, so that it doesn’t accidentally interfere with your TreeLayout.

Thank you so much Walter, that’s exactly what I was looking for :)
Now, it’s working like a charm.


Ben