npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@antv/vis-predict-engine

v0.1.1

Published

visualization predict engine

Downloads

264

Readme

@antv/vis-predict-engine 可视化预测引擎

图布局预测

目前布局预测的模型由本引擎内置,支持force/radial/concentric/circular的四布局分类,后续将支持更多布局分类。

使用方法

import { GraphLayoutPredict } from '@antv/vis-predict-engine';
const { predictLayout, confidence } = await GraphLayoutPredict.predict(data, expectLayout, showLog);

入参

  • data: 图数据(格式见使用示例),必传;
  • expectLayout: 期望布局('force' | 'radial' | 'concentric' | 'circular' ),如无期望布局可传undefined;
  • showLog: 是否需要是输出日志(布尔), 传false或不传则不输出日志; 返回
  • predictLayout: 预测布局, string;
  • confidence: 置信度,number。

使用示例

import G6 from "@antv/g6";
import { GraphLayoutPredict } from "@antv/vis-predict-engine";

const data = {
  nodes: [
    {
      id: "node-0",
      label: "0"
    },
    {
      id: "node-1",
      label: "1"
    },
    {
      id: "node-2",
      label: "2"
    },
    {
      id: "node-3",
      label: "3"
    },
    {
      id: "node-4",
      label: "4"
    },
    {
      id: "node-5",
      label: "5"
    },
    {
      id: "node-6",
      label: "6"
    },
    {
      id: "node-7",
      label: "7"
    },
    {
      id: "node-8",
      label: "8"
    },
    {
      id: "node-9",
      label: "9"
    }
  ],
  edges: [
    {
      id: "edge-0",
      source: "node-0",
      target: "node-1"
    },
    {
      id: "edge-1",
      source: "node-0",
      target: "node-2"
    },
    {
      id: "edge-2",
      source: "node-0",
      target: "node-3"
    },
    {
      id: "edge-4",
      source: "node-0",
      target: "node-4"
    },
    {
      id: "edge-5",
      source: "node-0",
      target: "node-5"
    },
    {
      id: "edge-6",
      source: "node-1",
      target: "node-6"
    },
    {
      id: "edge-7",
      source: "node-6",
      target: "node-7"
    },
    {
      id: "edge-8",
      source: "node-5",
      target: "node-7"
    },
    {
      id: "edge-9",
      source: "node-1",
      target: "node-4"
    },
    {
      id: "edge-10",
      source: "node-4",
      target: "node-5"
    },
    {
      id: "edge-11",
      source: "node-3",
      target: "node-7"
    },
    {
      id: "edge-12",
      source: "node-2",
      target: "node-5"
    },
    {
      id: "edge-13",
      source: "node-2",
      target: "node-1"
    }
  ]
};

async function layoutPredict() {
  return await GraphLayoutPredict.predict(data);
}

(async function () {
  // predictLayout 表示预测的布局:force | radial | concentric | circular
  // confidence 表示预测的可信度
  const { predictLayout, confidence } = await layoutPredict();
  const container = document.getElementById("root");
  const graph = new G6.Graph({
    container,
    width: container.scrollWidth,
    height: container.scrollHeight || 500,
    layout: {
      type: predictLayout,
      nodeSize: 50,
      preventOverlap: true
    },
    modes: {
      default: ["drag-canvas", "zoom-canvas", "drag-node"]
    }
  });

  graph.data(data);
  graph.render();
  graph.on("afterlayout", () => {
    graph.fitView();
  });

  if (typeof window !== "undefined") {
    window.onresize = () => {
      if (!graph || graph.get("destroyed")) return;
      if (!container || !container.scrollWidth || !container.scrollHeight)
        return;
      graph.changeSize(container.scrollWidth, container.scrollHeight);
    };
  }
})();