Skip to content

Commit

Permalink
docs: add diamond, image demo
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Mar 7, 2024
1 parent 304dc3c commit f9d6127
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 321 deletions.
2 changes: 2 additions & 0 deletions packages/g6/src/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const dark: Theme = {
style: {
badgeFill: BG_COLOR,
badgePalette: ['#7E92B5', '#F86254', '#EDB74B'],
badgePadding: [1, 4],
badgeFontSize: 8,
fill: NODE_COLOR,
halo: false,
haloLineWidth: 12,
Expand Down
2 changes: 2 additions & 0 deletions packages/g6/src/themes/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const light: Theme = {
style: {
badgeFill: BG_COLOR,
badgePalette: ['#7E92B5', '#F86254', '#EDB74B'],
badgePadding: [1, 4],
badgeFontSize: 8,
fill: NODE_COLOR,
halo: false,
haloLineWidth: 12,
Expand Down
2 changes: 0 additions & 2 deletions packages/site/examples/item/defaultNodes/demo/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const graph = new Graph({
{ text: 'Notice', position: 'right-bottom' },
]
: [],
badgeFontSize: 8,
badgePadding: [1, 4],
},
},
layout: {
Expand Down
138 changes: 0 additions & 138 deletions packages/site/examples/item/defaultNodes/demo/diamond.js

This file was deleted.

29 changes: 15 additions & 14 deletions packages/site/examples/item/defaultNodes/demo/diamond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,38 @@ const graph = new Graph({
node: {
style: {
type: 'diamond',
width: 40,
height: 40,
size: 40,
labelMaxWidth: 120,
labelText: (d: any) => d.id,
labelText: (d) => d.id,
iconWidth: 20,
iconHeight: 20,
iconSrc: 'https://gw.alipayobjects.com/zos/basement_prod/012bcf4f-423b-4922-8c24-32a89f8c41ce.svg',
halo: (d: any) => d.id.includes('halo'),
ports: (d: any) =>
halo: (d) => d.id.includes('halo'),
ports: (d) =>
d.id.includes('ports')
? [{ position: 'left' }, { position: 'right' }, { position: 'top' }, { position: 'bottom' }]
: [],
badges: (d: any) =>
badges: (d) =>
d.id.includes('badges')
? [
{ text: 'A', position: 'right-top' },
{ text: 'Important', position: 'right' },
{ text: 'Notice', position: 'right-bottom' },
]
: [],
badgeFontSize: 8,
badgePadding: [1, 4],
},
},
layout: {
type: 'grid',
},
});
await graph.render();
graph.setElementState('diamond-active', 'active');
graph.setElementState('diamond-selected', 'selected');
graph.setElementState('diamond-highlight', 'highlight');
graph.setElementState('diamond-inactive', 'inactive');
graph.setElementState('diamond-disabled', 'disabled');

graph.render();

graph.on('afterrender', () => {
graph.setElementState('diamond-active', 'active');
graph.setElementState('diamond-selected', 'selected');
graph.setElementState('diamond-highlight', 'highlight');
graph.setElementState('diamond-inactive', 'inactive');
graph.setElementState('diamond-disabled', 'disabled');
});
2 changes: 0 additions & 2 deletions packages/site/examples/item/defaultNodes/demo/ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const graph = new Graph({
{ text: 'Notice', position: 'right-bottom' },
]
: [],
badgeFontSize: 8,
badgePadding: [1, 4],
},
},
layout: {
Expand Down
155 changes: 0 additions & 155 deletions packages/site/examples/item/defaultNodes/demo/image.js

This file was deleted.

0 comments on commit f9d6127

Please sign in to comment.