{"id":13566726,"url":"https://github.com/DomParfitt/graphviz-react","last_synced_at":"2025-04-04T00:32:07.898Z","repository":{"id":33201796,"uuid":"154854226","full_name":"DomParfitt/graphviz-react","owner":"DomParfitt","description":"React component for displaying Graphviz graphs","archived":false,"fork":false,"pushed_at":"2023-03-15T05:59:39.000Z","size":12384,"stargazers_count":104,"open_issues_count":13,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T21:37:00.090Z","etag":null,"topics":["graphviz","react"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DomParfitt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-26T15:18:28.000Z","updated_at":"2025-01-27T12:56:55.000Z","dependencies_parsed_at":"2024-06-18T15:21:16.030Z","dependency_job_id":"8cb97b04-c384-4247-96ed-74457fb919bc","html_url":"https://github.com/DomParfitt/graphviz-react","commit_stats":{"total_commits":326,"total_committers":12,"mean_commits":"27.166666666666668","dds":"0.40797546012269936","last_synced_commit":"59c384b220574ad30fbdd6f5c3c3416c357ceb9d"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomParfitt%2Fgraphviz-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomParfitt%2Fgraphviz-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomParfitt%2Fgraphviz-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DomParfitt%2Fgraphviz-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DomParfitt","download_url":"https://codeload.github.com/DomParfitt/graphviz-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247028316,"owners_count":20871676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphviz","react"],"created_at":"2024-08-01T13:02:15.376Z","updated_at":"2025-04-04T00:32:07.375Z","avatar_url":"https://github.com/DomParfitt.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# graphviz-react\n![Continuous Integration](https://github.com/DomParfitt/graphviz-react/workflows/Continuous%20Integration/badge.svg)\n\n1. [Overview](#overview)\n2. [Install](#install)\n3. [Usage](#usage)\n   1. [Props](#props)\n   2. [NextJS](#nextjs)\n   3. [Examples](#examples)\n4. [Dependencies](#dependencies)\n\n## Overview\n\n`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](https://www.npmjs.com/package/d3-graphviz) library, providing a uniform way to use the renderer. `graphviz-react` is written in Typescript and provides typing declarations.\n\nA demo of this component can be found [here.](https://domparfitt.com/graphviz-react)\n\n## Install\n\nFrom the root directory of your React project run the following command.\n\n```\nnpm install graphviz-react\n```\n\n***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:\n```\nNODE_OPTIONS=--max_old_space_size=4096 npm run start\n```\nor by adding the flag to the relevant commands in the `scripts` section of your `package.json` as such:\n```json\n\"scripts\": {\n  \"start\": \"react-scripts --max_old_space_size=4096 start\",\n  \"predeploy\": \"react-scripts --max_old_space_size=4096 build\",\n}\n```\n\n## Usage\n\nAdd an import to the top of the component you wish to use Graphviz with.\n\n```javascript\nimport { Graphviz } from 'graphviz-react';\n```\n\nTo 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.\n\n### Props\n\nThe following props are available to the component:\n```typescript\ndot: string\noptions?: GraphvizOptions\nclassName?: string\n```\n\n- `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](https://graphviz.org/doc/info/lang.html). Note that neither the component nor the underlying renderer check the validity of the DOT string.\n\n- `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](https://www.npmjs.com/package/d3-graphviz#creating-a-graphviz-renderer) for details). The follow values are set by default:\n\n  ```javascript\n  fit: true\n  height: 500\n  width: 500\n  zoom: false\n  ```\n\n  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.\n\n- `className` attaches an HTML `class` attribute to the top level of the component to allow for easier styling.\n\n### NextJS\nBy default `NextJS` [pre-renders](https://nextjs.org/docs/basic-features/pages#pre-rendering) 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.\n\nThe workaround for this is to use [dynamic imports](https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr) to import the package without server-side rendering on pages where the component is required:\n\n```typescript\nimport dynamic from 'next/dynamic';\n\nconst Graphviz = dynamic(() =\u003e import('graphviz-react'), { ssr: false });\n\nconst GraphvizPage = () =\u003e {\n  const dot = 'graph{a--b}';\n\n  return \u003cGraphviz dot={dot} /\u003e;\n}\n\nexport default GraphvizPage;\n```\n\n### Examples\n\nThe below shows a simple React component using the Graphviz component to render a simple DOT string ([GraphViz Pocket Reference](https://graphs.grevian.org/example)).\n\n```jsx\n\u003cGraphviz dot={`graph {\n  grandparent -- \"parent A\";\n  child;\n  \"parent B\" -- child;\n  grandparent --  \"parent B\";\n}`} /\u003e\n```\n\n\u003cimg width=\"513\" src=\"./img/example-graph.png\"\u003e\n\n```jsx\n\u003cGraphviz dot={`digraph {\n  a -\u003e b;\n  c;\n  d -\u003e c;\n  a -\u003e d;\n}`} /\u003e\n```\n\n\u003cimg width=\"402\" src=\"./img/example-digraph.png\"\u003e\n\n## Dependencies\n\n1. [React](https://www.npmjs.com/package/react)\n2. [d3-graphviz](https://www.npmjs.com/package/d3-graphviz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDomParfitt%2Fgraphviz-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDomParfitt%2Fgraphviz-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDomParfitt%2Fgraphviz-react/lists"}