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="..."/>标记
文档
- 要使用此交互 API,请使用 IFrame 调用 GraphistryJS ,其中包含有图解活化
- 见 客户端- api (单位:千美元)交互式故事书(中文(简体) )
- 关于目前支持的方法,请参看Graphistry类。 再来点!
- 参考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 引用