I am a newbee for graphviz, what I want to do is generate a picture that accept a json which describes a graph, I want to call the api in my application, and I want to use cpp as my language.
I read the document but https://www.graphviz.org/documentation/ but just found some easy and simple case
You should be able to include and call the C api from C++, as C++ is (almost) a superset of C.
However for a network API, I’d suggest/consider running the command line program as a sandboxed subprocess; graphviz has a few bugs that cause it to crash, and graphviz isn’t thread-safe (important if you want to handle multiple parallel requests). Subprocesses work around these issues. Just my 2c
Are you looking for more examples other than the examples you’ve already found? If so, we don’t have any ready made. You’ll have to search outside of the Graphviz project. If you need help with those examples or something completely different; please specify what you need help with.
Here is my case, I have got a graph json data from upstream, I want to draw a picture and send it to the webpage.
The graph json data would be like [[a,b], [a, c], [b,c]] , which means a goes to b, a goes to c, b goes to c, I thought maybe I should (1) transfer the json data into dot language used by GraphViz, and (2)use the command line to generate a picture binary ,and then I should (3) transfer the picture binary into a base64-encoded string and give it to the webpage.
That is what I have thought at the first step, I dont know if there is any better practice, since I don’t know the dot language well, and I am confused by these cases or demos in the PDF.
Maybe I should use the clib Graphviz interface to generate the base64-encoded picture string to privide to the frontend, so this may be what I prefered, but I dont know if the clib interface is easy to learn, or if the clib interface just take the dot language as parameter.
Shameless plug: Use d3-graphviz. Write a JavaScript application that converts your JSON to DOT and uses d3-graphviz to render an SVG and directly. Then send your JSON to it. Or, if you don’t want to write as much JavaScript, use your favorite language to convert JSON to DOT locally and and write a d3-graphviz based JavaScript application that just renders it.
Seems that you’re in need of an organizational consultant more than technical help . I would use Python to accomplish what you want. Parsing JSON comes out of the box and there are plenty of Graphviz Python bindings to chose from.