gramps-project / gramps-web

Frontend for Gramps Web
https://www.grampsweb.org
GNU Affero General Public License v3.0
336 stars 48 forks source link

Relationship graph syntax error #412

Closed DavidMStraub closed 3 months ago

DavidMStraub commented 3 months ago

Hi @geostag, testing the new relationship chart on my own tree, I am encountering a JS syntax error Uncaught (in promise) Error: syntax error in line 1347 near '-' when I navigate to specific people. I am not sure what the root cause is, but I suspect it has something to do with two cousins being married, so two grandparents are identical.

I also noticed (might be related or not) that people can show up twice in such cases, or when they have multiple marriages

image

geostag commented 3 months ago

Persons showing up more than once is intended, if they are part of more than one family and their partners or children are also part of the graph. This is the situation I tried to describe.

The JS syntax error obviously is not. Could you give some more details, e.g. the stacktrace from the browser console?

DavidMStraub commented 3 months ago

image

geostag commented 3 months ago

Seems to be a syntax error in the generated dot string. Could you do me a favour and add console.log(dot) before line 186 in RelationshipChart.js and show the line the error refers to - if this is possible? Currently I have no idea how a '-02' should make it to the generated dot depending on individual data.

I am assuming, that the handle from api data is a save alphanumeric string. If this not the case, I have to rework the code.

DavidMStraub commented 3 months ago

Here (trying out locally now) it says "line 2476 near '-02'", line 2476 would be the third line here - not sure if this is the right counting though...

      subgraph cluster_p_53ce42d5-02cd-4d82-bbfb-db3449fe038c {
        cluster=true
        color=white
        label="."
        node_p_53ce42d5-02cd-4d82-bbfb-db3449fe038cx53ce42d5-02cd-4d82-bbfb-db3449fe038c [
          class="person_53ce42d5-02cd-4d82-bbfb-db3449fe038c"
          margin=0.25
          shape="none"
          fixedsize=true
          width=2.878787878787879
          height=1.0636363636363635
          label=<->
        ]
      }
DavidMStraub commented 3 months ago

Actually it's the only subgraph with the string -02, so might be something in there.

DavidMStraub commented 3 months ago

I ran this on the command line with dot and got

Warning: syntax ambiguity - badly delimited number '-02c' in line 2475 of graph.dot splits into two tokens
Error: graph.dot: syntax error in line 2475 near '-02'
DavidMStraub commented 3 months ago

For some reason it seems handles with hyphens cause problems. And Gramps Web API uses UUIDv4s with hyphens :grimacing:

I suspect quotation marks might be enough to fix it https://stackoverflow.com/questions/14958346/dot-dash-in-name

DavidMStraub commented 3 months ago

I'll try that out

DavidMStraub commented 3 months ago

That fixed it! Will push directly

andre1wall commented 3 months ago

I am experiencing some problems with the correct sorting of the main person's descendants. maybe i'm the only one experiencing these errors as my family tree is quite large, but it would be good if the descendants were always sorted by year of birth and no distinction was made as to whether the people were married or not, as this should not affect the view.

wrong sorting descendants: gramps-web-realationship-praph sorting

a person who has been married twice is reported twice: the same person was married twice1 the same person was married twice2

thank you for your hard work i really appreciate it. this view was really missing. please continue with your great work

geostag commented 2 months ago

We are using graphviz, a common software library to render and layout arbitrary graphs. The algorythm tries to minimize the number of crossing edges. This is well accepted as helpful when displaying large directed graphs. But it definetly has the effect, that other sorting crierteria like date of birth are not taken into account.

Displaying persons which are part of more than one family multiple times is intended as discussed in #313 . It seems to be the best option in these cases.