{"analyzedAt":"2022-10-07T08:35:15.851Z","collected":{"metadata":{"name":"graphviz-react","scope":"unscoped","version":"1.2.5","description":"React component for displaying Graphviz graphs","keywords":["React","Graphviz"],"date":"2022-10-06T11:46:43.680Z","author":{"name":"Dom Parfitt"},"publisher":{"username":"domparfitt","email":"mail@domparfitt.com"},"maintainers":[{"username":"domparfitt","email":"mail@domparfitt.com"}],"repository":{"type":"git","url":"git+https://github.com/DomParfitt/graphviz-react.git"},"links":{"npm":"https://www.npmjs.com/package/graphviz-react","homepage":"https://github.com/DomParfitt/graphviz-react#readme","repository":"https://github.com/DomParfitt/graphviz-react","bugs":"https://github.com/DomParfitt/graphviz-react/issues"},"license":"MIT","dependencies":{"d3-graphviz":"^2.6.1"},"devDependencies":{"@testing-library/react":"^10.4.7","@types/d3-graphviz":"^2.6.3","@types/jest":"^25.2.3","@types/jsdom":"^16.2.3","@types/react":"^16.9.43","@typescript-eslint/eslint-plugin":"^3.6.1","@typescript-eslint/parser":"^3.6.1","eslint":"^7.5.0","eslint-config-airbnb-typescript":"^8.0.2","eslint-config-prettier":"^8.5.0","eslint-plugin-import":"^2.22.0","eslint-plugin-jsx-a11y":"^6.3.1","eslint-plugin-only-warn":"^1.0.2","eslint-plugin-prettier":"^4.2.1","eslint-plugin-react":"^7.30.1","jest":"^28.1.3","jest-environment-jsdom":"^28.1.3","jsdom":"^16.3.0","prettier":"^2.7.1","react-dom":"^16.13.1","ts-jest":"^28.0.8","ts-node":"^10.9.1","typescript":"^4.8.4"},"peerDependencies":{"react":">= 16.13.1"},"releases":[{"from":"2022-09-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":5},{"from":"2022-07-09T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":6},{"from":"2022-04-10T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":6},{"from":"2021-10-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":6},{"from":"2020-10-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":7}],"hasTestScript":true,"hasSelectiveFiles":true,"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(() => import('graphviz-react'), { ssr: false });\n\nconst GraphvizPage = () => {\n  const dot = 'graph{a--b}';\n\n  return <Graphviz dot={dot} />;\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<Graphviz dot={`graph {\n  grandparent -- \"parent A\";\n  child;\n  \"parent B\" -- child;\n  grandparent --  \"parent B\";\n}`} />\n```\n\n<img width=\"513\" src=\"./img/example-graph.png\">\n\n```jsx\n<Graphviz dot={`digraph {\n  a -> b;\n  c;\n  d -> c;\n  a -> d;\n}`} />\n```\n\n<img width=\"402\" src=\"./img/example-digraph.png\">\n\n## Dependencies\n\n1. [React](https://www.npmjs.com/package/react)\n2. [d3-graphviz](https://www.npmjs.com/package/d3-graphviz)"},"npm":{"downloads":[{"from":"2022-10-06T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":1445},{"from":"2022-09-30T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":7103},{"from":"2022-09-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":30021},{"from":"2022-07-09T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":86350},{"from":"2022-04-10T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":160362},{"from":"2021-10-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":237997}],"starsCount":0},"github":{"starsCount":77,"forksCount":15,"subscribersCount":2,"issues":{"count":83,"openCount":8,"distribution":{"3600":31,"10800":6,"32400":4,"97200":2,"291600":2,"874800":6,"2624400":9,"7873200":5,"23619600":7,"70858800":10,"212576400":1},"isDisabled":false},"contributors":[{"username":"DomParfitt","commitsCount":288},{"username":"dependabot[bot]","commitsCount":13},{"username":"dependabot-preview[bot]","commitsCount":5},{"username":"karlhorky","commitsCount":3},{"username":"alllex","commitsCount":1},{"username":"cyberixae","commitsCount":1}],"commits":[{"from":"2022-09-30T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":18},{"from":"2022-09-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":20},{"from":"2022-07-09T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":41},{"from":"2022-04-10T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":41},{"from":"2021-10-07T00:00:00.000Z","to":"2022-10-07T00:00:00.000Z","count":43}]},"source":{"files":{"readmeSize":4304,"testsSize":8034,"hasChangelog":true},"linters":["eslint","prettier"],"outdatedDependencies":{"d3-graphviz":{"required":"^2.6.1","stable":"4.4.0","latest":"4.4.0"}}}},"evaluation":{"quality":{"carefulness":0.9999999999999999,"tests":0.6,"health":0.75,"branding":0},"popularity":{"communityInterest":100,"downloadsCount":28783.333333333332,"downloadsAcceleration":146.87671232876713,"dependentsCount":0},"maintenance":{"releasesFrequency":1,"commitsFrequency":1,"openIssues":1,"issuesDistribution":0.9}},"score":{"final":0.6337958140665583,"detail":{"quality":0.7871334724424675,"popularity":0.13626054913890556,"maintenance":0.999898800386289}}}