magjac
(Magnus Jacobsson)
2020 年5 月 27 日 21:57
1
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 个赞
pfaffman
(Jay Pfaffman)
2021 年4 月 18 日 18:47
2
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 个赞
sam
(Sam Saffron)
2021 年4 月 19 日 01:24
3
Yes there are a bunch of edge cases with this approach, recommend anyone wanting graphviz use:
3 个赞
magjac
(Magnus Jacobsson)
2024 年1 月 14 日 15:57
4
@pfaffman 抱歉这么晚才看到这篇帖子并采取行动。我一定是误关闭了通知。我以前自己也注意到了这个问题,但当时没有时间处理,也不记得我发过这个帖子,也不知道还有其他人在使用它。
我很高兴地宣布 d3-graphviz 主题组件现在又能正常工作了。您可以在 Render Graphviz graphs directly in your posts - Announcements - Graphviz 看到它的实际效果。
@sam 您现在可以移除 broken 标签了吗?
4 个赞
fbpbdmin
(deepblue)
2024 年4 月 27 日 23:23
5
我已经安装了这个组件(Discourse 3.2.1)
将上面的示例复制到一个新帖子中,它没有渲染成图表
能否有人确认一下,这个现在是否可以工作了,谢谢……
这是由“内容安全策略”引起的……
不确定要在“内容安全策略脚本源”设置中添加什么才能使其工作……能否有人帮忙,谢谢……
fbpbdmin
(deepblue)
2024 年4 月 28 日 00:19
7
谢谢 @Arkshine
我们托管的实例不包含该计划的 graphviz 插件
尝试将这 3 个文件添加到“内容安全策略脚本 src”设置中,但无效……
2 个赞
magjac
(Magnus Jacobsson)
2024 年4 月 29 日 20:24
10
如果您对单个静态图满意,那么 discourse-graphviz-theme-component 可能就足够了,但如果您想在图之间使用动画过渡并能够控制图渲染的各个方面,您可能想尝试 D3 Graphviz 主题组件。您可以在以下位置看到它的实际效果:
Render graphs directly in your posts with [dot]your DOT source here[/dot]. When you are posting something here at the forum and want to show a graph that is generated by some DOT source code; wouldn’t it be great if you could just generate the...
Reading time: 9 mins 🕑
Likes: 14 ❤
不需要白名单。这是我们的设置:
1 个赞
fbpbdmin
(deepblue)
2024 年4 月 30 日 00:14
11
嘿,@magjac
我想试试 D3 动画,但我遇到了上面提到的内容安全策略问题,有什么设置可以更改以使其正常工作吗?
我们的实例现在是 3.2.1。谢谢…
I installed this component, (Discourse 3.2.1)
copied the example above into a new post, it does not render as a graph,
could someone confirm, if this one works now, thanks…
this is caused by “Content Security Policy” thing…
not sure what to add in “content security policy script src” setting to make it work… could someone help, thanks…
deepblue:
一些设置更改,使其能够工作
不幸的是,他正在使用使用严格动态 CSP 的新设置,而您的 3.2.1 版本中没有该设置。
1 个赞