GOJS 2.3 to 3.1

Hi,

I’m upgradding from 2.3 to 3.1.

My Code is in Angular TypeScript.

I used to import TableLayout.js from gojs/extensionsJSM/TableLayout.js

i downloaded the gojs and the extension libraries and npm installed them

So i have the gojs/extensionsJSM/ directory.

For some reason i have a compilation error complaining that gojs/extensionsJSM/TableLayout.js is NOT recognized.

Any clue ?

Regards,

Tany

Yes, as of v3.0, the extensions are no longer part of the “gojs” npm package. Instead, you can install them where you want by executing npm create gojs-kit.Then you can copy the files that you want into your project, or I suppose you could refer to them directly.

OK,

Another issue, for some reason the command :

Setting this.diagram.comandHandler.aschetypeGroupData with values crashes on ‘this.isGroupForNodeData is not a function’

I assume you have some typos in what you wrote that are not in your code.

What is the value of “this” in ‘this.isGroupForNodeData is not a function’?

Certainly the GraphLinksModel.isGroupForNodeData method has been present forever. And I don’t think the CommandHandler.archetypeGroupData property setter has changed in a long time either.

this is the code

and this is the error :

So my guess is that “this” is your diagram component, not the Diagram.model, nor even just the Diagram.

However, none of these things have changed between 2.3 and 3.1, so I cannot explain the exception.

No, when i breakpoint on the line i see that diagram and also command handler.

Anyway I have a bigger issue.

I have old diagrams created in 2.3 and saved as JSON in DB.

when i try to use them in 3.1, i get the following error for each node that is connected to a link

and by the way, i commented out the

this.diagram.commandHandler.archetypeGroupData…

and i still get

It happens when i try to add node to the model : diagram.model.addNodeData(nodeData)

The format/schema used by Model.toJson and Model.fromJson has not changed between 2.3 and 3.1.

Something seems very wrong in your environment. Are you sure that the only change you made was to update the version of GoJS? You didn’t also make changes to other libraries or to your code?

and why do i get the this.isGroupForNodeData error when i addNodeData ?

Can you confirm that your app is only loading the GoJS 3.1 library once and not also any other version?

I have started from scratch, ran npm install goj, comment out all extentionsm such as port shifting too and Tablelayout and tried to use native gojs 3.1. Once again, i got when adding a node

Something is very wrong with your configuration. Looking at the code, I do not see how it is possible to get that error.

isGroupForNodeData is a public method on GraphLinksModel. If you are getting that error, clearly the object on which that method is being called is not an instance of GraphLinksModel.

It is called from GraphLinksModel.isGroupForData, which is an internal method for deciding whether or not some node data should be treated as if it were a group. The code is:

const isgroup = model._isGroupModel() && model.isGroupForData(data);

That _isGroupModel predicate is an internal method that returns true only if the model is a GraphLinksModel. Because the name starts with an underscore, the name will be minified in the library.

So unless your environment has somehow modified the prototypes of the GoJS classes or the instances of those classes, I do not see how you could be getting that error.

Some possibilities are:

  • The GoJS library is being loaded more than once, especially if you are loading different versions of the GoJS library – say both the 2.3 and the 3.1 versions
  • The public Model and GraphLinksModel classes, and the internal PartManager and GraphLinksPartManager classes, are being modified
  • Incorrect minification has messed up the classes. The GoJS libraries are already minified, so if your build process is minifying them again, maybe there’s some bug being introduced.
  • Your code is depending on undocumented functionality, especially minified names, so of course that code won’t work any more with a newer library.

Maybe there are other reasons for this error.

If you replace the GoJS 3.1 library with a 2.3 library, and make no other changes, does everything work again? What if you try with a 3.0 library? I hope you have reviewed the 3.0 change log so that you can see whether any of the incompatibilities apply to your code.

I have started from scratch, ran npm install goj, comment out all extentionsm such as port shifting too and Tablelayout and tried to use native gojs 3.1. Once again, i got when adding a node

yes, if i go back to 2.3, it works fine.

I also went down to 3.0. Same error.

So, i tried NOT to set nodeTemplate and also create a simple diagram like

diagram = GO(go.Diagram);

Same error.

Which module system are you using? In other words, which library file are you loading? And how are you referring to it?
I’m wondering if there is a module mismatch.

I’m not sure i undersatnd,

but since then i played with the code and i noticed that if i reset the diagram right before setting the node, namely :

this.diagram = new GO(go.Diagram);

this.diafgram.model.addNodeData(nodeData);

It does not crash.

Any clue, where to check, mayne GroupTemplateMap, or LinkTemplateMap ?

I noticed that my code does alot :

let diagram = this.diagram;

diagram……

Maybe it is forbbiden to do let….

let diagram = this.diagram;
...diagram...

is fine – we do it all the time.

Check all places where you load models and where you set Diagram.model. Maybe what is being assigned isn’t really a GraphLinksModel. Grab the value in the console and evaluate whether it is an instanceof go.GraphLinksModel.

but even if i do

this.diagram.model.addNodeData({ key: 0, name: “ee”});

it crashes

Is it possible because key equals to zero ?

A key that is zero is fine – some of our samples use that.

Have you checked the value that you are setting to Diagram.model?