D3 Graphviz Theme Component

The D3 Graphviz Theme Component allows you to add animated Graphviz graphs to your post using the DOT language. Based on d3-graphviz.

Repository: GitHub - magjac/discourse-d3-graphviz: Discourse theme component for rendering animated Graphviz graphs using DOT source code

Installation

See How do I install a Theme or Theme Component?

Usage

Static graphs

This is just a brief introduction. You may want to read the detailed Render Graphviz graphs directly in your posts - Announcements - Graphviz which shows the theme component in action or join the Graphviz fourm where you can use it yourself.

To render a graph inline in your post, wrap the graph definition in dot tags like this:

[dot] digraph {a -> b} [/dot]

The block form is also supported:

[dot]
digraph {
  a -> b
}
[/dot]

Animated transitions between graphs

An animated transition between multiple graphs is shown when more than one graph is added to the same paragraph of a post and there is only whitespace between them:

[dot] digraph {bgcolor=lightblue a -> b} [/dot]
[dot] digraph {bgcolor=lightblue a -> b; a -> c} [/dot]
[dot] digraph {bgcolor=lightblue a -> b; a -> c; b -> c} [/dot]

or

[dot]
digraph {
  a -> b
}
[/dot]
[dot]
digraph {
  a -> b
  a -> c
}
[/dot]
[dot]
digraph {
  a -> b
  a -> c
  b -> c
}
[/dot]

Paragraphs are separated by blank lines, so this will generate three separate graphs:

[dot] digraph {bgcolor=lightblue a -> b} [/dot]

[dot] digraph {bgcolor=lightblue a -> b; a -> c} [/dot]

[dot] digraph {bgcolor=lightblue a -> b; a -> c; b -> c} [/dot]

Options

The graphs and the animated transitions are highly customizable by options that you can add to the dot tag. See Render Graphviz graphs directly in your posts - Announcements - Graphviz.

「いいね!」 8

A client yesterday reported that all of the content of their posts was missing. I disabled this theme to resolve the problem.

I think this should be moved to #theme:broken-theme , but wondered if anyone else has had trouble.

「いいね!」 3

Yes there are a bunch of edge cases with this approach, recommend anyone wanting graphviz use:

「いいね!」 3

@pfaffman この投稿に気づかず、すぐに対応できなかったことをお詫びします。通知を誤ってオフにしてしまったようです。以前、この問題に自分で気づいたのですが、その時は対応する時間がなく、投稿したことも覚えておらず、他の誰かが使用していることも知りませんでした。

d3-graphvizテーマコンポーネントが再び動作するようになったことをお知らせできることを嬉しく思います。https://forum.graphviz.org/t/render-graphviz-graphs-directly-in-your-posts/125で実際に動作している様子をご覧いただけます。

@sam brokenタグを削除していただけますか?

「いいね!」 4

このコンポーネントをインストールしました。(Discourse 3.2.1)
上記の例を新しい投稿にコピーしましたが、グラフとしてレンダリングされません。
これが現在機能するかどうか、誰か確認していただけますか?よろしくお願いします…

これは「コンテンツセキュリティポリシー」が原因です…
「コンテンツセキュリティポリシー スクリプト src」設定に何を追加すれば機能するか分かりません… 誰か助けていただけますか?よろしくお願いします…

プラグインを試しましたか?より安定しているようです。

おそらく、これらのリンクを許可する必要があります。

「いいね!」 2

@Arkshine ありがとうございます。
ホストインスタンスには、プラン用のGraphvizプラグインが含まれていません :frowning:
「コンテンツセキュリティポリシーのスクリプトソース」設定にこれらの3つのファイルを追加しようとしましたが、うまくいきませんでした…

「いいね!」 2

こちらのコンポーネントをお試しいただけますでしょうか。

これにより、サードパーティ製ライブラリを統合する際のCSP問題回避策として、より良い方法となります。

注意: ラッパーが異なります。BBCodeではありません。

「いいね!」 2

ありがとう、@Arkshine
うまくいきました!

「いいね!」 2

静的なグラフで十分な場合は、discourse-graphviz-theme-component で十分ですが、グラフ間のアニメーション遷移を使用し、グラフレンダリングのさまざまな側面を制御したい場合は、D3 Graphviz Theme Component を試すことをお勧めします。実際に動作している様子は、以下で確認できます。

ホワイトリスト登録は不要です。これが私たちのセットアップです。

「いいね!」 1

ねえ、@magjac
アニメーションのためにD3のものを使ってみようと思うのですが、上記で報告したコンテンツセキュリティポリシーの問題が発生しました。動作させるために何か設定を変更する必要がありますか?
私たちのインスタンスは現在3.2.1です。よろしくお願いします…

残念ながら、彼は厳密な動的CSPを使用する新しい設定を使用していますが、これは3.2.1にはありません。

「いいね!」 1