@antv/g6-core
Advanced tools
Comparing version 0.6.8 to 0.6.9
@@ -7,2 +7,3 @@ import { __assign } from "tslib"; | ||
import { shapeBase } from './shapeBase'; | ||
import { truncateLabelByLength } from '../util/graphic'; | ||
var singleNode = { | ||
@@ -51,2 +52,9 @@ itemType: 'node', | ||
getLabelStyleByPosition: function getLabelStyleByPosition(cfg, labelCfg) { | ||
var labelMaxLength = labelCfg.maxLength; | ||
var text = cfg.label; | ||
if (labelMaxLength) { | ||
text = truncateLabelByLength(text, labelMaxLength); | ||
} | ||
var labelPosition = labelCfg.position || this.labelPosition; // 默认的位置(最可能的情形),所以放在最上面 | ||
@@ -58,3 +66,3 @@ | ||
y: 0, | ||
text: cfg.label, | ||
text: text, | ||
textBaseline: 'middle', | ||
@@ -113,3 +121,3 @@ textAlign: 'center' | ||
style.text = cfg.label; | ||
style.text = text; | ||
return style; | ||
@@ -116,0 +124,0 @@ }, |
@@ -50,3 +50,3 @@ var subjectColor = 'rgb(95, 149, 255)'; | ||
export default { | ||
version: '0.6.8', | ||
version: '0.6.9', | ||
rootContainerClassName: 'root-container', | ||
@@ -53,0 +53,0 @@ nodeContainerClassName: 'node-container', |
@@ -221,3 +221,3 @@ import { __assign, __rest } from "tslib"; | ||
layoutMethods === null || layoutMethods === void 0 ? void 0 : layoutMethods.forEach(function (layoutMethod, index) { | ||
var currentCfg = layoutCfg[index]; | ||
var currentCfg = layoutCfg[index] || layoutCfg; | ||
start = start.then(function () { | ||
@@ -224,0 +224,0 @@ return _this.reLayoutMethod(layoutMethod, currentCfg); |
@@ -477,2 +477,3 @@ import AbstractGraph from './graph/graph'; | ||
getTextSize: (text: string, fontSize: number) => number[]; | ||
truncateLabelByLength: (text: string, length: number) => string; | ||
plainCombosToTrees: (array: import("./types").ComboConfig[], nodes?: import("./types").NodeConfig[]) => import("./types").ComboTree[]; | ||
@@ -479,0 +480,0 @@ reconstructTree: (trees: import("./types").ComboTree[], subtreeId?: string, newParentId?: string) => import("./types").ComboTree[]; |
import EventEmitter from '@antv/event-emitter'; | ||
import { IGroup, Point } from '@antv/g-base'; | ||
import Graph from '../graph/graph'; | ||
import { EdgeConfig, GraphData, Item, ITEM_TYPE, ModelConfig, NodeConfig, Padding, TreeGraphData, LayoutConfig, GraphOptions, ModeOption, ModeType, ComboConfig, GraphAnimateConfig, StackData, HullCfg, IG6GraphEvent, IPoint, FitViewRules } from '../types'; | ||
import { EdgeConfig, GraphData, Item, ITEM_TYPE, ModelConfig, NodeConfig, Padding, TreeGraphData, LayoutConfig, GraphOptions, ModeOption, ModeType, ComboConfig, GraphAnimateConfig, StackData, HullCfg, IG6GraphEvent, IPoint, FitViewRules, G6Event } from '../types'; | ||
import { IEdge, INode, ICombo } from './item'; | ||
@@ -517,7 +517,7 @@ import Hull from '../item/hull'; | ||
*/ | ||
on: <T = IG6GraphEvent>(eventName: string, callback: (e: T) => void, once?: boolean) => this; | ||
on: <T = IG6GraphEvent>(eventName: G6Event, callback: (e: T) => void, once?: boolean) => this; | ||
/** | ||
* 移除指定的監聽函數 | ||
*/ | ||
off: <T = IG6GraphEvent>(eventName: string, callback: (e: T) => void, once?: boolean) => this; | ||
off: <T = IG6GraphEvent>(eventName: G6Event, callback: (e: T) => void, once?: boolean) => this; | ||
/** | ||
@@ -524,0 +524,0 @@ * 销毁画布 |
@@ -10,2 +10,3 @@ import { IGroup, IShape } from '@antv/g-base'; | ||
style: LabelStyle; | ||
maxLength?: number; | ||
}>; | ||
@@ -12,0 +13,0 @@ export declare type ShapeDefine = string | ((cfg: ModelConfig) => string); |
@@ -48,2 +48,3 @@ import { IGroup, BBox } from '@antv/g-base'; | ||
export declare const getTextSize: (text: string, fontSize: number) => number[]; | ||
export declare const truncateLabelByLength: (text: string, length: number) => string; | ||
/** | ||
@@ -50,0 +51,0 @@ * construct the trees from combos data |
@@ -380,2 +380,9 @@ import { __assign } from "tslib"; | ||
}; | ||
export var truncateLabelByLength = function truncateLabelByLength(text, length) { | ||
if (typeof length !== 'number' || length <= 0 || length >= text.length) { | ||
return text; | ||
} | ||
return text.substring(0, length) + '...'; | ||
}; | ||
/** | ||
@@ -382,0 +389,0 @@ * construct the trees from combos data |
@@ -93,2 +93,3 @@ import * as MathUtil from './math'; | ||
getTextSize: (text: string, fontSize: number) => number[]; | ||
truncateLabelByLength: (text: string, length: number) => string; | ||
plainCombosToTrees: (array: import("..").ComboConfig[], nodes?: import("..").NodeConfig[]) => import("..").ComboTree[]; | ||
@@ -95,0 +96,0 @@ reconstructTree: (trees: import("..").ComboTree[], subtreeId?: string, newParentId?: string) => import("..").ComboTree[]; |
@@ -15,2 +15,4 @@ "use strict"; | ||
var _graphic = require("../util/graphic"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -62,2 +64,9 @@ | ||
getLabelStyleByPosition: function getLabelStyleByPosition(cfg, labelCfg) { | ||
var labelMaxLength = labelCfg.maxLength; | ||
var text = cfg.label; | ||
if (labelMaxLength) { | ||
text = (0, _graphic.truncateLabelByLength)(text, labelMaxLength); | ||
} | ||
var labelPosition = labelCfg.position || this.labelPosition; // 默认的位置(最可能的情形),所以放在最上面 | ||
@@ -69,3 +78,3 @@ | ||
y: 0, | ||
text: cfg.label, | ||
text: text, | ||
textBaseline: 'middle', | ||
@@ -124,3 +133,3 @@ textAlign: 'center' | ||
style.text = cfg.label; | ||
style.text = text; | ||
return style; | ||
@@ -127,0 +136,0 @@ }, |
@@ -56,3 +56,3 @@ "use strict"; | ||
var _default = { | ||
version: '0.6.8', | ||
version: '0.6.9', | ||
rootContainerClassName: 'root-container', | ||
@@ -59,0 +59,0 @@ nodeContainerClassName: 'node-container', |
@@ -230,3 +230,3 @@ "use strict"; | ||
layoutMethods === null || layoutMethods === void 0 ? void 0 : layoutMethods.forEach(function (layoutMethod, index) { | ||
var currentCfg = layoutCfg[index]; | ||
var currentCfg = layoutCfg[index] || layoutCfg; | ||
start = start.then(function () { | ||
@@ -233,0 +233,0 @@ return _this.reLayoutMethod(layoutMethod, currentCfg); |
@@ -477,2 +477,3 @@ import AbstractGraph from './graph/graph'; | ||
getTextSize: (text: string, fontSize: number) => number[]; | ||
truncateLabelByLength: (text: string, length: number) => string; | ||
plainCombosToTrees: (array: import("./types").ComboConfig[], nodes?: import("./types").NodeConfig[]) => import("./types").ComboTree[]; | ||
@@ -479,0 +480,0 @@ reconstructTree: (trees: import("./types").ComboTree[], subtreeId?: string, newParentId?: string) => import("./types").ComboTree[]; |
import EventEmitter from '@antv/event-emitter'; | ||
import { IGroup, Point } from '@antv/g-base'; | ||
import Graph from '../graph/graph'; | ||
import { EdgeConfig, GraphData, Item, ITEM_TYPE, ModelConfig, NodeConfig, Padding, TreeGraphData, LayoutConfig, GraphOptions, ModeOption, ModeType, ComboConfig, GraphAnimateConfig, StackData, HullCfg, IG6GraphEvent, IPoint, FitViewRules } from '../types'; | ||
import { EdgeConfig, GraphData, Item, ITEM_TYPE, ModelConfig, NodeConfig, Padding, TreeGraphData, LayoutConfig, GraphOptions, ModeOption, ModeType, ComboConfig, GraphAnimateConfig, StackData, HullCfg, IG6GraphEvent, IPoint, FitViewRules, G6Event } from '../types'; | ||
import { IEdge, INode, ICombo } from './item'; | ||
@@ -517,7 +517,7 @@ import Hull from '../item/hull'; | ||
*/ | ||
on: <T = IG6GraphEvent>(eventName: string, callback: (e: T) => void, once?: boolean) => this; | ||
on: <T = IG6GraphEvent>(eventName: G6Event, callback: (e: T) => void, once?: boolean) => this; | ||
/** | ||
* 移除指定的監聽函數 | ||
*/ | ||
off: <T = IG6GraphEvent>(eventName: string, callback: (e: T) => void, once?: boolean) => this; | ||
off: <T = IG6GraphEvent>(eventName: G6Event, callback: (e: T) => void, once?: boolean) => this; | ||
/** | ||
@@ -524,0 +524,0 @@ * 销毁画布 |
@@ -10,2 +10,3 @@ import { IGroup, IShape } from '@antv/g-base'; | ||
style: LabelStyle; | ||
maxLength?: number; | ||
}>; | ||
@@ -12,0 +13,0 @@ export declare type ShapeDefine = string | ((cfg: ModelConfig) => string); |
@@ -48,2 +48,3 @@ import { IGroup, BBox } from '@antv/g-base'; | ||
export declare const getTextSize: (text: string, fontSize: number) => number[]; | ||
export declare const truncateLabelByLength: (text: string, length: number) => string; | ||
/** | ||
@@ -50,0 +51,0 @@ * construct the trees from combos data |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.traverseTreeUp = exports.traverseTree = exports.shouldRefreshEdge = exports.reconstructTree = exports.plainCombosToTrees = exports.getTextSize = exports.getLoopCfgs = exports.getLetterWidth = exports.getLabelPosition = exports.getComboBBox = exports.getBBox = exports.cloneBesidesImg = void 0; | ||
exports.truncateLabelByLength = exports.traverseTreeUp = exports.traverseTree = exports.shouldRefreshEdge = exports.reconstructTree = exports.plainCombosToTrees = exports.getTextSize = exports.getLoopCfgs = exports.getLetterWidth = exports.getLabelPosition = exports.getComboBBox = exports.getBBox = exports.cloneBesidesImg = void 0; | ||
@@ -418,2 +418,12 @@ var _tslib = require("tslib"); | ||
}; | ||
exports.getTextSize = getTextSize; | ||
var truncateLabelByLength = function truncateLabelByLength(text, length) { | ||
if (typeof length !== 'number' || length <= 0 || length >= text.length) { | ||
return text; | ||
} | ||
return text.substring(0, length) + '...'; | ||
}; | ||
/** | ||
@@ -427,3 +437,3 @@ * construct the trees from combos data | ||
exports.getTextSize = getTextSize; | ||
exports.truncateLabelByLength = truncateLabelByLength; | ||
@@ -430,0 +440,0 @@ var plainCombosToTrees = function plainCombosToTrees(array, nodes) { |
@@ -93,2 +93,3 @@ import * as MathUtil from './math'; | ||
getTextSize: (text: string, fontSize: number) => number[]; | ||
truncateLabelByLength: (text: string, length: number) => string; | ||
plainCombosToTrees: (array: import("..").ComboConfig[], nodes?: import("..").NodeConfig[]) => import("..").ComboTree[]; | ||
@@ -95,0 +96,0 @@ reconstructTree: (trees: import("..").ComboTree[], subtreeId?: string, newParentId?: string) => import("..").ComboTree[]; |
{ | ||
"name": "@antv/g6-core", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "A Graph Visualization Framework in JavaScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1152870
33888