@graphistry/client-api

中文文档
5.1.8发布于 2025/07/17Apache-2.0ESM + CJS近 30 天下载 7103

客户端 API 用于与 Graphistry 嵌入式可视化交互.

中文使用文档
文档目录6 节
  1. Graphistry的客户端-侧式交互API使得开发者容易与嵌入式图形可视化交互.
  2. 安装
  3. 文档
  4. 导入
  5. 双重使用模式
  6. 上传

Graphistry 的 JavaScript 客户端 API

Graphistry的客户端-侧式交互API使得开发者容易与嵌入式图形可视化交互.

安装

JS软件包支持通用js,esm和iffe格式. 见 软件包.json 页:1 dist/ 文件夹内容.

这个 rxjs 版本是一个未绑定的对等依赖 :

  • 捆绑的版本 dist/index.{cjs,esm,iife}.min.js 保留 rxjs 作为外部软件包
  • 捆绑的版本 dist/index.full.{cjs,esm,iife}.min.js 包括它
  • 使用 dist/index.full.iife.min.js 页:1 <script src="..."/> 标记

文档

  1. 要使用此交互 API,请使用 IFrame 调用 GraphistryJS ,其中包含有图解活化
  2. 见 客户端- api (单位:千美元)交互式故事书(中文(简体) )
  3. 关于目前支持的方法,请参看Graphistry类。 再来点!
  4. 参考GraphistryJS中的例子

另见 @ graphistry/ 客户端- api- react 反应文件

导入

根据模块格式,您可以使用 import, (中文(简体) ), require,以及 window.GraphistryModule数字 :

const G = GraphistryModule;
const g = G.graphistryJS(elt);
import { graphistryJS } from '@graphistry/client-api';
const g = graphistryJS(elt);
const G = require('@graphistry/client-api');
const g = G.graphistryJS(elt);

双重使用模式

图书馆揭露出两个召募会从中选择.

RxJS 组合

const G = GraphistryModule;
document.addEventListener("DOMContentLoaded", function () {

    var g = G.graphistryJS(document.getElementById('viz'));
    var sub = g.pipe(
            G.tap(() => console.log('GraphistryJS ready instance as window.g')),
            G.delay(5000),
            G.addFilter('point:degree > 1'),
            G.updateSetting('background', '#FF0000')
        )
        .subscribe(
            function () {},
            function (err) { console.error('exn on setup', err); },
            function () { console.log('finished setup'); });

    //Optional: sub.unsubscribe() to cancel

});

Async 命令

const G = GraphistryModule;
document.addEventListener("DOMContentLoaded", function () {

    var g = G.graphistryJS(document.getElementById('viz'));
    g.pipe(
        G.tap(() => {

            //non-rxjs on ready g
            console.log('GraphistryJS ready instance as window.g');
            setTimeout(
                () => {
                    g.addFilter();
                    g.updateSetting('background', '#FF0000');
                },
                5000);

        }))
        .subscribe();

});

上传

您也可以使用库配置并上传可视化数据,并获取数据集ID以嵌入为活式可视化:

import { Client, Dataset, File, EdgeFile, NodeFile } from '@graphistry/client-api';

//defaults: 'https', 'hub.graphistry.com', 'https://hub.graphistry.com'
const client = new Client('my_username', 'my_password');

//columnar data is fastest; column per attribute; reuse across datasets
const edgesFile = new EdgeFile({'s': ['a1', 'b2'], 'd': ['b2', 'c3']});
const nodesFile = new NodeFile({'n': ['a1', 'b2', 'c3'], 'a1': ['x', 'y', 'z']});

const dataset = new Dataset({
    node_encodings: { bindings: { node: 'n' } },
    edge_encodings: { bindings: { source: 's', destination: 'd' } },
    metadata: {},
    name: 'testdata',
}, edgesFile, nodesFile);

await dataset.upload();
console.info(`View at ${dataset.datasetID} at ${dataset.datasetURL}`);

参见本报告中的其他例子 @graphistry/node-api 这里的文件或 API 引用

版本与发布记录

@graphistry/client-api 共发布 89 个版本,首次发布于 2017/05/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.1.8latest2025/07/171.3 年前
5.1.72025/07/171.3 年前
5.1.62025/07/101.4 年前
5.1.52025/06/181.4 年前
5.1.42025/05/301.5 年前
5.1.32025/05/221.5 年前

关于 @graphistry/client-api 的常见问题

@graphistry/client-api 是什么?

客户端 API 用于与 Graphistry 嵌入式可视化交互.

如何安装 @graphistry/client-api?

在项目目录运行 npm install @graphistry/client-api,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:rxjs(>=7.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@graphistry/client-api 支持 TypeScript 吗?

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

@graphistry/client-api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@graphistry/client-api 可以商用吗?

@graphistry/client-api 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@graphistry/client-api 的下载量有多少?

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

@graphistry/client-api 还在维护吗?

最新版本 5.1.8 发布于 2025/07/17(1.3 年前);至今共发布 89 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/05/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。