{"analyzedAt":"2022-07-12T15:20:26.554Z","collected":{"metadata":{"name":"@japgolly/graphviz-react","scope":"japgolly","version":"1.2.0-1","description":"React component for displaying Graphviz graphs","keywords":["React","Graphviz"],"date":"2021-07-20T05:07:47.155Z","author":{"name":"Dom Parfitt"},"publisher":{"username":"japgolly","email":"japgolly@gmail.com"},"maintainers":[{"username":"japgolly","email":"japgolly@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/DomParfitt/graphviz-react.git"},"links":{"npm":"https://www.npmjs.com/package/%40japgolly%2Fgraphviz-react"},"license":"MIT","dependencies":{"d3-graphviz":"^2.6.1","react":"^16.13.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-plugin-import":"^2.22.0","eslint-plugin-jsx-a11y":"^6.3.1","eslint-plugin-only-warn":"^1.0.2","eslint-plugin-react":"^7.20.3","jest":"^26.1.0","jsdom":"^16.3.0","react-dom":"^16.13.1","ts-jest":"^26.1.3","typescript":"^3.9.7"},"releases":[{"from":"2022-06-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-04-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-01-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":1},{"from":"2021-07-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":3},{"from":"2020-07-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":3}],"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-07-11T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-07-05T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-06-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":2},{"from":"2022-04-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":19},{"from":"2022-01-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":47},{"from":"2021-07-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":123}],"starsCount":0},"github":{"starsCount":66,"forksCount":14,"subscribersCount":2,"issues":{"count":57,"openCount":16,"distribution":{"3600":15,"10800":2,"32400":4,"97200":0,"291600":2,"874800":2,"2624400":10,"7873200":5,"23619600":7,"70858800":10,"212576400":0},"isDisabled":false},"contributors":[{"username":"karlhorky","commitsCount":3},{"username":"DomParfitt","commitsCount":251},{"username":"alllex","commitsCount":1},{"username":"dependabot-preview[bot]","commitsCount":5}],"commits":[{"from":"2022-07-05T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-06-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-04-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2022-01-13T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0},{"from":"2021-07-12T00:00:00.000Z","to":"2022-07-12T00:00:00.000Z","count":0}]},"source":{"files":{"readmeSize":4304,"testsSize":7520,"hasChangelog":true},"linters":["eslint"],"outdatedDependencies":{"react":{"required":"^16.13.1","stable":"18.2.0","latest":"18.3.0-next-dd2d65227-20220708"},"d3-graphviz":{"required":"^2.6.1","stable":"4.1.1","latest":"4.1.1"}}}},"evaluation":{"quality":{"carefulness":0.9999999999999999,"tests":0.6,"health":0.5,"branding":0},"popularity":{"communityInterest":86,"downloadsCount":6.333333333333333,"downloadsAcceleration":-0.08654870624048705,"dependentsCount":0},"maintenance":{"releasesFrequency":0.4099315068493151,"commitsFrequency":0,"openIssues":0.8654970760233919,"issuesDistribution":0.12672404555422667}},"score":{"final":0.6137809959973617,"detail":{"quality":0.7871334724424675,"popularity":0.07906976049045301,"maintenance":0.9999043945513229}}}