Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I pass html-text from page or user macro into a custom macro graphviz

ellodj April 8, 2020

Hi,

plan is to render a organization chart for my using the App "Graphviz". The data comes from SQL-Query using the App "SQL for Confluence".

The Macro "graph-from-table" doesen't work for me, because I need special formated objects/labels to display as you can see below.

 

The following data was generated in a Confluence User Macro using Javascript and stored on page in this html tag:

<p id="GVFINALDATA"></p>

Here is the Data from the Confluence User Macro:

digraph {

graph [fontname = "arial"];

node [shape = record, fontname = "arial"];

edge [fontname = "arial"];

"xxx"[label="{Namexxx|{Typ: xxx|ID1: xxx|ID2: xxx}}"];

"yyy"[label="{Nameyyy|{Typ: yyy|ID1: yyy|ID2: yyy}}"];

... more lines of labels ...

"xxx" -> "yyy";

... more lines of relations ...

}

 

I tested Velocity and also Javascript to generate the data. The problem is always the last step, copying the data into the body of the graphviz macro.

It works, if I hand over pre defined data using velocity (server site) to the Macro.

 

#set ($data = 'digraph { graph [fontname = "arial"]; ... more lines ...}')

<ac:structured-macro ac:macro-id="fe3a6021-d09b-495b-8079-7b33c223cba1" ac:name="graphviz" ac:schema-version="1">

<ac:plain-text-body><![CDATA[$data]]></ac:plain-text-body>

</ac:structured-macro>

 

But it doesent't work using Javacript at client site - I know it's to late, the page already exists.

So, the question is, how can I call the Macro "graphviz" using javascript on client site and passing the data into the body? 

Or is it possible to use velocity in a new User Macro, which reads the data from the existing html paragraph like using "document.all.GVFINALDATA.innerHTML" in Javascript?

Many thanks for your help.

Reguards Jörg

 

 

2 answers

0 votes
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 8, 2020

Is Graphviz available as a Confluence plugin?

ellodj April 9, 2020

Yes, it is.

 

Graphviz Diagrams for Confluence

by Bob Swift Atlassian Apps (an Appfire company)

 

We use it on-premises, Server-Version.

0 votes
ellodj April 8, 2020

I've additional information but not the solution...

The following example works...

 

AJS.toInit(function() {

document.getElementById('GVOUTPUT').innerHTML = '$action.getHelper().renderConfluenceMacro("{cheese}")';

})

 

But not the one with the Call for the "graphviz"...

AJS.toInit(function() {

document.getElementById('GVOUTPUT').innerHTML = '$action.getHelper().renderConfluenceMacro("{digraph:"Test XXX Test"}")';

})

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
6.15.9
TAGS
AUG Leaders

Atlassian Community Events