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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tfq-drawing-tool

v0.1.1

Published

天富勤gojs概化图定制插件

Readme

generalization-drawing-tool

这是一个以vue3 + gojs开发的概化图定制插件。

使用方法如下:

  • 可以作为插件安装在你的项目中,也可以单独启动该项目。

作为插件使用:

npm install tfq-drawing-tool

import 'tfq-drawing-tool/style.css';

import Drawing from 'tfq-drawing-tool';

<Drawing/>

作为项目启动

npm run dev

关键:导出的json如何使用以及如何绑定事件

这里有个前提是,导出的json只负责描述关系以及位置。关于模板(它的模样),需要优先约定,也就是你必须使用本模板才能正确渲染。
在使用本模板时,你需要单独定义你的绑定事件。
// 如果使用了本插件,在node_modules中会存在该文件 文件地址为/node_modules/tfq-drawing-tool/dist/images
// 如果不适用该插件,这些文件需要你自己引入
import SK_big from '/public/images/SK_big.svg'
import SK_small from '/public/images/SK_small.svg'
import HD from '/public/images/HD.svg'
import brake from '/public/images/brake.svg'
import arrow_big from '/public/images/arrow_big.svg'
import arrow_small from '/public/images/arrow_small.svg'
import FHQ from '/public/images/FHQ.svg'
import FHQ1 from '/public/images/FHQ1.svg'
import legend from '/public/images/legend.png'
import legend1 from '/public/images/legend1.png'
import line from '/public/images/line.svg'
import line_arrow from '/public/images/line_arrow.svg'

/**
 * @param source 文件源
 * @param layerName 图层 'Below' || 'Above'
 * @param config 你的配置
 * @param width 自定义宽度
 * @param height 自定义高度
 * @returns {*}
 */
import * as go from 'gojs';
const $ = go.GraphObject.make;
function getMakeDragByConfig(source, layerName, config = {}, width, height) {
  return $(
    go.Node,
    'Auto',
    {
      ...config, // 你的配置
    },
    { layerName: layerName || 'Foreground' },
    new go.Binding("width", "width"),
    new go.Binding("height", "height"),
    new go.Binding('location', 'loc').makeTwoWay(),
    new go.Binding('angle', 'angle'),
    new go.Binding('layerName', 'layerName'),
    $(go.Picture, {
      name: 'SHAPE',
      source,
      width: width ? width : NaN,
      height: height ? height : NaN,
    })
  );
}

const SK_big_template = getMakeDragByConfig(SK_big, 'Above');

const SK_small_template = getMakeDragByConfig(SK_small, 'Above');
const HD_template = getMakeDragByConfig(HD, 'Above');

const ZB_template = getMakeDragByConfig(brake, 'Above');

const arrow_big_template = getMakeDragByConfig(arrow_big, 'Above', {});
const arrow_small_template = getMakeDragByConfig(arrow_small, 'Above', {});

const FHQ_template = getMakeDragByConfig(FHQ, 'Above', {});
const FHQ1_template = getMakeDragByConfig(FHQ1,  'Above', {});

const legend_template = getMakeDragByConfig(legend);
const legend1_template = getMakeDragByConfig(legend1);

const line_template = getMakeDragByConfig(line, 'Below', {});
const line_arrow_template = getMakeDragByConfig(line_arrow, 'Below', {});
const text_block = $(go.Node, "Spot",
  {
    // ... 你的配置
  },
  { layerName: 'default' },
  new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
  new go.Binding('layerName', 'layerName'),
  new go.Binding('angle', 'angle', Number),
  $(go.TextBlock,
    {
      name: "TEXT",
      stroke: "#2196F3",
      background: "transparent",
      editable: false,
      font: "16px sans-serif"
    },
    new go.Binding("text", "text").makeTwoWay(),
    new go.Binding('stroke', 'color'),
    new go.Binding('font', 'fontSize', fs => `${fs}px sans-serif`),
  )
);

const box_template = $(go.Node, 'Auto',
  {
    resizeObjectName: 'SHAPE',
    // ... 你的配置
  },
  { layerName: 'default' },
  new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
  new go.Binding('layerName', 'layerName'),
  $(go.Shape,
    {
      name: 'SHAPE',
      figure: 'RoundedRectangle',
      stroke: '#689f9f',
      strokeWidth: 1,
      fill: '#04181ad6',
      spot1: go.Spot.TopLeft,
      spot2: go.Spot.BottomRight
    },
    new go.Binding('width', 'width').makeTwoWay(),
    new go.Binding('height', 'height').makeTwoWay(),
    new go.Binding('stroke', 'strokeColor', (v, t) => v || '#689f9f').makeTwoWay(),
    new go.Binding('fill', 'fill', (v, t) => v || '#04181ad6').makeTwoWay()
  )
)

myDiagram.nodeTemplateMap.add('bigSK', SK_big_template);
myDiagram.nodeTemplateMap.add('smallSK', SK_small_template);
myDiagram.nodeTemplateMap.add('HD', HD_template);
myDiagram.nodeTemplateMap.add('ZB', ZB_template);
myDiagram.nodeTemplateMap.add('bigArrow', arrow_big_template);
myDiagram.nodeTemplateMap.add('smallArrow', arrow_small_template);
myDiagram.nodeTemplateMap.add('FHQ', FHQ_template);
myDiagram.nodeTemplateMap.add('FHQ1', FHQ1_template);
myDiagram.nodeTemplateMap.add('legend', legend_template);
myDiagram.nodeTemplateMap.add('legend1', legend1_template);
myDiagram.nodeTemplateMap.add('line', line_template);
myDiagram.nodeTemplateMap.add('lineArrow', line_arrow_template);
myDiagram.nodeTemplateMap.add('textBlock', text_block);

// 按顺序把层建好(越早 push 的越靠下)
// 必要图层:'default', 'first', 'second', 'third', 'Below', 'Above'
myDiagram.addLayerBefore(
  $(go.Layer, { name: 'Below' }),
  myDiagram.findLayer('')
);
myDiagram.addLayerAfter(
  $(go.Layer, { name: 'Above' }),
  myDiagram.findLayer('')
);
const layerNames = ['default', 'first', 'second', 'third'];
layerNames.forEach(n => myDiagram.addLayer($(go.Layer, { name: n })));
使用导出的JSON。
// 加载默认 JSON 数据。json为你导出的定制好的文件。
myDiagram.model = go.Model.fromJson(json);