question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to pass options to the underlying diagram libraries

See original GitHub issue

Some diagram libraries relies on options declared outside of the diagram definition. These options are usually used to configure the output: margin, padding, size, style, font, layout…

For instance, when using Mermaid, we can define a configuration object to configure the font size, the layout direction or the maxium width and height: https://mermaid-js.github.io/mermaid/#/./Setup?id=configuration

The goal of this issue is to define a generic format to pass these options using the API. Then, in a seconde phase, we will progressively add support for options on each diagram libraries (potentially disabling options that might be harmful in safe mode).

Query parameters

For GET requests, it makes sense to use query parameters:

GET /graphviz/svg/eNpLyUwvSizIUHBXqPZIzcnJ17ULzy_KSanlAgB1EAjQ?key=value

POST requests

POST /
{
  "diagram_source": "digraph G {Hello->World}",
  "diagram_type": "graphviz",
  "output_format": "svg",
  "diagram_options": {
    "key": "value"
  }
}

If the same option is defined as both a query parameter and as an attribute in the JSON body, I think the option defined in the JSON body should have an higher precedence.

HTTP headers

Since we can also send diagrams as plain text, we should also support HTTP headers:

POST /graphviz
Accept: image/svg+xml
Content-Type: text/plain
Kroki-Diagram-Options-Key: value

digraph G {
  Hello->World
}

In this case, it’s important to use a prefix to disambiguate option names from other header names. Again, if the same option is defined as both a query parameter and as a request header, I think the option defined as a request header should have an higher precedence.

Precedence order

  1. JSON body
  2. HTTP header
  3. Query parameter

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Mogzttercommented, Aug 3, 2021

Sneak peek with GraphViz:

graphviz-opts

1reaction
Mogzttercommented, Sep 10, 2021

Perhaps it can be used to nominate the theme used for PlantUML?

Sure, could you please open a new issue?

Speaking of themes,I wonder if we should also include themes from https://plantumlstyler.netlify.app/.

Gray tone graytone

Isaac isaac

Deep sea deepsea

Black and white blackwhite

We should probably open another issue to discuss it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure the diagrams.net and draw.io editor
To load the libraries from the libraries section above, use the defaultLibraries setting.
Read more >
Create a Data Visualizer diagram - Microsoft Support
Stage 1: Choose a Data Visualizer template · Open Visio, or select File > New if you are editing a diagram. · Select...
Read more >
Pass data between destinations - Android Developers
In the Navigation editor, click on the destination that receives the argument. · In the Attributes panel, click Add (+). · In the...
Read more >
LLVM's Analysis and Transform Passes - Documentation
A basic alias analysis pass that implements identities (two different ... This pass, only available in opt , prints the call graph into...
Read more >
My Top 13 JavaScript Diagram Libraries | HackerNoon
DHTMLX Diagram is a handy JavaScript diagramming library that allows you to add well-structured and interactive diagrams and org charts to your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found