-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip): tooltip support get content async
- Loading branch information
Showing
4 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { ElementDatum, IElementEvent } from '@antv/g6'; | ||
import { Graph } from '@antv/g6'; | ||
|
||
export const pluginTooltipAsync: TestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
data: { | ||
nodes: [ | ||
{ id: 'node1', style: { x: 150, y: 100 }, data: { desc: 'get content async test' } }, | ||
], | ||
}, | ||
node: { | ||
style: { | ||
labelText: (d) => d.id, | ||
}, | ||
}, | ||
plugins: [ | ||
{ | ||
key: 'tooltip', | ||
type: 'tooltip', | ||
trigger: 'click', | ||
getContent: (evt: IElementEvent, items: ElementDatum[]) => { | ||
return new Promise((resolve) => { | ||
resolve(items[0].data?.desc || ''); | ||
}) | ||
}, | ||
}, | ||
], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
return graph; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters