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

@knotx/plugins-dagre-layout

v0.0.1

Published

A Knotx plugin for automatic graph layout using dagre algorithm

Downloads

3

Readme

Dagre Layout for Knotx

npm version npm downloads GitHub license TypeScript GitHub stars

基于 dagre 的 Knotx 图布局插件,提供自动布局功能。

功能特点

  • 为 Knotx 图形提供自动布局能力
  • 支持各种布局方向(从上到下、从左到右等)
  • 无缝集成到 Knotx 生态系统
  • 响应式布局更新

安装

# 使用 npm
npm install @knotx/plugins-dagre-layout

# 使用 yarn
yarn add @knotx/plugins-dagre-layout

# 使用 pnpm
pnpm add @knotx/plugins-dagre-layout

使用方法

在您的 Knotx 应用中引入并使用该插件:

import { DagreLayout } from '@knotx/plugins-dagre-layout'
import { Knotx } from '@knotx/react'

function App() {
  return (
    <Knotx
      // ...其他属性
      plugins={[DagreLayout]}
      pluginConfig={{
        // ...其他插件配置
        dagreLayout: {
          rankdir: 'TB', // 布局方向:TB(从上到下), LR(从左到右)等
          // 其他 dagre 配置选项
        },
      }}
    />
  )
}

布局配置

您可以通过 pluginConfig.dagreLayout 传递 dagre 支持的配置选项

  • rankdir: 布局方向 ('TB', 'BT', 'LR', 或 'RL')
  • align: 节点对齐方式 ('UL', 'UR', 'DL', 或 'DR')
  • nodesep: 同一层级节点之间的间距(像素)
  • edgesep: 边之间的间距(像素)
  • ranksep: 层级之间的间距(像素)
  • marginx, marginy: 图形边缘的边距(像素)
  • acyclicer: 如何处理循环('greedy' 或 undefined)
  • ranker: 层级分配算法 ('network-simplex', 'tight-tree' 或 'longest-path')

手动触发布局

您可以在需要时手动触发布局重新计算:

import type { PluginData } from '@knotx/core'

// 在组件内部使用
import { inject } from '@knotx/decorators'

class YourPlugin extends BasePlugin {
  @inject.dagreLayout.rebuild()
  private layout!: PluginData['dagreLayout']['rebuild']

  someMethod() {
    // 在需要时触发布局重新计算
    this.layout()
  }
}

示例

详细示例请参考 playground 目录。

许可证

MIT © Knotx