Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g6-core

Package Overview
Dependencies
Maintainers
36
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g6-core - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

2

es/global.js

@@ -50,3 +50,3 @@ var subjectColor = 'rgb(95, 149, 255)';

export default {
version: '0.2.5',
version: '0.2.6',
rootContainerClassName: 'root-container',

@@ -53,0 +53,0 @@ nodeContainerClassName: 'node-container',

@@ -419,2 +419,3 @@ /// <reference types="_gl-matrix@3.3.0@gl-matrix" />

pointRectSquareDist: (point: import("@antv/g-base").Point, rect: import("./types").IRect) => number;
pointLineDistance: (line: any, point: any) => number;
roundedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string;

@@ -421,0 +422,0 @@ paddedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string | {

@@ -137,2 +137,4 @@ import { IGroup, Event as GraphEvent, BBox, AnimateCfg, ICanvas, IShape } from '@antv/g-base';

relayout?: boolean;
brushStyle?: object;
zoomKey?: 'shift' | 'ctrl' | 'alt' | 'control';
shouldUpdate?: (e: IG6GraphEvent) => boolean;

@@ -172,9 +174,9 @@ shouldBegin?: (e: IG6GraphEvent) => boolean;

/**
* 指定画布宽度,单位为 'px'
* 指定画布宽度,单位为 'px',可选,默认为容器宽度
*/
width: number;
width?: number;
/**
* 指定画布高度,单位为 'px'
* 指定画布高度,单位为 'px',可选,默认为容器宽度
*/
height: number;
height?: number;
/**

@@ -388,2 +390,3 @@ * renderer canvas or svg

img?: string;
text?: string;
width?: number;

@@ -390,0 +393,0 @@ height?: number;

@@ -37,2 +37,3 @@ /// <reference types="_gl-matrix@3.3.0@gl-matrix" />

pointRectSquareDist: (point: import("@antv/g-base").Point, rect: import("..").IRect) => number;
pointLineDistance: (line: any, point: any) => number;
roundedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string;

@@ -39,0 +40,0 @@ paddedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string | {

@@ -158,1 +158,8 @@ import { Point, IGroup } from '@antv/g-base';

export declare const pointRectSquareDist: (point: Point, rect: IRect) => number;
/**
* point to line distance
* @param {array} line 线的四个顶点 [x1, y1, x2, y2]
* @param {object} point 坐标点 {x, y}
* @return {Number|NaN} distance
*/
export declare const pointLineDistance: (line: any, point: any) => number;

@@ -1,2 +0,2 @@

import { mat3, vec3, ext } from '@antv/matrix-util';
import { mat3, vec3, ext, vec2 } from '@antv/matrix-util';
import { isArray, each } from '@antv/util';

@@ -842,2 +842,29 @@ var transform = ext.transform;

return dx * dx + dy * dy;
};
/**
* point to line distance
* @param {array} line 线的四个顶点 [x1, y1, x2, y2]
* @param {object} point 坐标点 {x, y}
* @return {Number|NaN} distance
*/
export var pointLineDistance = function pointLineDistance(line, point) {
var x1 = line[0],
y1 = line[1],
x2 = line[2],
y2 = line[3];
var x = point.x,
y = point.y;
var d = [x2 - x1, y2 - y1];
if (vec2.exactEquals(d, [0, 0])) {
return NaN;
}
var u = [-d[1], d[0]]; // @ts-ignore
vec2.normalize(u, u);
var a = [x - x1, y - y1]; // @ts-ignore
return Math.abs(vec2.dot(a, u));
};

@@ -0,1 +1,2 @@

import { __spreadArray } from "tslib";
import { isString } from '@antv/util';

@@ -15,3 +16,3 @@ import { traverseTree } from './graphic';

if (!data) {
console.error('G6 Error Tips: data must be defined first');
console.error('G6 Error Tips: the data must be defined');
return false;

@@ -22,3 +23,5 @@ } // 2. 节点的 ID 必须为字符串或数字类型

var nodes = data.nodes,
edges = data.edges;
edges = data.edges,
_a = data.combos,
combos = _a === void 0 ? [] : _a;

@@ -44,5 +47,5 @@ if (!nodes && !edges) {

if (nonNode) {
console.warn("G6 Warn Tips: Node ID %c" + nonNode.id + "%c only supports string type.", 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: missing 'id' property, or %c" + nonNode.id + "%c is not a string.", 'font-size: 20px; color: red;', '');
return false;
} // 3. 边的 source 和 target 必须存在于节点中
} // 3. 边的 source 和 target 必须存在于节点 或 Combo中

@@ -53,8 +56,14 @@

});
var comboIds = combos.map(function (combo) {
return combo.id;
});
var ids = __spreadArray(__spreadArray([], nodeIds), comboIds);
var nonEdges = (edges || []).find(function (edge) {
return !nodeIds.includes(edge.source) || !nodeIds.includes(edge.target);
return !ids.includes(edge.source) || !ids.includes(edge.target);
});
if (nonEdges) {
console.warn("G6 Warn Tips: The edge with source %c" + nonEdges.source + "%c and target %c" + nonEdges.target + "%c does not completely exist in the ID of the node.", 'font-size: 20px; color: red;', '', 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: The source %c" + nonEdges.source + "%c or the target %c" + nonEdges.target + "%c of the edge do not exist in the nodes or combos.", 'font-size: 20px; color: red;', '', 'font-size: 20px; color: red;', '');
return false;

@@ -74,5 +83,5 @@ }

if (type === 'node' || type === 'combo') {
// 必须有id字段,且id必须为字符串类型
// 必须有 id 字段,且id必须为字符串类型
if (data.id && !isString(data.id)) {
console.warn("G6 Warn Tips: ID must be defined first or ID %c" + data.id + "%c is not string type.", 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: missing 'id' property, or the 'id' %c" + data.id + "%c is not a string.", 'font-size: 20px; color: red;', '');
return false;

@@ -83,3 +92,3 @@ }

if (!data.source || !data.target) {
console.warn('G6 Warn Tips: source and target must be defined first.');
console.warn("G6 Warning Tips: missing 'source' or 'target' for the edge.");
return false;

@@ -86,0 +95,0 @@ }

@@ -56,3 +56,3 @@ "use strict";

var _default = {
version: '0.2.5',
version: '0.2.6',
rootContainerClassName: 'root-container',

@@ -59,0 +59,0 @@ nodeContainerClassName: 'node-container',

@@ -419,2 +419,3 @@ /// <reference types="_gl-matrix@3.3.0@gl-matrix" />

pointRectSquareDist: (point: import("@antv/g-base").Point, rect: import("./types").IRect) => number;
pointLineDistance: (line: any, point: any) => number;
roundedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string;

@@ -421,0 +422,0 @@ paddedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string | {

@@ -137,2 +137,4 @@ import { IGroup, Event as GraphEvent, BBox, AnimateCfg, ICanvas, IShape } from '@antv/g-base';

relayout?: boolean;
brushStyle?: object;
zoomKey?: 'shift' | 'ctrl' | 'alt' | 'control';
shouldUpdate?: (e: IG6GraphEvent) => boolean;

@@ -172,9 +174,9 @@ shouldBegin?: (e: IG6GraphEvent) => boolean;

/**
* 指定画布宽度,单位为 'px'
* 指定画布宽度,单位为 'px',可选,默认为容器宽度
*/
width: number;
width?: number;
/**
* 指定画布高度,单位为 'px'
* 指定画布高度,单位为 'px',可选,默认为容器宽度
*/
height: number;
height?: number;
/**

@@ -388,2 +390,3 @@ * renderer canvas or svg

img?: string;
text?: string;
width?: number;

@@ -390,0 +393,0 @@ height?: number;

@@ -37,2 +37,3 @@ /// <reference types="_gl-matrix@3.3.0@gl-matrix" />

pointRectSquareDist: (point: import("@antv/g-base").Point, rect: import("..").IRect) => number;
pointLineDistance: (line: any, point: any) => number;
roundedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string;

@@ -39,0 +40,0 @@ paddedHull(polyPoints: import("gl-matrix").vec2[], padding: number): string | {

@@ -158,1 +158,8 @@ import { Point, IGroup } from '@antv/g-base';

export declare const pointRectSquareDist: (point: Point, rect: IRect) => number;
/**
* point to line distance
* @param {array} line 线的四个顶点 [x1, y1, x2, y2]
* @param {object} point 坐标点 {x, y}
* @return {Number|NaN} distance
*/
export declare const pointLineDistance: (line: any, point: any) => number;

@@ -6,3 +6,3 @@ "use strict";

});
exports.pointRectSquareDist = exports.isPointsOverlap = exports.pointLineSquareDist = exports.squareDist = exports.getPointsCenter = exports.fractionToLine = exports.itemIntersectByLine = exports.getBBoxBoundLine = exports.Line = exports.isPolygonsIntersect = exports.intersectBBox = exports.isPointInPolygon = exports.getDegree = exports.rotate = exports.scale = exports.move = exports.translate = exports.getAdjMatrix = exports.floydWarshall = exports.scaleMatrix = exports.distance = exports.getCircleCenterByPoints = exports.invertMatrix = exports.applyMatrix = exports.getEllipseIntersectByPoint = exports.getCircleIntersectByPoint = exports.getRectIntersectByPoint = exports.getLineIntersect = exports.compare = void 0;
exports.pointLineDistance = exports.pointRectSquareDist = exports.isPointsOverlap = exports.pointLineSquareDist = exports.squareDist = exports.getPointsCenter = exports.fractionToLine = exports.itemIntersectByLine = exports.getBBoxBoundLine = exports.Line = exports.isPolygonsIntersect = exports.intersectBBox = exports.isPointInPolygon = exports.getDegree = exports.rotate = exports.scale = exports.move = exports.translate = exports.getAdjMatrix = exports.floydWarshall = exports.scaleMatrix = exports.distance = exports.getCircleCenterByPoints = exports.invertMatrix = exports.applyMatrix = exports.getEllipseIntersectByPoint = exports.getCircleIntersectByPoint = exports.getRectIntersectByPoint = exports.getLineIntersect = exports.compare = void 0;

@@ -936,3 +936,34 @@ var _matrixUtil = require("@antv/matrix-util");

};
/**
* point to line distance
* @param {array} line 线的四个顶点 [x1, y1, x2, y2]
* @param {object} point 坐标点 {x, y}
* @return {Number|NaN} distance
*/
exports.pointRectSquareDist = pointRectSquareDist;
exports.pointRectSquareDist = pointRectSquareDist;
var pointLineDistance = function pointLineDistance(line, point) {
var x1 = line[0],
y1 = line[1],
x2 = line[2],
y2 = line[3];
var x = point.x,
y = point.y;
var d = [x2 - x1, y2 - y1];
if (_matrixUtil.vec2.exactEquals(d, [0, 0])) {
return NaN;
}
var u = [-d[1], d[0]]; // @ts-ignore
_matrixUtil.vec2.normalize(u, u);
var a = [x - x1, y - y1]; // @ts-ignore
return Math.abs(_matrixUtil.vec2.dot(a, u));
};
exports.pointLineDistance = pointLineDistance;

@@ -8,2 +8,4 @@ "use strict";

var _tslib = require("tslib");
var _util = require("@antv/util");

@@ -24,3 +26,3 @@

if (!data) {
console.error('G6 Error Tips: data must be defined first');
console.error('G6 Error Tips: the data must be defined');
return false;

@@ -31,3 +33,5 @@ } // 2. 节点的 ID 必须为字符串或数字类型

var nodes = data.nodes,
edges = data.edges;
edges = data.edges,
_a = data.combos,
combos = _a === void 0 ? [] : _a;

@@ -53,5 +57,5 @@ if (!nodes && !edges) {

if (nonNode) {
console.warn("G6 Warn Tips: Node ID %c" + nonNode.id + "%c only supports string type.", 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: missing 'id' property, or %c" + nonNode.id + "%c is not a string.", 'font-size: 20px; color: red;', '');
return false;
} // 3. 边的 source 和 target 必须存在于节点中
} // 3. 边的 source 和 target 必须存在于节点 或 Combo中

@@ -62,8 +66,12 @@

});
var comboIds = combos.map(function (combo) {
return combo.id;
});
var ids = (0, _tslib.__spreadArray)((0, _tslib.__spreadArray)([], nodeIds), comboIds);
var nonEdges = (edges || []).find(function (edge) {
return !nodeIds.includes(edge.source) || !nodeIds.includes(edge.target);
return !ids.includes(edge.source) || !ids.includes(edge.target);
});
if (nonEdges) {
console.warn("G6 Warn Tips: The edge with source %c" + nonEdges.source + "%c and target %c" + nonEdges.target + "%c does not completely exist in the ID of the node.", 'font-size: 20px; color: red;', '', 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: The source %c" + nonEdges.source + "%c or the target %c" + nonEdges.target + "%c of the edge do not exist in the nodes or combos.", 'font-size: 20px; color: red;', '', 'font-size: 20px; color: red;', '');
return false;

@@ -86,5 +94,5 @@ }

if (type === 'node' || type === 'combo') {
// 必须有id字段,且id必须为字符串类型
// 必须有 id 字段,且id必须为字符串类型
if (data.id && !(0, _util.isString)(data.id)) {
console.warn("G6 Warn Tips: ID must be defined first or ID %c" + data.id + "%c is not string type.", 'font-size: 20px; color: red;', '');
console.warn("G6 Warning Tips: missing 'id' property, or the 'id' %c" + data.id + "%c is not a string.", 'font-size: 20px; color: red;', '');
return false;

@@ -95,3 +103,3 @@ }

if (!data.source || !data.target) {
console.warn('G6 Warn Tips: source and target must be defined first.');
console.warn("G6 Warning Tips: missing 'source' or 'target' for the edge.");
return false;

@@ -98,0 +106,0 @@ }

{
"name": "@antv/g6-core",
"version": "0.2.5",
"version": "0.2.6",
"description": "A Graph Visualization Framework in JavaScript",

@@ -61,3 +61,3 @@ "keywords": [

"dependencies": {
"@antv/algorithm": "0.1.8-beta.5",
"@antv/algorithm": "0.1.8-beta.6",
"@antv/dom-util": "^2.0.1",

@@ -64,0 +64,0 @@ "@antv/event-emitter": "~0.1.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc