@cosmograph/cosmograph

中文文档
2.5.1发布于 2026/08/15CC-BY-NC-4.0TypeScriptES Module近 30 天下载 6.7万

Cosmograph: The fastest web-based graph visualization library

原始使用文档
文档目录6 节
  1. ✨ Features
  2. 🚀 Quick Start
  3. 🛸 Issues and Contributing
  4. 💫 License
  5. 🌌 Cosmograph Universe
  6. 👩🏻‍🚀 Contacts

🪐 Cosmograph

npm version license GitHub Issues Discord Docs

A powerful JavaScript graph visualization library built around a GPU-accelerated force layout engine with 2D and 3D support. It is especially suited to knowledge graphs—large networks of entities, relationships, and ontologies you need to see and navigate in the browser—as well as semantic maps from machine learning embeddings. Cosmograph keeps those graphs responsive at scale and pairs the renderer with interactive tools for search, filtering, and exploration.

✨ Features

  • 🕸️ Knowledge-graph friendly: visualize entity–relationship networks at scale, with layouts and interactions that help you spot structure, neighborhoods, and outliers
  • 🧊 2D and 3D: switch between a flat view and a GPU 3D force layout with an orbit camera (spaceDimensions: 3), including optional Z coordinates for embeddings
  • 🧠 High-performance processing of millions of points and edges on modern hardware
  • 🧩 Ready-to-use interactive components including a timeline, search, histograms, legends, and more.
  • 🛠️ Flexible configuration API for full customization over graph behavior and appearance
  • 🎨 Rich set of automatic data-based coloring and sizing strategies for points and links
  • ✨ Real-time addition, removal, and positioning of points and links
  • 📊 Support for standard data formats including .csv, .parquet, .arrow and .json
  • 🔍 SQL capabilities for powerful data transformations and filtering
  • 🔗 Direct connection to tables in external DuckDB instances
  • ⌨️ TypeScript support featuring comprehensive types and API hints

🚀 Quick Start

1️⃣ Install the package:

npm install @cosmograph/cosmograph

2️⃣ Get the data, configure the graph and render Cosmograph in the provided container:

import { Cosmograph, prepareCosmographData } from '@cosmograph/cosmograph'

// Points and links data can be:
// - Array of objects
// - File (.csv/.tsv, .parquet/.pq, .arrow, .json)
// - URL string to a file
// - Apache Arrow Table (binary data Uint8Array/ArrayBuffer)
// - DuckDB table name if connection is passed into the Cosmograph constructor

const rawPoints = [{ id: 'a' }, { id: 'b' }, { id: 'c' }]

const rawLinks = [
  { source: 'a', target: 'b' },
  { source: 'b', target: 'c' },
  { source: 'c', target: 'a' },
]

// Create a config to map your data into Cosmograph's internal format
const dataConfig = {
  points: {
    pointIdBy: 'id',
  },
  links: {
    linkSourceBy: 'source',
    linkTargetsBy: ['target'],
  },
}

const createCosmograph = async (container: HTMLElement): Promise<void> => {
  // Prepare data and config for Cosmograph
  const result = await prepareCosmographData(dataConfig, rawPoints, rawLinks)

  // Create Cosmograph instance from prepared data and config
  if (result) {
    const { points, links, cosmographConfig } = result
    const cosmograph = new Cosmograph(container, { points, links, ...cosmographConfig })
  }
}

// Render Cosmograph in the provided container
createCosmograph(document.getElementById('cosmograph-container'))

Check out the Cosmograph documentation for more information and examples.

🛸 Issues and Contributing

While currently closed source, we welcome your feedback! Help improve Cosmograph by submitting bug reports and feature ideas in our issues repository.

💫 License

Cosmograph is licensed under the CC-BY-NC-4.0 license and free for any non-commercial usage. If you want to use it in a commercial project, please reach out to us.

🌌 Cosmograph Universe

@cosmograph/react - Cosmograph for React applications
py_cosmograph - Jupyter widget for data science workflows in Python

👩🏻‍🚀 Contacts

🌎 cosmograph.app
📩 [email protected]
👾 Cosmograph Discord channel

版本与发布记录

@cosmograph/cosmograph 共发布 79 个版本,首次发布于 2023/07/04;过去 12 个月发布了 21 个版本。

版本发布日期距今
2.5.1latest2026/08/152 个月前
2.5.02026/08/112 个月前
2.4.12026/07/233 个月前
2.4.02026/07/223 个月前
2.4.0-beta.4beta2026/07/223 个月前
2.3.32026/07/163 个月前

其他发布通道:test → 2.0.0-test.16.2,beta → 2.4.0-beta.4。

关于 @cosmograph/cosmograph 的常见问题

@cosmograph/cosmograph 是什么?

Cosmograph: The fastest web-based graph visualization library

如何安装 @cosmograph/cosmograph?

在项目目录运行 npm install @cosmograph/cosmograph,或使用 pnpm add / yarn add / bun add。

@cosmograph/cosmograph 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cosmograph/cosmograph 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cosmograph/cosmograph 可以商用吗?

@cosmograph/cosmograph 使用 CC-BY-NC-4.0 许可。声明的许可为 CC-BY-NC-4.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@cosmograph/cosmograph 的下载量有多少?

根据 npm 官方下载统计,@cosmograph/cosmograph 在 2026/10/11 – 2026/11/09 这 30 天内被下载 66,890 次,日均约 2,230 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cosmograph/cosmograph 还在维护吗?

最新版本 2.5.1 发布于 2026/08/15(2 个月前);至今共发布 79 个版本,其中过去 12 个月发布了 21 个;首次发布于 2023/07/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。