Skip to content

Commit

Permalink
docs: add diamond, image demo (#5501)
Browse files Browse the repository at this point in the history
* docs: add diamond, image demo

* chore: fix code review
  • Loading branch information
hustcc authored Mar 7, 2024
1 parent 8633679 commit 5a3e6c9
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 334 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
6 changes: 2 additions & 4 deletions packages/site/examples/item/defaultNodes/demo/circle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Graph } from '@antv/g6';
import { Graph, GraphEvent } from '@antv/g6';

const data = {
nodes: [
Expand Down Expand Up @@ -39,8 +39,6 @@ const graph = new Graph({
{ text: 'Notice', position: 'right-bottom' },
]
: [],
badgeFontSize: 8,
badgePadding: [1, 4],
},
},
layout: {
Expand All @@ -50,7 +48,7 @@ const graph = new Graph({

graph.render();

graph.on('afterrender', () => {
graph.on(GraphEvent.AFTER_RENDER, () => {
graph.setElementState('circle-active', 'active');
graph.setElementState('circle-selected', 'selected');
graph.setElementState('circle-highlight', 'highlight');
Expand Down
138 changes: 0 additions & 138 deletions packages/site/examples/item/defaultNodes/demo/diamond.js

This file was deleted.

31 changes: 16 additions & 15 deletions packages/site/examples/item/defaultNodes/demo/diamond.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Graph } from '@antv/g6';
import { Graph, GraphEvent } from '@antv/g6';

const data = {
nodes: [
Expand All @@ -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(GraphEvent.AFTER_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');
});
6 changes: 2 additions & 4 deletions packages/site/examples/item/defaultNodes/demo/ellipse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Graph } from '@antv/g6';
import { Graph, GraphEvent } from '@antv/g6';

const data = {
nodes: [
Expand Down Expand Up @@ -39,8 +39,6 @@ const graph = new Graph({
{ text: 'Notice', position: 'right-bottom' },
]
: [],
badgeFontSize: 8,
badgePadding: [1, 4],
},
},
layout: {
Expand All @@ -50,7 +48,7 @@ const graph = new Graph({

graph.render();

graph.on('afterrender', () => {
graph.on(GraphEvent.AFTER_RENDER, () => {
graph.setElementState('ellipse-active', 'active');
graph.setElementState('ellipse-selected', 'selected');
graph.setElementState('ellipse-highlight', 'highlight');
Expand Down
Loading

0 comments on commit 5a3e6c9

Please sign in to comment.