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

@dgdv/vue-flowchart

v1.4.6

Published

Render tree using mermaid flowchart

Downloads

17

Readme

@dgdv/vue-flowchart

Render tree data using mermaid flowchart

Description

Render a flow graph using a tree structured or a flat array data with node customization, zoom / pan and click / hover events.

Dependencies

How to install

Add @dgdv/vue-flowchart to your project

$ npm install --save @dgdv/vue-flowchart

OR

$ yarn add @dgdv/vue-flowchart

Use in vue 3 app

Data as tree

<template>
  <vue-flowchart orientation="TD" v-model="data" @click="allNodesClick" @zoom="onZoom" @hover:node="allHoverNodes" />
</template>

<script>
import { VueFlowchart } from '@dgdv/vue-flowchart'

export default {
  setup () {
    const allNodesClick = (node, event) => {
      // all nodes
      console.log(node)
    }

    const onNodeClick = (node, event) => {
      // specific node
      console.log(node)
    }

    const allHoverNodes = (node, event) => {
      // all nodes
      console.log(node)
    }

    const onNodeHover = (node, event) => {
      // specific node
      console.log(node)
    }

    const onZoom = (event) => {
      // zoom event
      console.log(event)
    }

    const data = [
      {
        id: 1,
        label: 'Node 1',
        shape: 'rhombus',
        children: [
          {
            id: 2,
            label: 'Node 1.1',
            shape: 'stadium',
            link: 'line',
            onClick: onNodeClick,
            onHover: onNodeHover
          }
        ]
      }
    ]

    return {
      data,
      allNodesClick,
      onZoom
    }
  }
}
<script>

data as flat array

<template>
  <vue-flowchart flat-array parentKey="parentId" v-model="data" />
</template>

<script>
import { VueFlowchart } from '@dgdv/vue-flowchart'

export default {
  setup () {
    const data = [
      {
        id: 1,
        label: 'Node 1'
      },
      {
        id: 2,
        label: 'Node 1.1',
        parentId: 1
      }
    ]

    return {
      data
    }
  }
}
<script>

API

Props

  • orientation string - 'TD' by default
  • locked boolean - if true, zooming and panning will be disabled (false by default)
  • debug boolean - if true, mermaid graph definition will be console.log on every render (false by default)
  • save-zoom boolean - if true, zooming and panning states will be saved using local storage (false by default)
  • flat-array boolean - if true, data must be a flat array (false by default)
  • parent-key string - work with flat-array (parentId by default)

Events

  • @click function (node, event)
  • @hover:node function (node, event)
  • @zoom function (event)

Node options

  • id int | string - required
  • label string
  • shape shapeType (optionnal - see below)
  • style styleOptions (optionnal - see below)
  • link linkType (optionnal - see below - only for children)
  • children array (optionnal)
  • caption string (optionnal)
  • parentId int | string (optionnal, used with flat-array prop)
  • avatar object (optionnal - see below)
  • onClick function (optionnal) - apply only on current node

avatar properties

  • url
  • width (40 by default)
  • height (40 by default)

shapeType values

  • round (default)
  • stadium
  • subroutine
  • cylindrical
  • circle
  • asymmetric
  • rhombus
  • hexagone
  • parallelogram
  • parallelogram_alt
  • trapezoid
  • trapezoid_alt

styleOptions values

an object with any color / painting properties shared by svg and css

  • fill
  • stroke
  • strokeWidth
  • color
  • strokeDasharray
  • strokeOpacity
  • and more...

Example:

{
  id: 1,
  label: 'My Styled Node',
  style: {
    fill: '#bbf',
    stroke: '#f66',
    strokeWidth: '2px',
    color: '#fff',
    strokeDasharray: '4',
    strokeOpacity: '0.5'
  }
}

linkType values (only for children)

  • arrow (default)
  • line
  • dotted
  • thick
  • multi_round
  • multi_arrow
  • multi_cross

if you need link with text, use this syntax:

{
  type: linkType,
  text: 'Hello World !'
}

How to test / build

# install dependencies
$ npm install

# run test app
$ npm run dev

# build for production
$ npm run build