Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Saving of DiagramNode Groups in JSON files (Read 277 times)
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Saving of DiagramNode Groups in JSON files
Jul 13th, 2026 at 10:03am
Print Post  
Could you check that group membership is saved in JSON files? When I load my binary Diagram and then save it to a JSON file and then re-load it, group membership of DiagramNodes seems to have been lost.

Regards
DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #1 - Jul 14th, 2026 at 9:06am
Print Post  
Looking at the code, groups should be saved in JSON:

Code
Select All
else if (MasterGroup != null)
{
    obj.Add("master", context.WriteItemId(MasterGroup.MainItem));
    var attachment = MasterGroup.GetAttachment(this);
    obj.Add("attachment", context.WriteAttachment(attachment));
} 



Which Attach* method variant exactly are you calling to define groups?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Re: Saving of DiagramNode Groups in JSON files
Reply #2 - Jul 14th, 2026 at 11:00am
Print Post  
To create groups, I do this...

        protected Group SubordinateGroup(ShapeNode box)
        {
            // Returns box's subordinate group, creates the group if it does not exist
            var g = box.SubordinateGroup;

            if (g == null)
            {
                // Group not there yet - create a group, using 'box' as the master
                g = FlowChart.Factory.CreateGroup(box);

                g.AutoDeleteItems = true;
                g.Expandable = true;
            }

            return g;
        }

and to attach nodes to a group I do this sort of thing...

                // Attach 'boxLabel' to the group
                SubordinateGroup(box).AttachToCorner(boxLabel, BottomLeft);

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #3 - Jul 15th, 2026 at 10:19am
Print Post  
This group is preserved in our tests. Please let us know what we should change in attached test project to see the problem, or attach your JSON file for our developer to inspect.

Regards,
Slavcho
Mindfusion
  

TestGroups.zip ( 5 KB | 13 Downloads )
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Re: Saving of DiagramNode Groups in JSON files
Reply #4 - Jul 16th, 2026 at 9:13am
Print Post  
When you save and load the JSON file in your example program and then delete a main box, the label box is left behind and not deleted as I expected and observed when saving and loading a binary file.

I assume that this was the loss of group membership. Perhaps there is another reason.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #5 - Jul 16th, 2026 at 12:13pm
Print Post  
Sorry, we only tried moving and resizing. It turns out there's no auto-delete property in JavaScript version of the diagram, so it was also missing from JSON format. This build adds "autoDeleteGroup" entry to JSON files, and should fix the delete problem:

https://www.nuget.org/packages/MindFusion.Diagramming/7.2.1-beta2

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Re: Saving of DiagramNode Groups in JSON files
Reply #6 - Jul 17th, 2026 at 9:29am
Print Post  
Thank you. That works well.

The only other problem I have now is that boxes in my chart can seem to end up in reverse order when a binary file is saved as a JSON file and then reloaded. It does not happen to all branches in the chart and I can't seem to reproduce it, which is very annoying.

I have attached two pictures.

DavidL
  

Binary__correct_.png ( 4 KB | 10 Downloads )
Binary__correct_.png
JSON__wrong_order_.png ( 4 KB | 9 Downloads )
JSON__wrong_order_.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #7 - Jul 17th, 2026 at 11:06am
Print Post  
Do you mean you are applying TreeLayout after loading the diagram?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Re: Saving of DiagramNode Groups in JSON files
Reply #8 - Jul 20th, 2026 at 9:36am
Print Post  
Yes, we do use the TreeLayout.

DavidL
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #9 - Jul 21st, 2026 at 11:30am
Print Post  
The order of TreeLayout branches depends on order of parent node's OutgoingLinks, so the control might not be storing that in JSON. We'll try to fix it in next few days.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3502
Joined: Oct 19th, 2005
Re: Saving of DiagramNode Groups in JSON files
Reply #10 - Jul 23rd, 2026 at 9:36am
Print Post  
This build saves the order of nodes' in/out links in JSON, and should hopefully fix TreeLayout differences -

https://www.nuget.org/packages/MindFusion.Diagramming/7.2.1-beta3

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 162
Location: England
Joined: Oct 23rd, 2006
Re: Saving of DiagramNode Groups in JSON files
Reply #11 - Today at 9:46am
Print Post  
Yes, that works well. Thank you.

DavidL
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint