TW5-Graph display using transclusion to derive graph name

Attempting (and failing) to render a TW5-graph using the $graph.view widget. The title of a graphTiddler to render ($tiddler) is to be derived using a macrocall. Although the macrocall works, the graph is not rendered, as per below screen grabs. Hardcoding the title of a graphTiddler within the $graph.view widget rednders the graph correctly.

To demo, the following tiddler was created on TW5-Graph

Tiddler Title : ShowTW5Graph
Tiddlyer Text :

\define TWGraphName(grphname) $:/graph/$grphname$

<$set name=grphname value="Introduction" />

<$set name="tw5graphtitle" value="""<$macrocall $name="TWGraphName" grphname="Introduction" />""" >

!Graph1 - derived graph title - does not work

Graph Link : <<tw5graphtitle>>

<$graph.view $tiddler=<<tw5graphtitle>> />

!Graph2 - using graphname
<$graph.view $tiddler="$:/graph/Introduction" />

Screengrab of the two graphs:


Any pointers on how to resolve?

Thanks,
Gt

Hi @goldtiddler

Try this:

\define TWGraphName(grphname) $:/graph/$grphname$

<$let
   tw5graphtitle=<<TWGraphName "Introduction">>
>

!Graph1 - derived graph title - //does// ~~not~~ work!

Graph Link : <<tw5graphtitle>>

<$graph.view $tiddler=<<tw5graphtitle>> />

!Graph2 - using graphname
<$graph.view $tiddler="$:/graph/Introduction" />

</$let>

The problem in your original code was that you can’t nest a <$macrocall> widget inside parameter value definition of another widget.

Hope this helps,

Fred

Hi @tw-FRed Thank you for your quick response. The solution works prefectly.

Hi @tw-FRed, sorry to trouble you again. What if the Introduction in $let stanza was to be derived from the output of another procedure or macrocall with parameters ?

Thanks in advance.

Depending on the content of the procedure or macro, it might be possible to transform it into a series of functions, which can be nested, or to use the <$wikify> widget to store the result of the macro/procedure rendering into a variable.

Can you show the procedures or macros you’re talking about?

Fred

Its simply a field value assigned to a variable :set name=grphIntroduction value={{!!fldgrphname}}

Field fldgrphname would contain Introduction

grphIntroduction would then needs to be passed as a parameter to the macro TWGraphName.

I converted your macro to a function, which can be called from within a {{{ ... }}} filtered transclusion with a field value as a parameter.

Here’s the code:

\function TWGraphName(grphname) [[$:/graph/]addsuffix<grphname>]

<$let
   tw5graphtitle={{{ [function[TWGraphName],{!!fldgrphname}] }}}
>

Graph Link : <<tw5graphtitle>>

<$graph.view $tiddler=<<tw5graphtitle>> />

</$let>

Don’t hesitate to ask if you want explanations, I’ll try to answer tomorrow, but now it’s time to sleep…

Fred

1 Like

@tw-FRed

The solution works perfectly.

Thankyou for spending your time working through this problem.

I will try and understand the syntax. Will get back if I have any questions.

Thanks,
Gt