rstacruz / kingraph

Plots family trees using JavaScript and Graphviz
439 stars 86 forks source link

Duplicate names #8

Open i2xzy opened 5 years ago

i2xzy commented 5 years ago

At the moment, as far as I can tell, the way to get around duplicate names is to give a unique id e.g. 'name2' and then modify the name field in the people obj

people:
  #duplicates
  Henry2:
    name: Henry
  William2:
    name: William

The only problem with this in the below code if person.name && !person.fullname you end up with the name written twice:

https://github.com/rstacruz/kingraph/blob/ac6c8da851ae5354c308dcbfbbd8b9501054efa0/lib/render_graph.js#L76-L86

The solution I came up with is the following:

  if (person.fullname) {  // only make a second line when there is a fullname 
    label =
      '<<table align="center" border="0" cellpadding="0" cellspacing="2" width="4">' +
      '<tr><td align="center">' +
      `${person.name || id}</td></tr>` +
      '<tr><td align="center">' +
      '<font point-size="10" color="#aaaaaa">' +
      `${person.fullname}</font></td></tr></table>>` // put the fullname in the second line
  } else {
    label = person.name || id // if there is a name use that otherwise use id
  }

Really loving this project btw thanks

AlexanderWillner commented 4 years ago

Fixed by @vabene1111 in https://github.com/vabene1111/kingraph and I pushed some additional fixes at https://github.com/AlexanderWillner/kingraph