algenty / grafana-flowcharting

Flowcharting, plugin for Grafana to create complexe visio's draws style like technical architectures, floorplan, diagrams, hierarchical schema based on draw.io
Apache License 2.0
977 stars 149 forks source link

Loading diagrams in XML format #185

Closed VinuraD closed 4 years ago

VinuraD commented 4 years ago

Hello! I am new to grafana as well as to this plugin. I am generating an XML content like this: in a flask server and try to retrieve that in grafana by providing my localhost url. (I have enabled the download source option). Is this method possible? However the graph is not loading and no error is displayed either.

algenty commented 4 years ago

Hi @VinuraD Welcome to grafana users ;) your xml must be begin by mxgraph, i can't see that in you model try a graph in draw.io and clieck on menu Extra > edit diagram See the xml like this example https://app.diagrams.net/?lightbox=1&highlight=0000ff&edit=_blank&layers=1&nav=1&title=Untitled%20Diagram.drawio#RtVXbjtowEP2aPLYiMddHCLSVdhErIfWyL5Wxh8SqEyPjLKFfXxsPuYJ2K%2B0iHsbHM%2BOZc8ZOQOKs%2FKrpIV0rDjKIBrwMyDKIonAYRYH7D%2FjZI5PZ0AOJFhydamAr%2FgKCA0QLweHYcjRKSSMObZCpPAdmWhjVWp3abnsl26ceaAI9YMuo7KM%2FBDepR6fRpMa%2FgUjS68nheOZ3Mnp1xk6OKeXq1IDIKiCxVsp4KytjkI68Ky8%2B7sud3aowDbl5S8DzaLV4%2BJ4MN%2FSBLmK2Xv%2FeLD9hlhcqC2wYizXnKwO27oMz2VmKnIMOyOKUCgPbA2UOP1nhLZaaTNpVaM2dKqwjf9xVAGV%2FEu3QTWFsFkAcDwdtoLzbVVhxZYcMVAZGn60LBgyRXRyvam5OtVhjhNKGTlPEKI5HUiWuGbQGkvgfhEY9QufMKH2X1SKT3oEsHA%2FCTt4j3YF8UkdhhMqty04ZozLrIN3GouIyVtLF2Wxkf%2Fk1csylSFysUR1tlBcgrq7L4H10qIhHIcJpXwhyQ4jxRwlB3j7Zewnl3L0VlgrIOZpLJunxKFibPyiF%2BdmwfzkKP49wtSyR0cvi3KIXeO%2Bl6ZBri1OFZvD6fTVUJ2BeG8O%2BWA0xRjfEuGIaJDXipV3uLYXwhCclbCPVLISz9iyQSUdk3yZGNZ%2BsTqLu7SZRJ5HnoZfoMjBV27dmyC7rl9e7198vsvoH

VinuraD commented 4 years ago

Hi! Thanks for replying...! So this means that even if I generate the XML content of this example (your's) locally, I should be able to generate the graph? Hence, I just copied its XML content and only changed cell-ids (pardon me for my laziness) and returned it through the server to the plugin. But the graph still not showing up and an error comes up; "Error : TypeError: Failed to fetch" Is this kind of drawing not supported or can there be any other issue ? (I have not previously come through the mxgraph format as well) I have tried it returning as a string with xml syntax as well as an XML elementtree

algenty commented 4 years ago

try get started in doc

VinuraD commented 4 years ago

Okay...I will be referring the docs as well. Meanwhile this is the new XML content I am trying to retrieve to the plugin, here

VinuraD commented 4 years ago

Hi, on the manual and repo site for the plugin (site link) you have put, "By selecting URL, flowcharting downloads xml file from url with mxgraph definition. /!\ NOT EMPLEMENTED". Does that mean this functionality is not implemented yet? Thanks

algenty commented 4 years ago

See configuration examples at https://play.grafana.org/d/Unu5JcjWk/flowcharting-index?orgId=1

CrashLaker commented 4 years ago

Hi @VinuraD

You export it to XML.

image

uncheck compress image

then output only the <mxGraphModel> content in your flask endpoint including <mxGraphModel> tag. image

then customize your shapes inside <mxGraphModel> as you wish

then in grafana flowcharting choose Download Source using source type XML (note you can do this with both CSV and XML just return the right syntax. both have its perks). image

this should work :)

algenty commented 4 years ago

or menu > extra > edit diagram

CrashLaker commented 4 years ago

omg @algenty ... i didn't know that! o.O just saved a bunch os clicks 👏

CrashLaker commented 4 years ago

something like this would work image

image

image

VinuraD commented 4 years ago

@CrashLaker Thanks for reply. It was my fault at the flask server implementation that I had not implemented Cross Origin Resource Sharing (CORS), Otherwise it was the same way. So, my bad! Thanks for the support @CrashLaker and @algenty

VinuraD commented 4 years ago

@CrashLaker Sorry for bothering again. You mentioned that both CSV and XML can be used as source type. Could you please guide me to source/doc or any example which shows that. In my case I can only select "Source Type: XML content" from the drop down menu in grafana. Thanks!

algenty commented 4 years ago

CSV only available since 0.9 released yesterday

VinuraD commented 4 years ago

That's great. I updated and checked the same process with source type csv. However, I encountered a different issue. But will start that in another new thread. Thanks!

layer3lv commented 2 years ago

Hi,

still, getting an error Error : "TypeError: Failed to fetch" if I want to host my file https://example.com/example.xml any suggestion why it's happening? grafana 8.2.5

p.s

on the server side where I host XML file webserver returns status code 200 on grafana req for XML file.