Getting Started

Prerequisites

To use the Company Ownership component, yFiles for HTML is required. You can evaluate yFiles for 60 days free of charge on my.yworks.com. See Licensing for more information on this topic.

You can learn how to work with the yFiles npm module in our Developer’s Guide. A convenient way of getting access to yFiles is to use the yFiles Dev Suite.

Project Setup

  1. Installation

    In addition to yFiles, the Company Ownership component requires React to be installed in your project. If you want to start your project from scratch, we recommend using vite:

    npm create vite@latest my-company-ownership-app -- --template react-ts

    Add the yFiles dependency:

    npm install <yFiles package path>/lib-dev/yfiles-26.0.0+dev.tgz

    Sample package.json dependencies The resulting package.json dependencies should resemble the following:

       "dependencies": {
         "react": "^18.2.0",
         "react-dom": "^18.2.0",
         "yfiles": "./lib-dev/yfiles-26.0.0.tgz"
      }

    Now, the component itself can be installed:

    npm install @yworks/react-yfiles-company-ownership
  2. License

    Be sure to invoke registerLicense before using the Company Ownership React component. When evaluating yFiles, the license JSON file is found in the lib/ folder of the yFiles for HTML evaluation package. For licensed users, the license data is provided separately.

    License registration

    Import or paste your license data and register the license, e.g. in App.tsx:

    import yFilesLicense from './license.json'
    
    registerLicense(yFilesLicense)
  3. Stylesheet

    Make sure to import the CSS stylesheet as well:

    import '@yworks/react-yfiles-company-ownership/dist/index.css'
  4. Usage

    You are now all set to utilize the Company Ownership component with your data! See a basic example App.tsx below:

    import {
      CompanyOwnership,
      CompanyOwnershipData,
      Entity,
      Ownership,
      registerLicense
    } from '@yworks/react-yfiles-company-ownership'
    
    import '@yworks/react-yfiles-company-ownership/dist/index.css'
    
    import yFilesLicense from './license.json'
    
    registerLicense(yFilesLicense)
    
    const data: CompanyOwnershipData<Entity, Ownership> = {
      companies: [
        {
          id: 1,
          name: 'Monster Inc',
          type: 'Corporation'
        },
        {
          id: 2,
          name: 'Connect Partner',
          type: 'RCTB'
        },
        {
          id: 3,
          name: 'Large Scale Trust',
          type: 'Trust'
        }
      ],
      connections: [
        {
          type: 'Ownership',
          ownership: 0.4,
          sourceId: 1,
          targetId: 2
        },
        {
          type: 'Ownership',
          ownership: 0.2,
          sourceId: 1,
          targetId: 3
        }
      ]
    }
    
    function App() {
      return <CompanyOwnership data={data}></CompanyOwnership>
    }
    
    export default App
    

    Note: By default, the CompanyOwnership component adjusts its size to match the size of its parent element. Therefore, it is necessary to set the dimensions of the containing element or apply styling directly to the CompanyOwnership component. This can be achieved by defining a CSS class or applying inline styles.

Learn More

Explore the possibilities of visualizing company ownership diagrams with the yFiles Company Ownership Component. For further information about yFiles for HTML and our company, please visit yWorks.com.

If you are exploring a different use case and require another React component, please take a look at the available React components powered by yFiles!

For support or feedback, please reach out to our support team or open an issue on GitHub. Happy diagramming!