C# 有向图生成库
我注意到 Visual Studio 可以使用称为 DGML 的东西生成图形。
我想在我的 C# 应用程序中生成如下图所示的图表。
不必像VS一样互动。我只想生成一个静态的这样的图像并将其保存为通用图形文件,例如PNG。
有没有免费的 .NET 库可以实现这个目的?
I noticed that Visual Studio can generate graphs using something called DGML.
I would like to generate a graph like the following one in my C# application.
It does not have to be interactive like the VS. I just want to generate a static such image and save it as a general graphics file, such as PNG.
Is there any free .NET library for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有点晚了,但实际上自己实现起来相对容易:
A little late, but it's actually relatively easy to implement yourself:
对于事后的任何人来说,现在有一个 NuGet 包 (GitHub),可以更轻松地创建 DGML 文件,包括支持样式和其他属性元数据。我最初使用了 Simon 的答案(它非常适合我最初的需求),然后在寻找改进输出的方法时偶然发现了 NuGet 包。希望有帮助。
对于任何对方便的工具组合感兴趣的人,我一直将其与 DgmlImage (NuGet 包;注意,这会将自身公开为工具目录中的可执行文件包的,所以我手动将其提取到我可以轻松调用的地方),NDepend (商业但令人难以置信方便的软件,我相信免费开源项目),以及 LINQPad (免费,但值得我的许可证意见)生成图表在尝试设计主要重构时针对相当复杂的代码库进行临时查询。能够使用简单的 LINQ 查询询问有关代码库的问题、生成图表并快速连续显示结果,真是太棒了。请注意,我不隶属于任何这些项目/产品,我刚刚使用这些工具组合获得了如此美妙的体验,我想我会向任何尝试类似东西的人推荐它。
For anybody coming along after the fact, there is now a NuGet Package (GitHub) that makes it easier to create DGML files, including support styling and additional property metadata. I used Simon's answer initially (which worked great for my initial needs) and then stumbled on the NuGet package when looking for ways to improve my output. Hope it helps.
For anybody interested in a handy combination of tools, I've been using this in conjunction with DgmlImage (NuGet Package; note, this exposes itself as an executable in the tools directory of the package, so I manually extracted it to somewhere I could call it easily), NDepend (commercial but incredibly handy software, I believe free to open source projects), and LINQPad (free, but worth the license in my opinion) to generate diagrams from ad-hoc queries against a fairly complex codebase while trying to design a major refactor. It has been fantastic being able to ask questions about the codebase using simple LINQ queries, generate diagrams, and display the results in rapid succession. Note that I am not affiliated with any of these projects/products, I've just had such a wonderful experience using this combination of tools that I thought I'd recommend it to anybody trying to something similar.
我过去曾使用 NodeXL 在 Web 应用程序中生成工作流程图,但它适用于桌面应用程序以及互动。
该描述可能会让您有点困惑,让您认为它仅适用于 Excel。完全不是,您可以直接使用它的对象模型,并从 .NET 中绘制任何您想要的图形。
I have used NodeXL in the past, for generating workflow graphs within a web application, but it is suitable for desktop applications and interaction as well.
The description might confuse you a bit, making you think it's just for Excel. Not at all, you can use it's object model directly and graph whatever you want from .NET.
我自己没有尝试过,但阅读了 Graph# 的一些建议。
原始代码以前位于 Codeplex,但由于该代码已于 01/07/2021 关闭,因此这里是找到多个分支的 Github 链接:
https://github.com/search?p=1&q=graphsharp&type=Repositories
(感谢 @ergohack 提供它。)
Did not try it by myself, but read some recommendations for Graph#.
The original code was formerly at Codeplex, but since this is closed at 01/07/2021, here is a Github link which finds several forks:
https://github.com/search?p=1&q=graphsharp&type=Repositories
(Thanks to @ergohack for providing it.)