@carrotsearch/foamtree

中文文档
3.7.0发布于 2026/11/05SEE LICENSE IN LICENSE.txtES Module零依赖近 30 天下载 5836

Voronoi treemap visualization. Innovative layouts, animated interactions, endless customization.

原始使用文档

FoamTree

FoamTree is a highly interactive Voronoi treemap visualization for the browser.

demo


To add a FoamTree dependency to your project:

npm install @carrotsearch/foamtree

The simplest React component showing a FoamTree visualization:

import { useEffect, useRef } from "react";
import { FoamTree } from "@carrotsearch/foamtree";

const FoamTreeView = ({ data }) => {
  const element = useRef(null);
  const foamtree = useRef(null);

  useEffect(() => {
    foamtree.current = new FoamTree({
      element: element.current,
      pixelRatio: window.devicePixelRatio || 1,
    });
    return () => {
      if (foamtree.current) {
        foamtree.current.dispose();
      }
    };
  }, []);

  useEffect(() => {
    if (foamtree.current) {
      foamtree.current.set({ dataObject: data });
    }
  }, [data, foamtree.current]);

  return (
      <div
          ref={element}
          style={{ width: "80vw", height: "50vh", margin: "auto" }}
      />
  );
};

export const App = ({}) => {
  const data = {
    groups: [
      { label: "Hello!",  weight: 20 },
      { label: "world!", weight: 10 },
      {}, {}, {}, {}, {},
      {}, {}, {}, {}, {},
      {}, {}, {}, {}, {},
      {}, {}, // some empty groups to fill the space
    ],
  };

  return (
      <div className="App">
        <FoamTreeView data={data} />
      </div>
  );
}

For more information, see:


Notable features:

  • Non-rectangular layouts: visually pleasing non-rectangular layouts efficiently use the available space.

  • Rectangular treemaps: traditional squarified and ordered rectangular treemaps are also supported.

  • Zooming and exposing: animated zooming and expose interaction for browsing of deeply nested hierarchies.

  • Endless customizations: custom content in each cell, including additional text, shapes or images.

  • Non-rectangular containers: embedding Voronoi treemaps in any convex shape, such as a circle or diamond.

  • Support for very large hierarchies: handling of hierarchies with 100k+ nodes on 100+ levels, such as the tree of life data.

  • Flattened and hierarchical stacking: all levels visible at once or in a top-down progressive disclosure arrangement.

  • Multilingual and emoji-friendly: supports all special characters your browser can display, including emoji.

  • Animated transitions: A multitude of animation parameters can create tens of rollout and pullback effects.

  • Extensive tuning: Settings panel for tuning of visual properties and exporting them to your JavaScript code.

FoamTree is free to use with Carrot Search branding. A license key, passed in the licenseKey option, unlocks the branding options; contact Carrot Search for licensing.


版本与发布记录

@carrotsearch/foamtree 共发布 20 个版本,首次发布于 2021/01/07;过去 12 个月发布了 7 个版本。

版本发布日期距今
3.7.0latest2026/11/054 天前
3.6.22026/09/281 个月前
3.6.12026/04/096 个月前
3.6.1-rc1next2026/04/037 个月前
3.6.02026/04/017 个月前
3.6.0-rc22026/03/287 个月前

关于 @carrotsearch/foamtree 的常见问题

@carrotsearch/foamtree 是什么?

Voronoi treemap visualization. Innovative layouts, animated interactions, endless customization.

如何安装 @carrotsearch/foamtree?

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

@carrotsearch/foamtree 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/carrotsearch__foamtree 是否存在。

@carrotsearch/foamtree 支持 ESM 还是 CommonJS?

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

@carrotsearch/foamtree 可以商用吗?

@carrotsearch/foamtree 使用 SEE LICENSE IN LICENSE.txt 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@carrotsearch/foamtree 的下载量有多少?

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

@carrotsearch/foamtree 还在维护吗?

最新版本 3.7.0 发布于 2026/11/05(4 天前);至今共发布 20 个版本,其中过去 12 个月发布了 7 个;首次发布于 2021/01/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。