Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph.getPluginInstance('fullscreen') return undefined ,the graph is a instance of Graph #6206

Closed
Yuhemei opened this issue Aug 21, 2024 · 5 comments

Comments

@Yuhemei
Copy link

Yuhemei commented Aug 21, 2024

Describe the bug / 问题描述

const fullScreenPlugin: Fullscreen = graph.getPluginInstance('fullscreen');
console.log(fullScreenPlugin);//undefined
fullScreenPlugin.request();

Reproduction link / 重现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

macOS

Browser / 浏览器

Chrome

Additional context / 补充说明

No response

@Aarebecca
Copy link
Contributor

Did you config fullscreen plugin in graph options? Could you provide the codes.

@Yuhemei
Copy link
Author

Yuhemei commented Aug 21, 2024

const fullScreenPlugin: Fullscreen = graph.getPluginInstance(
    'plugin-fullscreen-0',
  );
  fullScreenPlugin.request();

生效了。
原因是 graph.context.plugin.extensionMap是plugin-fullscreen-0不是fullscreen
但是用起来很别扭,期待团队早日更新

@Yuhemei
Copy link
Author

Yuhemei commented Aug 21, 2024

Did you config fullscreen plugin in graph options? Could you provide the codes.

Yes,this is my code

plugins: [
      'minimap',
      'fullscreen',
      ...
]

my dependencies version is "@antv/g6": "^5.0.16",
you can try it.

@Aarebecca
Copy link
Contributor

The main reason is that once you do not assign a key for the plugin, G6 will generate one automatically. Hence, if you want to get the plugin instance, you'd better configure as follows:

Graph options:

plugins: [
  'minimap',
  {
    type: 'fullscreen',
    key: 'fullscreen'
  }
]

Use:

import type { Fullscreen } from '@antv/g6';

const fullscreen = graph.getPluginInstance<Fullscreen>('fullscreen');

@Aarebecca
Copy link
Contributor

@Yuhemei Hi, we enhanced the getPluginInstance API in #6215, you can use it in the next version, but its return is ambiguous, so it will print a warning in console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants