How to use 2 fields to create a filter in a visjstimeline widget

61 views
Skip to first unread message

jln

unread,
Apr 16, 2021, 10:28:49 AM4/16/21
to TiddlyWiki
Hi,

I've a field named "filtre_domaine" with value tag[AÀP] and a second one named "filtre_institution" with value field:institution[CLARA]

I would like to "inject" these values into a visjstimeline widget

The following doesn't work :

<$visjstimeline filter=[{{!!filtre_domaine}}{{!!filtre_institution}}] startDateField="date-debut" endDateField="date-fin" format="YYYY-MM-DD" groupField="institution" boxing="auto" navpad />

so I guess I've to create a macro to concatenate the fields values:

\define concatenate_filter() [{{!!filtre_domaine}}{{!!filtre_institution}}]

The "result" of the macro is fine: when I call <<concatenate_filter>> I get

tag[AÀP]field:institution[CLARA]]

and if I copy/paste this litteral result into the widget, the Gantt chart is ok.

But it doesn't work when I try to call the macro inside the widget:

<$visjstimeline filter=<<concatenate_filter>> startDateField="date-debut" endDateField="date-fin" format="YYYY-MM-DD" groupField="institution" boxing="auto" navpad />. I get "Filter error: Missing [ in filter expression" but I dont' undertand why…

Thanks!

Mark S.

unread,
Apr 16, 2021, 2:18:59 PM4/16/21
to TiddlyWiki
Try:

<$visjstimeline filter="[<currentTiddler>get[filtre_domaine]compare:string:eq{!!filtre_institution}]" startDateField="date-debut" endDateField="date-fin" format="YYYY-MM-DD" groupField="institution" boxing="auto" navpad />

This requires a recent edition of TW since it uses the compare operator.

Double braces (e.g. {{ and }} ) don't work inside of filters. They get reduced to single braces (as above). Text substitution only works inside of macros, so here instead I use the "get" operator to fetch the contents of the filtre-_domaine field and then compare it with the contents of filtre_institution. It's good practice to put your filter inside double quotes.

This is a case where seeing a website would help -- setting up my own visjstimeline test site might take hours.

Good luck!

jln

unread,
Apr 17, 2021, 12:20:58 PM4/17/21
to TiddlyWiki
Thank you very much Mark. I couldn't get your solution to work, but I did it differently, with a macro:

\define concatenate_filter(fd fi)
<$visjstimeline filter="[$fd$$fi$]" startDateField="date-debut" endDateField="date-fin" format="YYYY-MM-DD" groupField="institution" boxing="auto" navpad />
\end

<$macrocall $name="concatenate_filter" fd={{!!filtre_domaine}} fi={{!!filtre_institution}} />
Reply all
Reply to author
Forward
0 new messages