[Help] How to perform OR based filtering from a subfilter || How to use Tidgraph for Family Tree

130 views
Skip to first unread message

D X

unread,
May 5, 2019, 3:13:39 PM5/5/19
to TiddlyWiki
I have a Tiddlywiki with genealogy-like tiddlers and I'm trying to integrate the excellent Tidgraph ( https://ihm4u.github.io/tw5plugs/#Tidgraph%20-%20Easy%20tiddler%20graphs%20for%20TW5 ) to draw nice family trees from the tiddlers.

I have this (the mode argument is re-run by Tidgraph without further control or input at each node of its traversal of a TW):

<$tidgraph start="James" mode="listed[father]" layout="S"/>

But for Tidgraph to walk down all of James's descendants including matrilineal (mother) relationships, I need something like this:

<$tidgraph start="James" mode="listed[father] listed[mother]" layout="S"/>

But this doesn't work because the listed[mother] results just overwrite the listed[father] results instead of appending, since I don't have access to the full filter.

Tidgraph doesn't give me access to the current node (tiddler) it's processing at each step of its traversal or control over the full filter it uses to walk through the tiddlers -- just this snippet that it calls a subfilter.

Alternatives:
  1. Invert data model, i.e., store the relationship in the parent. Problem: Given that the relationship parent =< child is one-to-many, it doesn't make sense from a data model perspective (and would be hard to wrap nice drop-downs around) having each parent have a long text field with a list of all its children.
  2. Use Tags, i.e., represent the relationship by having the child tag the parent. Problem: I don't see an easy way to have a nice drop down on the child tiddler that selects a new parent, removes the old parent tag, and adds the new parent tag. (Although help welcome if there is a clean way to do this.)
  3. Aggregated / virtual "parents" field. Is there some way to have a combined "parents" text field on the children that when I added or changed either "father" or "mother" would remove the old value and add the new value to the aggregated "parents" field?
  4. Enlist / ListOps??? Is there some way to combine the results of two filters using enlist or listops? Input welcome here.
Ideas welcome. Thanks in advance!

@TiddlyTweeter

unread,
May 6, 2019, 1:39:16 AM5/6/19
to tiddl...@googlegroups.com
Ciao DX

I can't give you an answer. But can give you some clues.

I've, too, wanted to create proper family trees. I've not yet found a way to generate them.

I tried several of the graphical presentation plugins. Tidgraph, Maiden, TiddlyMap & the D3.

I couldn't get any of them to work properly. Reason: though all of them can do "uni-linear descent" (i.e. descent through either fathers or mothers) as far I can tell they can't do bilateral descent (i.e. descent through marriage partnerships; from conjunction of a man and woman).

I'm pretty sure a reason for the difficulty is that if they rely on an underlying HTML representation though "list" code it won't work because you'd need to be able to conjoin two list trees laterally  for a marriage with joint descendants. But Lists can't work that way? At least I haven't found any easy way round the issue.

Bimlas created a good "kin" tool (https://bimlas.gitlab.io/tw5-kin-filter/) that can trace complex descent but, I think, it too, hits this limit on conjunction in rendered html ... but its maybe worth looking at?

I played a bit with JS libraries designed for anthropologists & genealogists but in these cases I don't have skill enough to implement them in TW.

Another idea was to use diagramming that doesn't require html lists in render. The issue here is its difficult to generate them using TW filters.

Not exactly a positive reply! But thought you might find it useful background. And maybe you'll get further than I did!

Best wishes
Josiah

D X

unread,
May 6, 2019, 3:09:29 AM5/6/19
to tiddl...@googlegroups.com
Thanks for the reply, Josiah. I'm not familiar with that kin filter plugin; I'll check it out. I'm really more keen on something that will draw a nice diagram than on a filter that helps me query children (since Tidgraph can walk a whole tree of related tiddlers as well).

It appears Tidgraph is semi-abandoned in that the code for it in Github appears to be a couple versions behind (e.g., it doesn't have the custom modes mentioned at its documentation site) and when you import it, it's unfortunately obfuscated JavaScript, which is quite painful to work with. 

Nevertheless, I've hacked the obfuscated JavaScript for the plugin to make the custom mode argument pass in the first part of the filter I need (children who list the current node as "father") and the filter argument receive in the second part of my filter (append in all children who list the current node as "mother").

So I don't have spouses (a shame, but I can manage for now without this), but my hacked Tidgraph will now find and draw all descendants (both from male and female lines) given a starting tiddler (a top-level parent).

For those interested in this (note: it may break your wiki / Tidgraph), you have to find and change the following section (the obfuscated JavaScript is all jammed on a single line, so line numbers are not helpful here) in $:/plugins/ihm/tidgraph/utils.js:
default:b="[["+a+"]"+c.mode+"]+"+c.filter}

to:
default:b="[["+a+"]"+c.mode+"] [["+a+"]"+c.filter+"]"}

After this change you have to save utils.js and hard refresh / reload your TW. Then you invoke it like this (using my previous example):
<$tidgraph start="James" mode="listed[father]" filter="listed[mother]" layout="S"/>

Which will now generate the needed OR style filter (and draw a full lineage).
[[James]listed[father]] [[James]listed[mother]]

Woot!

@TiddlyTweeter

unread,
May 6, 2019, 4:13:08 AM5/6/19
to TiddlyWiki
Ciao D X ... 

Just a footnote on a simple diagramming approach. 

You might find this useful to read too? Its not a solution as its not converted to TW. But its suggestive of a possible real solution ... https://groups.google.com/forum/#!msg/tiddlywiki/7Za1WXrcSMs/HmLqHvuLAQAJ

bimlas also played with it ... https://bimlas.gitlab.io/tw5-asciidoctor/

Best wishes
Josiah

D X wrote:
... I'm really more keen on something that will draw a nice diagram than on a filter that helps me query children 

D X

unread,
May 20, 2019, 2:47:07 AM5/20/19
to TiddlyWiki
Thanks, Tweeter. I'll take a look at that.

bimlas

unread,
May 20, 2019, 5:31:05 AM5/20/19
to TiddlyWiki
D X,

I think you have to use the "filter" parameter instead of "mode". For example, if you install the plugin for https://www.tiddlywiki.com/ and want to list the tiddlers with the Order Operators AND Listops Operators tags:

<$tidgraph start="Filter Operators" filter="[tag[Order Operators]tag[Listops Operators]]">

I don't know why, but if I want to filter with OR ([tag[Order Operators]] [tag[Listops Operators]]), Tiddly simply doesn't responding, I think it's causing problems in the plugin.

Reply all
Reply to author
Forward
0 new messages