Skip to content

Commit

Permalink
docs: add combo demos (#5568)
Browse files Browse the repository at this point in the history
* docs: add combo demos

* docs: combo demos
  • Loading branch information
yvonneyx committed Mar 20, 2024
1 parent 75ea31f commit 7768227
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 254 deletions.
1 change: 1 addition & 0 deletions packages/site/examples/item/arrows/demo/built-in-arrows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const graph = new Graph({
style: {
type: 'line', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
endArrowType: (d) => d.id.split('-')[0],
},
Expand Down
1 change: 1 addition & 0 deletions packages/site/examples/item/arrows/demo/custom-arrows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const graph = new Graph({
type: 'line', // 👈🏻 Edge shape type.
color: '#F6BD16',
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
124 changes: 0 additions & 124 deletions packages/site/examples/item/defaultCombos/demo/circle.js

This file was deleted.

32 changes: 32 additions & 0 deletions packages/site/examples/item/defaultCombos/demo/circle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Graph } from '@antv/g6';

const data = {
nodes: [
{ id: 'node1', style: { x: 250, y: 150, parentId: 'combo1' } },
{ id: 'node2', style: { x: 350, y: 150, parentId: 'combo1' } },
{ id: 'node3', style: { x: 250, y: 300, parentId: 'combo2' } },
],
edges: [],
combos: [
{ id: 'combo1', style: { parentId: 'combo2' } }, // collapsed: true
{ id: 'combo2', style: {} },
],
};

const graph = new Graph({
container: 'container',
node: {
style: {
labelText: (d) => d.id,
},
},
combo: {
style: {
type: 'circle', // 👈🏻 Combo shape type.
},
},
data,
behaviors: ['drag-element', 'collapse-expand'],
});

graph.render();
4 changes: 2 additions & 2 deletions packages/site/examples/item/defaultCombos/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
},
"demos": [
{
"filename": "circle.js",
"filename": "circle.ts",
"title": "圆形",
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*Kbk1S5pzSY0AAAAAAAAAAAAADmJ7AQ/original"
},
{
"filename": "rect.js",
"filename": "rect.ts",
"title": "矩形",
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*PKtgSZzmb3YAAAAAAAAAAAAADmJ7AQ/original"
}
Expand Down
124 changes: 0 additions & 124 deletions packages/site/examples/item/defaultCombos/demo/rect.js

This file was deleted.

33 changes: 33 additions & 0 deletions packages/site/examples/item/defaultCombos/demo/rect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Graph } from '@antv/g6';

const data = {
nodes: [
{ id: 'node1', style: { x: 250, y: 150, parentId: 'combo1' } },
{ id: 'node2', style: { x: 350, y: 150, parentId: 'combo1' } },
{ id: 'node3', style: { x: 250, y: 300, parentId: 'combo2' } },
],
edges: [],
combos: [
{ id: 'combo1', style: { parentId: 'combo2' } }, // collapsed: true
{ id: 'combo2', style: {} },
],
};

const graph = new Graph({
container: 'container',
node: {
style: {
labelText: (d) => d.id,
},
},
combo: {
style: {
type: 'rect', // 👈🏻 Combo shape type.
padding: 20,
},
},
data,
behaviors: ['drag-element', 'collapse-expand'],
});

graph.render();
1 change: 1 addition & 0 deletions packages/site/examples/item/defaultEdges/demo/cubic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const graph = new Graph({
style: {
type: 'cubic', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const graph = new Graph({
style: {
type: 'cubic-horizontal', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/site/examples/item/defaultEdges/demo/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const graph = new Graph({
style: {
type: 'line', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/site/examples/item/defaultEdges/demo/quadratic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const graph = new Graph({
style: {
type: 'quadratic', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const graph = new Graph({
style: {
type: 'cubic-vertical', // 👈🏻 Edge shape type.
labelText: (d) => d.id!,
labelBackground: true,
endArrow: true,
},
},
Expand Down
1 change: 0 additions & 1 deletion packages/site/examples/item/defaultNodes/demo/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const graph = new Graph({
style: {
type: 'circle', // 👈🏻 Node shape type.
size: 40,
labelMaxWidth: 120,
labelText: (d) => d.id,
iconHeight: 20,
iconWidth: 20,
Expand Down
Loading

0 comments on commit 7768227

Please sign in to comment.