Skip to content

Commit

Permalink
fix: type for draw function in elements, closes: #4395 (#4398)
Browse files Browse the repository at this point in the history
* fix: type for draw function in elements, closes: #4395

* fix: force2 with webworker, closes: #4394

* fix: excludeInvisibles with collapse-expand behavior problem;

* chore: update version nums

* fix: tooltip top position error (#4411)

fix: tooltip top position error

---------

Co-authored-by: hipi <[email protected]>
  • Loading branch information
Yanyan-Wang and hipi authored Apr 8, 2023
1 parent 34eae7d commit a31c45d
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 36 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ChangeLog

### 4.8.9

- fix: type for draw function in elements, closes: #4395;
- fix: force2 with webworker, closes: #4394;
- fix: excludeInvisibles with collapse-expand behavior problem;

### 4.8.8

- feat: preset layout with gpu layout;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-core",
"version": "0.8.8",
"version": "0.8.9",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const colorSet = {
};

export default {
version: '0.8.8',
version: '0.8.9',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/interface/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type ShapeOptions = Partial<{
/**
* 绘制
*/
draw: (cfg?: ModelConfig, group?: IGroup) => IShape;
draw: (cfg: ModelConfig, group: IGroup) => IShape;

getCustomConfig: (cfg: ModelConfig) => ModelConfig;
drawShape: (cfg?: ModelConfig, group?: IGroup) => IShape;
Expand Down
4 changes: 2 additions & 2 deletions packages/element/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-element",
"version": "0.8.8",
"version": "0.8.9",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -61,7 +61,7 @@
},
"dependencies": {
"@antv/g-base": "^0.5.1",
"@antv/g6-core": "0.8.8",
"@antv/g6-core": "0.8.9",
"@antv/util": "~2.0.5"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/g6/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6",
"version": "4.8.8",
"version": "4.8.9",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -66,7 +66,7 @@
]
},
"dependencies": {
"@antv/g6-pc": "0.8.8"
"@antv/g6-pc": "0.8.9"
},
"devDependencies": {
"@babel/core": "^7.7.7",
Expand Down
4 changes: 2 additions & 2 deletions packages/g6/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import G6 from '@antv/g6-pc';

G6.version = '4.8.8';
G6.version = '4.8.9';

export * from '@antv/g6-pc';
export default G6;
export const version = '4.8.8';
export const version = '4.8.9';
6 changes: 3 additions & 3 deletions packages/pc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-pc",
"version": "0.8.8",
"version": "0.8.9",
"description": "A Graph Visualization Framework in JavaScript",
"keywords": [
"antv",
Expand Down Expand Up @@ -75,8 +75,8 @@
"@antv/g-canvas": "^0.5.2",
"@antv/g-math": "^0.1.1",
"@antv/g-svg": "^0.5.1",
"@antv/g6-core": "0.8.8",
"@antv/g6-element": "0.8.8",
"@antv/g6-core": "0.8.9",
"@antv/g6-element": "0.8.9",
"@antv/g6-plugin": "^0.8.7",
"@antv/hierarchy": "^0.6.10",
"@antv/layout": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/pc/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const textColor = 'rgb(0, 0, 0)';
const colorSet = getColorsWithSubjectColor(subjectColor, backColor);

export default {
version: '0.8.8',
version: '0.8.9',
rootContainerClassName: 'root-container',
nodeContainerClassName: 'node-container',
edgeContainerClassName: 'edge-container',
Expand Down
27 changes: 16 additions & 11 deletions packages/pc/src/graph/tree-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,26 +343,31 @@ export default class TreeGraph extends Graph implements ITreeGraph {
let layoutData = data;
if (layoutConfig?.excludeInvisibles) {
data = clone(self.get('data'));
const cacheChidMap = {}
traverseTree<TreeGraphData>(data, subTree => {
const siblings = subTree.children;
if (!siblings?.length) return true;
for (let i = siblings.length - 1; i >= 0; i--) {
const node = this.findById(siblings[i].id);
let isHidden = node ? !node.isVisible() : siblings[i].visible === false;
if (isHidden) siblings.splice(i, 1);
const isHidden = node ? !node.isVisible() : siblings[i].visible === false;
if (isHidden) {
cacheChidMap[subTree.id] = cacheChidMap[subTree.id] || [];
cacheChidMap[subTree.id].push({
idx: i,
child: siblings.splice(i, 1)[0],
});
}
}
});
layoutData = layoutMethod ? layoutMethod(data, self.get('layout')) : data;
traverseTree<TreeGraphData>(layoutData, subTree => {
const node = this.findDataById(subTree.id);
if (!node) return;
node.data = subTree.data;
node.x = subTree.x;
node.y = subTree.y;
});
layoutData = self.get('data');
traverseTree<TreeGraphData>(layoutData, subTree => {
if (!subTree.data) subTree.data = { ...subTree }
const cachedItems = cacheChidMap[subTree.id];
if (cachedItems?.length) {
for (let i = cachedItems.length - 1; i >= 0; i --) {
const { idx, child } = cachedItems[i];
subTree.children.splice(idx, 0, child);
}
}
});
} else {
layoutData = layoutMethod ? layoutMethod(data, self.get('layout')) : data;
Expand Down
2 changes: 2 additions & 0 deletions packages/pc/src/layout/worker/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const LayoutWorker = (
// @ts-ignore
layout.registerLayout('force', layout.ForceLayout);
// @ts-ignore
layout.registerLayout('force2', layout.Force2Layout);
// @ts-ignore
layout.registerLayout('circular', layout.CircularLayout);
// @ts-ignore
layout.registerLayout('dagre', layout.DagreLayout);
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g6-plugin",
"version": "0.8.8",
"version": "0.8.9",
"description": "G6 Plugin",
"main": "lib/index.js",
"module": "es/index.js",
Expand All @@ -22,8 +22,8 @@
"@antv/g-base": "^0.5.1",
"@antv/g-canvas": "^0.5.2",
"@antv/g-svg": "^0.5.2",
"@antv/g6-core": "0.8.8",
"@antv/g6-element": "0.8.8",
"@antv/g6-core": "0.8.9",
"@antv/g6-element": "0.8.9",
"@antv/matrix-util": "^3.1.0-beta.3",
"@antv/scale": "^0.3.4",
"@antv/util": "^2.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/timeBar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export default class TimeBar extends Base {
graph.getEdges().forEach(edge => currentEdgeExistMap[edge.getID()] = true);

if (filterItemTypes.includes('node')) {
originNodes.forEach((node: any) => {
originNodes?.forEach((node: any) => {
const date = +(getDate?.(node) || node.date);
const hitRange = (date >= minDate && date <= maxDate) || shouldIgnore?.('node', node, { min: minDate, max: maxDate });
const exist = currentNodeExistMap[node.id];
Expand Down
3 changes: 3 additions & 0 deletions packages/plugin/src/tooltip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ export default class Tooltip extends Base {

if (y + bbox.height + offsetY > height) {
res.y -= bbox.height + offsetY;
if (res.y < 0) {
res.y = 0
}
}

modifyCSS(tooltip, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ G6.registerCombo(
const rect = group.addShape('rect', {
attrs: {
...style,
x: -style.width / 2 - (cfg.padding[3] - cfg.padding[1]) / 2,
y: -style.height / 2 - (cfg.padding[0] - cfg.padding[2]) / 2,
x: -style.width / 2 - padding[3],
y: -style.height / 2 - padding[0],
width: style.width,
height: style.height,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ G6.registerCombo(
const rect = group.addShape('rect', {
attrs: {
...style,
x: -style.width / 2 - (cfg.padding[3] - cfg.padding[1]) / 2,
y: -style.height / 2 - (cfg.padding[0] - cfg.padding[2]) / 2,
x: -style.height / 2 - padding[0],
y: -style.width / 2 - padding[3],
width: style.width,
height: style.height,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/site/examples/interaction/combo/demo/cRect.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ G6.registerCombo(
const rect = group.addShape('rect', {
attrs: {
...style,
x: -style.width / 2 - (cfg.padding[3] - cfg.padding[1]) / 2,
y: -style.height / 2 - (cfg.padding[0] - cfg.padding[2]) / 2,
x: -style.width / 2 - padding[3],
y: -style.height / 2 - padding[0],
width: style.width,
height: style.height,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/site/examples/item/customCombo/demo/cRect.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ G6.registerCombo(
const rect = group.addShape('rect', {
attrs: {
...style,
x: -style.width / 2 - (cfg.padding[3] - cfg.padding[1]) / 2,
y: -style.height / 2 - (cfg.padding[0] - cfg.padding[2]) / 2,
x: -style.width / 2 - padding[3],
y: -style.height / 2 - padding[0],
width: style.width,
height: style.height,
},
Expand Down

0 comments on commit a31c45d

Please sign in to comment.