@flourish/data-popup

中文文档
5.0.0发布于 2026/11/10UNLICENSEDES Module近 30 天下载 5663

Popup with data insertion

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Specifying a default template
  4. Specifying a popup title

Flourish data popup

Enable popups with styling and data binding from Flourish

Install

npm install @flourish/data-popup

Usage

The settings.yml file should be imported into your template’s template.yml file, like this:

  - Popups
  - property: mypopup
    import: "@flourish/data-popup"

Popup(container, state) creates a Popup appended to container.

Pass only the state for the popup. For example: Popup("#wrapper", state.mypopup)

Add column names to the popup by calling popup.addColumnNames(data.data.column_names).

popup.point(x, y) points the popup at the given coordinates.

popup.point(element) points the popup at the center of the given element.

popup.html(html).draw() shows the popup with the given html. If you don't specify an argument in .html() it will return the popup html.

popup.draw(datapoint) passes a data point (eg. from D3) for rendering depending on the settings. You can also pass a decorator function to this call, which will get back the root DOM element for the popup, which you can use to apply additional styling.

For example:

data_popup.point(this).draw(d, function(el) {
  el.querySelector("h1").style.color = "red";
});

Specifying a default template

It's also possible to specify a different template for the popup content. For instance if you want to add an tag or content needs to show in a specific order.

It's possible to pass in a default template when initializing the data popup. Adding data binding names between curly brackets, like {{name_of_data_binding}};

For example:

var popup_template = "<img src='{{image}}' /><br /><p>{{name}}</p>";
Popup(container, state, popup_template);

Specifying a popup title

It's possible to add a title to the popup. On default it looks for a data binding called id and turns that into an <h1> tag. It's possible to overwrite this in the 4th argument when initializing the Data Popup. For example, when you want to turn a data binding called "name" into the popup title:

Popup(container, state, null, "name");

版本与发布记录

@flourish/data-popup 共发布 18 个版本,首次发布于 2018/07/23;过去 12 个月发布了 1 个版本。

版本发布日期距今
5.0.0latest2026/11/105 天前
4.0.02021/06/215 年前
3.3.12020/04/206 年前
3.3.02019/12/126 年前
3.2.02019/07/187 年前
3.1.02019/07/047 年前

关于 @flourish/data-popup 的常见问题

@flourish/data-popup 是什么?

Popup with data insertion

如何安装 @flourish/data-popup?

在项目目录运行 npm install @flourish/data-popup,或使用 pnpm add / yarn add / bun add。

@flourish/data-popup 支持 TypeScript 吗?

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

@flourish/data-popup 支持 ESM 还是 CommonJS?

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

@flourish/data-popup 可以商用吗?

@flourish/data-popup 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@flourish/data-popup 的下载量有多少?

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

@flourish/data-popup 还在维护吗?

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