All Projects → DomParfitt → graphviz-react

DomParfitt / graphviz-react

Licence: MIT License
React component for displaying Graphviz graphs

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to graphviz-react

sqlw-mysql
Wrapper code (or any text source) generator for MySQL databases and queries
Stars: ✭ 45 (-30.77%)
Mutual labels:  graphviz
graphviz network
Creating network diagrams with Graphviz
Stars: ✭ 72 (+10.77%)
Mutual labels:  graphviz
craftql
A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format
Stars: ✭ 75 (+15.38%)
Mutual labels:  graphviz
j2
j2 is a minimalist concatenative programming language that makes up for its simplicity by its ability to natively bind with C libraries' ABI *and types*, *without glue*
Stars: ✭ 37 (-43.08%)
Mutual labels:  graphviz
DecisionTrees
A python implementation of the CART algorithm for decision trees
Stars: ✭ 38 (-41.54%)
Mutual labels:  graphviz
spark-sql-flow-plugin
Visualize column-level data lineage in Spark SQL
Stars: ✭ 20 (-69.23%)
Mutual labels:  graphviz
graphstore
Fast in-memory graph structure, powering Gephi
Stars: ✭ 64 (-1.54%)
Mutual labels:  graphviz
doteur
Tool to automate the visualisation of SQL schemas from a SQL file
Stars: ✭ 80 (+23.08%)
Mutual labels:  graphviz
cl-dot
Common Lisp package for generating GraphViz (dot) files
Stars: ✭ 24 (-63.08%)
Mutual labels:  graphviz
GiGraph
Simple yet versatile library for generating graphs in the DOT language
Stars: ✭ 25 (-61.54%)
Mutual labels:  graphviz
graph
modern mathematical graph/network library written in PHP
Stars: ✭ 12 (-81.54%)
Mutual labels:  graphviz
gcb-visualizer
Cloudbuild pipeline visualizer with graphviz
Stars: ✭ 21 (-67.69%)
Mutual labels:  graphviz
pathway-mapper
PathwayMapper: An interactive and collaborative graphical curation tool for cancer pathways
Stars: ✭ 47 (-27.69%)
Mutual labels:  graphviz
visualsc
A simplicial complex and hypergraph visualization tool similar to Graphviz.
Stars: ✭ 31 (-52.31%)
Mutual labels:  graphviz
setup-graphviz
▶️ GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).
Stars: ✭ 20 (-69.23%)
Mutual labels:  graphviz
ipydagred3
ipywidgets library for drawing directed acyclic graphs in jupyterlab using dagre-d3
Stars: ✭ 38 (-41.54%)
Mutual labels:  graphviz
vscode-interactive-graphviz
Interactive Graphviz Dot Preview for Visual Studio Code
Stars: ✭ 57 (-12.31%)
Mutual labels:  graphviz
poddotify
A command line tool: from a Podfile.lock to an image.
Stars: ✭ 79 (+21.54%)
Mutual labels:  graphviz
alphasql
AlphaSQL provides Integrated Type and Schema Check and Parallelization for SQL file set mainly for BigQuery
Stars: ✭ 35 (-46.15%)
Mutual labels:  graphviz
state machines-graphviz
Graphviz module for state machines
Stars: ✭ 27 (-58.46%)
Mutual labels:  graphviz

graphviz-react

Continuous Integration

  1. Overview
  2. Install
  3. Usage
    1. Props
    2. NextJS
    3. Examples
  4. Dependencies

Overview

graphviz-react provides a simple to use component for rendering Graphviz objects in React. It effectively acts as a React-flavoured wrapper over the d3-graphviz library, providing a uniform way to use the renderer. graphviz-react is written in Typescript and provides typing declarations.

A demo of this component can be found here.

Install

From the root directory of your React project run the following command.

npm install graphviz-react

N.B. There is currently an issue with react-scripts and the viz.js package used by d3-graphviz that causes heap overflows when running react-scripts start and react-scripts build. To get around this set --max_old_space_size=4096 when running. This can be done by either running the following:

NODE_OPTIONS=--max_old_space_size=4096 npm run start

or by adding the flag to the relevant commands in the scripts section of your package.json as such:

"scripts": {
  "start": "react-scripts --max_old_space_size=4096 start",
  "predeploy": "react-scripts --max_old_space_size=4096 build",
}

Usage

Add an import to the top of the component you wish to use Graphviz with.

import { Graphviz } from 'graphviz-react';

To render a Graphviz component as part of an existing React component simply include the Graphviz tag as part of that component's render function along with the dot prop.

Props

The following props are available to the component:

dot: string
options?: GraphvizOptions
className?: string
  • dot is required for all instances of the component. It expects a string containing a valid graph definition using the Graphviz DOT language. Details of the DOT language can be found here. Note that neither the component nor the underlying renderer check the validity of the DOT string.

  • options is an optional array of rendering options for the component. It is aligned with the options accepted by the d3-graphviz renderer (see the API for details). The follow values are set by default:

    fit: true
    height: 500
    width: 500
    zoom: false

    Any provided options are treated as additive to the default options. That is, the values above will not be overwritten by the provided options unless explicitly done so.

  • className attaches an HTML class attribute to the top level of the component to allow for easier styling.

NextJS

By default NextJS pre-renders every page. This causes issues with graphviz-react as it relies on attaching rendered graphs to DOM components, which are only available client-side, not server-side.

The workaround for this is to use dynamic imports to import the package without server-side rendering on pages where the component is required:

import dynamic from 'next/dynamic';

const Graphviz = dynamic(() => import('graphviz-react'), { ssr: false });

const GraphvizPage = () => {
  const dot = 'graph{a--b}';

  return <Graphviz dot={dot} />;
}

export default GraphvizPage;

Examples

The below shows a simple React component using the Graphviz component to render a simple DOT string (GraphViz Pocket Reference).

<Graphviz dot={`graph {
  grandparent -- "parent A";
  child;
  "parent B" -- child;
  grandparent --  "parent B";
}`} />

<Graphviz dot={`digraph {
  a -> b;
  c;
  d -> c;
  a -> d;
}`} />

Dependencies

  1. React
  2. d3-graphviz
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].