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

图例container无效,changeData报错 #5581

Open
DIVADING opened this issue Mar 22, 2024 · 0 comments
Open

图例container无效,changeData报错 #5581

DIVADING opened this issue Mar 22, 2024 · 0 comments

Comments

@DIVADING
Copy link

DIVADING commented Mar 22, 2024

Describe the bug

在图例正常设置并且已经显示在页面上时,打印legend.container会显示undefined,legend.changeData会报以下错误:
1122
2222

Your Example Website or App

如有需要请告诉我 我再提供

Steps to Reproduce the Bug or Issue

const legend = new G6.Legend({
data: { nodes: [], edges: [] },
align: 'center',
layout: 'horizontal', // vertical
position: 'bottom-left',
vertiSep: 12,
horiSep: 24,
offsetY: -24,
padding: [4, 16, 8, 16],
containerStyle: {
fill: '#ccc',
lineWidth: 1,
},
title: 'Legend',
titleConfig: {
position: 'left',
offsetX: 0,
offsetY: 12,
},
filter: {
enable: true,
multiple: true,
trigger: 'click',
graphActiveState: 'activeByLegend',
graphInactiveState: 'inactiveByLegend',
filterFunctions: {},
},
});

// 这里会log undefined
console.log(
'%c [ ]-101',
'font-size:13px; background:#b83e89; color:#fc82cd;',
legend.getContainer(),
);

创建g6实例:
const createNewG6Graph = () => {
const minimap = new Minimap({
size: [100, 100],
className: 'minimap',
type: 'delegate',
});
const newG6Graph = new G6.Graph({
container: 'graph-container',
fitView: true,
modes: {
default: [
'zoom-canvas',
'drag-canvas',
'drag-node',
// { type: 'activate-relations', activeState: 'active' },
],
},
layout: {
type: 'fruchterman',
animate: false,
preventOverlap: true,
nodeSize: defaultNodeSize,
gravity: 10,
speed: 100,
},
plugins: [minimap, tooltip, legend],
});
};

html结构:
<div ref={ref} id={'g-graph'}>
<div
id={'graph-container'}
style={{ height: 800, width: '100%', display: 'flex' }}
>

Expected behavior

如何在react正确使用图例并随时更新图例数据?

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 122.0.6261.112

Additional context

No response

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

1 participant