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

vue-honeycomb

v0.1.1

Published

An interactive honeycomb graph component for Vue 3

Downloads

194

Readme

vue-honeycomb

npm License: MIT

交互式蜂巢图(Honeycomb Graph)Vue 3 组件,基于 CSS clip-path 实现六边形节点,无需 canvas。配套可平移缩放画布,可用于知识图谱、技能树、地图缩略图等场景。

在线演示

GitHub Pages Demo

特性

  • 节点内放任意 Vue 内容:六边形只是 CSS 切的外形,内部还是普通 div,可以放任何组件、图标、绑定、动画
  • 位置全靠 CSS 变量:JS 不参与布局计算,性能稳定
  • 同奇偶坐标系[x, y] 必须同奇偶,比 offset / axial 坐标更直观,邻居计算简单
  • 可平移缩放画布:原生支持鼠标拖拽 + 滚轮缩放 + 双指 pinch + 双击重置

安装

bun add vue-honeycomb

使用

<template>
  <HoneycombGraph :load-data="loadData" />
</template>

<script setup lang="ts">
import { HoneycombGraph, type HoneycombGraphRootNode } from 'vue-honeycomb'

async function loadData(id?: string): Promise<HoneycombGraphRootNode> {
  // 返回当前节点及其子节点
  return {
    id: id ?? 'root',
    label: '根节点',
    children: [
      { id: '1', label: '子节点 1' },
      { id: '2', label: '子节点 2' },
    ],
  }
}
</script>

<style>
@import 'vue-honeycomb/style.css';
</style>

坐标系

       (−1, 1)   (1, 1)
            \   /
             \ /
   (−2, 0)──(0, 0)──(2, 0)
             / \
            /   \
       (−1,−1)  (1,−1)

规则:坐标 [x, y] 要求 x、y 同奇偶

  • 合法:[0,0][2,0][-2,0][1,1][-1,-1][3,1] ...
  • 非法:[1,0][0,1][2,1] ...

这套坐标系的好处:邻居规则简单且对称(一级邻居就是 [±1,±1][±2,0]),不像 offset 坐标要分奇偶行不同处理。

工具函数

import {
  isSamePoint,              // 判断两点是否相同
  inPoints,                 // 判断点是否在数组中
  calcRelativePosition,     // a 是 b 的第几个邻居(0..5,-1 表示不相邻)
  buildGroundPointsLevel1,  // 一级邻居(6 个)
  buildGroundPointsLevel2,  // 二级邻居(12 个)
} from 'vue-honeycomb'

buildGroundPointsLevel1([0, 0])
// → [[-1,1], [1,1], [2,0], [1,-1], [-1,-1], [-2,0]]

calcRelativePosition([2, 0], [0, 0])
// → 2  (右邻居方向)

样式定制

通过 CSS 变量覆盖(在 .hexagonal-layout 或全局):

.hexagonal-layout {
  --hexagonal-layout-item-size: 80px;    /* 单元宽度 */
  --hexagonal-layout-item-offset: 4px;   /* 相邻单元的额外间距 */
}

.honeycomb-graph-item {
  background: linear-gradient(135deg, #1770e5, #4f46e5);
}

Props

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | loadData | (id?: string) => Promise<HoneycombGraphRootNode> | 必填 | 加载节点数据的函数 | | colorGroup | BackgroundColor[] | 内置配色 | 自定义节点配色组,每组为 [normal, hover, primary] | | itemSize | number | 60 | 六边形节点大小(px) |

事件

  • root-change(root): 当前根节点变化时触发
  • node-select(node, root?): 选中节点时触发
  • cancel-select: 取消选中时触发

开发

# 安装依赖
bun install

# 启动演示
bun run dev

# 构建库(纯 Bun,输出 JS/CSS)
bun run build:lib

# 生成 TypeScript 类型声明(需 Node.js 兼容环境)
bun run build:types

# 构建演示
bun run build:demo

# 类型检查
bun run typecheck

发布

发布到 npm 前,请执行 prepublishOnly 脚本,确保同时构建库产物和类型声明:

bun run prepublishOnly
npm publish --registry https://registry.npmjs.org/

配套

vue-board-graph 共享同款交互模式,可以混合使用:蜂窝图做"概念近邻"视图,棋盘图做"实体关系"视图。

License

MIT © 2026 Liu Xiaosong