Issue to share two model objects with two diagrams

Models:
public model1 = new go.GraphLinksModel();
public model2 = new go.GraphLinksModel();

Update Model Data:

_APIJsonData.forEach((a: any) => {
        this.model1.insertArrayItem(v.ruledetails, 0, a);
        this.model2.insertArrayItem(v.ruledetails, 0, a);
      });

this.myDiagram.model=this.model1;
this.myLocalDiagram.model=this.model2;

Issue:
whenever I am inserting Entries in model2, then model1 automatically get updated
and that’s why model1 have two entries of one record, I am facing record duplication issue.

I don’t know what v is, but I assume it’s a JavaScript Object that has a “ruledetails” property that is an Array. My question is whether the two models both have data objects that refer to the same Array, so that you are effectively inserting the same value of a twice. I think you need to make sure that those Arrays are not shared between the two models.

  1. v is node object as mentioned below:
    $(“PanelExpanderButton”, “COLLAPSIBLE”,
    {
    row: 0,
    scale: 0.80,
    column: 1,
    alignment: go.Spot.TopRight,
    click: FillBrList,
    },
    )
    const FillBrList = (e: any, obj: any) => {
    const v = obj.part.data;
    }

2.How could be it possible to same Array not shared by two models?

Are you asking how two different node data objects refer to the same Array? It depends on how you create the data.

  1. Just for reference type of node data structure I have generated:
    NodeData”: [
    {
    “Key”: “FILEID-1”,
    “FileId”: “1”,
    “RuleId”: “”,
    “Text”: “ADDIDEP”,
    “RuleAnnotation”: “”,
    “Category”: “Program”,
    “IsGroup”: false,
    “Group”: “”,
    “EdgeReferenceCount”: “”,
    “IsButtonVisible”: true,
    “IsRulePresent”: “true”,
    “NodeDetails”: {
    “Color”: “#ffcc00”,
    “ShadowColor”: “#cca300”,
    “figure”: “”
    },
    “RuleDetails”: ,
    “ParentNode”: “”
    },
    ]
  2. I want to update RuleDetails as per my requirement but currently it is facing duplication issue in model1.

const v = obj.part.data;

_APIJsonData.forEach((a: any) => {
        this.model1.insertArrayItem(v.ruledetails, 0, a);
        this.model2.insertArrayItem(v.ruledetails, 0, a);
      });

this.myDiagram.model=this.model1;
this.myLocalDiagram.model=this.model2;

Why are you passing the same Array twice to the calls to Model.insertArrayItem? Shouldn’t you be modifying two different arrays, one that is in model1 and one that is in model2?

I have two diagrams, for this two diagrams I have used model1 and model2, without model2 I am not able to load data in second diagram.

Please explain what you are trying to do with this code.
obj.part is in which Diagram? obj.part.data is in which model?
Why are you passing the same Array to both models in your calls to Model.insertArrayItem?
Why are you inserting the same value a twice into the same Array?