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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vcytoscape

v1.4.11

Published

- [vcytoscape](#vcytoscape) * [案例](#案例) * [快速上手](#快速上手) * [包含组件](#包含组件) * [vcytoscape组件](#vcytoscape组件) + [属性](#属性) + [方法](#方法) + [事件](#事件) + [插槽](#插槽) * [vcytoscape-legend](#vcytoscape-legend) + [属性](#-属性-) + [事件](#-事件-)

Readme

vcytoscape

本组件为基于cytoscape的关系图区块。

  • 基于数据渲染当前显示的图,添加删除,只要修改数据即可。
  • filterByFunction会删除数据,但是会缓存,getAllElements能拿到包含过滤数据的全部数据
  • 数据量超过1k,推荐使用cytoscape-d3-force布局,依赖d3-force, 有布局的进度返回

案例

基础用法 分类颜色 图例用法 工具栏 分类编辑 综合案例

快速上手

安装依赖包:

npm install vcytoscape

添加插件:

1.1.8及之前版本Vue.use第二个参数option不能为空❗️

import Vue from 'vue';
import vcytoscape from 'vcytoscape';
import d3Force from 'cytoscape-d3-force'
Vue.use(vcytoscape, {
    beforeCreate: (Cytoscape) => { // inject plugin for cytoscape
      Cytoscape.use(d3Force)
    }
});

获取配置的schema ✅

import { nodeSchema, edgeSchema } from 'vcytoscape'

包含组件

该组件分为三个组件 vcytoscape 、 vcytoscape-legend 、 vcytoscape-setting

vcytoscape组件

属性

参数 | 说明 | 类型 | 可选值 | 默认值 :-: | :-: | :-: | :-: | :-: option | cytoscape原生配置,包括布局, 样式等等;cytoscape文档 | Object | - | {} | data | cytoscape的图数据 | Array | - | [] | category | 分类配置,详见下表 | Object | - | {} | toolbar | 工具栏 | Object | - | {} | behavior | 默认行为(点击高亮相邻节点)| Boolean | true/false | true |

方法

事件

事件名 | 说明 | 参数 :-: | :-: | :-: update | cytoscape实例数据更新(包括 数据重置,添加,删除,过滤等等) | cytoscape事件

其他详见cytoscape文档: http://js.cytoscape.org/#introduction

插槽

name | 说明 :-: | :-: legend | scope参数带有 data 和 category toolbar-before | 工具栏(前面) toolbar-after| 工具栏 (后面)

vcytoscape-legend

-属性-

参数 | 说明 | 类型 | 可选值 | 默认值 :-: | :-: | :-: | :-: | :-: value / v-model | 绑定值 | Object | - | -| data | cytoscape渲染数据 | Array | - | [] | option | vue-legend图例配置 | Object | - | {}| type | 图例类型 | String | nodes/edges | nodes| category | 图例分类配置 | Object | - | {} |

-事件-

事件名 | 说明 | 参数 :-: | :-: | :-: change | 图例变化 | legendMode setting | 分类编辑点击事件 | params: { type, name, label }

vcytoscape-setting

属性-

参数 | 说明 | 类型 | 可选值 | 默认值 :-: | :-: | :-: | :-: | :-: value / v-model | 配置表单 | Object | - | -| schema ✅ | 表单shcema | Array | - | - |

附录说明

category

/**
 * 分类配置:两种写法
 * 写法一:
 * {
 *   key: 指定获取数据中的某个字段, (1.1.7新增 a.b.c 形式的对象字面量)
 *   styles: 分类样式,可以为Array/Object键值对
 * }
 * 写法二:
 * [{
 *    name: '分类1',
 *    matching: data => data.label === '分类1', // 目前只支持函数
 *    style, // 具体参考cytoscape官网样式规范
 *    formatter: name => name // 格式转换,翻译
 * }]
 * **/
category = {
    nodes: [{
      name: 'category1',
      matching: data => data.label === 'category1', // 目前只支持函数
      style: {
        'background-color': '#c23531'
      },
      formatter: name => '分类1'
    }],
    edges: {
      key: 'category',
      styles: {
        category1: {
          'background-color': '#c23531'
        },
        category1: {
          'background-color': '#2f4554'
        }
      }
    }
  }

option

option = {
  layout: {
    name: 'cose',
    randomize: true,
    animate: false
  },
  style: [
    {
      selector: 'node',
      style: {
        'background-color': 'rgb(5, 161, 140)',
        'background-opacity': 0.6,
        'background-image-opacity': 0.6,
        'z-index-compare': 'manual',
        'z-index': 2
      }
    }
  ],
  minZoom: 0.5,
  maxZoom: 10
}

data

[{
  group: 'nodes',
  data: {
    id: 'XXX'
  }
}, {
  group: 'nodes',
  data: {
    id: 'YYY'
  }
}, {
  group: 'edges',
  data: {
    id: 'XXX-YYY',
    source: 'XXX',
    target: 'YYY'
}]

or

{
  nodes: [{
    data: {
      id: 'XXX'
    }
  }, {
    data: {
      id: 'YYY'
    }
  }],
  edges: [{
    data: {
      id: 'XXX-YYY',
      source: 'XXX',
      target: 'YYY'
    }
  }]
}

toolbar

参数 | 说明 | 类型 | 可选值 | 默认值 :-: | :-: | :-: | :-: | :-: style | 样式 | Object | vue的内联样式 | - | content | 工具栏显示内容 | Boolean/Array | true: 显示全部默认;false: 不显示默认;可选值:[center,zoomin,zoomout,download,fullscreen] | false | orient | 工具栏的方向 | String | horizontal/vertical | horizontal |