npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-balkangraph-orgchart

v1.0.1

Published

A react wrapper for balkangraph-orgchart

Downloads

448

Readme

react-balkangraph-orgchart

A react wrapper for balkangraph-orgchart

NPM JavaScript Style Guide

Demo

Install

npm install --save react-balkangraph-orgchart

Usage with default template

import React, { Component } from 'react'

import OrgChart from 'react-balkangraph-orgchart'
import 'react-balkangraph-orgchart/dist/index.css'

import avatar from 'src/assets/avatar.svg'

const nodes = [{ id: 1, name: 'Andriy', pid: 0, avatar, role: 'CEO' },
  { id: 2, name: 'Yarik', pid: 1, avatar, role: 'Developer' },
  { id: 3, name: 'Sasha', pid: 1, avatar, role: 'Developer' },
  { id: 4, name: 'Oleh', pid: 1, avatar, role: 'Designer' }]

<OrgChart
  onCardClick={(object) => console.log(object)}
  nodes={nodes}
  className='org-chart-container'
  id='my-custom-id-2'
  config={{
    nodeBinding: { 
      img_0: "avatar",
      field_0: "name",
      field_1: "role"
     }
  }}
/>

Usage with custom template

For getting your custom node you should use the getNode function

getNode({ component, width, height })

types = {
  component: ReactElement
  width: number
  height: number
}
import React, { Component } from 'react'

import OrgChart, { getNode, OrgChartConfig } from 'react-balkangraph-orgchart'
import 'react-balkangraph-orgchart/dist/index.css'

import avatar from 'src/assets/avatar.svg'

const nodes = [{ id: 1, name: 'Andriy', pid: 0, avatar, role: 'CEO' },
  { id: 2, name: 'Yarik', pid: 1, avatar, role: 'Developer' },
  { id: 3, name: 'Sasha', pid: 1, avatar, role: 'Developer' },
  { id: 4, name: 'Oleh', pid: 1, avatar, role: 'Designer' }]

const nodeSize = { height: 142, width: 348 }

<OrgChart
  customTemplate
  onCardClick={(object) => console.log(object)}
  nodes={nodes.map(({ id, pid, name, avatar, role }) => ({
    id,
    pid,
    node: getNode({
      ...nodeSize,
      component: (
        <div className='org-chart-item'>
          <img src={avatar} alt='avatar' className='tmlt-img' />
          <div className='tmlt-container'>
            <h1 className='tmlt-name'>{name}</h1>
            <span className='tmlt-role'>{role}</span>
          </div>
        </div>
      )
    })
  }))}
  className='org-chart-container'
  id='my-custom-id-1'
  nodeHeight={nodeSize.height}
  nodeWidth={nodeSize.width}
  config={{
    nodeBinding: { node: 'node' },
    mouseScrool: OrgChartConfig.action.ctrlZoom
  }}
/>

OrgChart Props

| params | value | default value | description | |:------------:|:--------:|:------------------------------------:|:----------------:| | defaultTemplate | string | ula | The name of default UI view (related with https://balkangraph.com/OrgChartJS/Demos/Templates) | | onCardClick | function | - | Callback for click event on card item | | nodes | array | [] | List of nodes | | zoomOutIcon | string | - | Svg minus button in string format | | zoomInIcon | string | - | Svg plus button in string format | | config | object | {} | The configuration of org chart (second argument for tsx new OrgChart(domNode, config) , https://balkangraph.com/OrgChartJS/Docs/GettingStarted) | | id | string | tree | id of org chart wrapper | | className | string | - | className of org chart wrapper | | nodeHeight | number | - | Height of node (only for custom template) | | nodeWidth | number | - | Width of node (only for custom template) | |enabledCustomTemplate| boolean | false | The flag that changes default node to your custom (HTML) node (paste your react component to node key in nodes object list) |

License

MIT © yarikhot