How to Add Chart Legend

Hi,

I want to add a legend to my chart.
Is there a way to add a it?
This legend should not be part of the graph.
It should contains a specific content, not matter what the graph looks like.

Thanks,
Eyal

https://gojs.net/latest/intro/legends.html

Thanks you.

I used the following code, but my question is how can I position it on the top left part of the document, not related to the graph.

diagram.add(
(go.Part, { location: new go.Point(0, -40) }, (go.TextBlock, “A Title”, { font: “bold 24pt sans-serif”, stroke: “green” })));

What does your “ViewportBoundsChanged” DiagramEvent listener do? GoJS Legends and Titles -- Northwoods Software

I tried it but it didn’t work

Does the example on the Introduction page do what you want? If so, you need to adapt and debug the code for your own purposes.