GraphVizWrapperCore 1.0.0

dotnet add package GraphVizWrapperCore --version 1.0.0
NuGet\Install-Package GraphVizWrapperCore -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GraphVizWrapperCore" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GraphVizWrapperCore --version 1.0.0
#r "nuget: GraphVizWrapperCore, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GraphVizWrapperCore as a Cake Addin
#addin nuget:?package=GraphVizWrapperCore&version=1.0.0

// Install GraphVizWrapperCore as a Cake Tool
#tool nuget:?package=GraphVizWrapperCore&version=1.0.0

nuget

PM> Install-Package GraphVizWrapperCore

Project Description

This is a C# wrapper for the GraphViz graph generator for dotnet core.

Pass in a dot string and an output type and voila, your graph is generated.

The output file is returned to you as a byte array to do as you please.

This library acts as a wrapper for the GraphViz command line tools. The graphviz command line tools may be downloaded from graphviz.org/Download.php, and need to be placed in the 'graphviz' folder relative to the GraphVizWrapper dll upon deployment.

Originally from https://github.com/JamieDixon/GraphViz-C-Sharp-Wrapper

Usage

using GraphVizWrapper;
using GraphVizWrapper.Commands;
using GraphVizWrapper.Queries;

// These three instances can be injected via the IGetStartProcessQuery, 
//                                               IGetProcessStartInfoQuery and 
//                                               IRegisterLayoutPluginCommand interfaces

var getStartProcessQuery = new GetStartProcessQuery();
var getProcessStartInfoQuery = new GetProcessStartInfoQuery();
var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

// GraphGeneration can be injected via the IGraphGeneration interface

var wrapper = new GraphGeneration(getStartProcessQuery, 
								  getProcessStartInfoQuery, 
								  registerLayoutPluginCommand);

byte[] output = wrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Png);

Getting started

Install GraphViz

If you haven't already, download and install GraphViz from graphviz.org/Download.php. Make sure the 'graphVizLocation' key in each of the following files points to the 'bin' folder of your installation:

/src/GraphVizWrapper/App.config /src/GraphVizWrapper.Tests/App.config /sample-applications\MVC4\GraphVizWrapper-MVC4Sample/Web.config

Clone the repository

git clone https://github.com/helgeu/GraphViz-C-Sharp-Wrapper

Add MSBuild to PATH

If you haven't used this before, you need to add the .Net4 framework to your PATH environment variable. Instructions on how to do so may be found here.

In the terminal (command prompt), change directory to the build folder and run the build.bat file

cd build
build.bat

This will build the GraphVizWrapper project, configure the necessary GraphViz files and move them into the GraphvizWrapper bin folder and then build/configure the sample project(s) included.

Copy files to your own project

Once you've run the build you're ready to move the necessary files to your own project. You'll need the GraphVizWrapper.dll file from the bin folder along with the GraphViz folder (the dll and this folder must reside at the same level and be placed into the bin of your application at build time)

You must either include the GraphViz folder (containing the files from the /bin folder of your installation), or specify the location of this folder inside either your app.config or web.config using the graphVizLocation key:

<appSettings>
    <add key="graphVizLocation" value="C:\Program Files (x86)\Graphviz2.38\bin" />
</appSettings>

Running the sample application

  1. Make sure you've run build.bat
  2. Navigate to sample-applications/MVC4
  3. Open the GraphVizWrapper-MVC4Sample.sln in Visual Studio. F5 to run the project.

The sample takes a binary dependency on GraphVizWrapper.dll which is placed into the lib folder when you run build.bat

If you make modifications to the GraphVizWrapper you'll need to run build.bat again to make sure this sample application has the latest version of GraphVizWrapper.dll

This sample application demonstrated one way of displaying the returned graph byte array to a user in an MVC4 application:

Controller Action Method:

using GraphVizWrapper;
using GraphVizWrapper.Commands;
using GraphVizWrapper.Queries;

var bytes = this.graphVizWrapper.GenerateGraph("digraph{a -> b; b -> c; c -> a;}", Enums.GraphReturnType.Jpg);
            
// Alternatively you could save the image on the server as a file.
var viewModel = string.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(bytes));
ViewBag.Data = viewModel;
return this.View();

Razor View

<img src="@ViewBag.Data" />
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 3,281 3/29/2020