Skip to content

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
antv committed Aug 9, 2024
1 parent 556b315 commit 65b3901
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/g6/__tests__/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export { pluginHistory } from './plugin-history';
export { pluginHull } from './plugin-hull';
export { pluginLegend } from './plugin-legend';
export { pluginMinimap } from './plugin-minimap';
export { pluginMinimapImage } from './plugin-minimap-image';
export { pluginTimebar } from './plugin-timebar';
export { pluginToolbarBuildIn } from './plugin-toolbar-build-in';
export { pluginToolbarIconfont } from './plugin-toolbar-iconfont';
Expand Down
44 changes: 44 additions & 0 deletions packages/g6/__tests__/demos/plugin-minimap-image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Graph } from '@antv/g6';

export const pluginMinimapImage: TestCase = async (context) => {
const graph = new Graph({
...context,
data: {
nodes: Array.from({ length: 20 }).map((_, i) => ({
id: `node${i}`,
style: {
src: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*_Do9Tq7MxFQAAAAAAAAAAAAADmJ7AQ/original',
},
})),
},
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-element', 'hover-activate'],
plugins: [
{
key: 'minimap',
type: 'minimap',
size: [240, 160],
},
],
node: {
type: 'image',
style: {
opacity: 0.5,
},
state: {
active: {
opacity: 1,
},
},
},
layout: { type: 'circular' },
autoFit: 'view',
});

await graph.render();

pluginMinimapImage.form = (panel) => {
return [];
};

return graph;
};
6 changes: 5 additions & 1 deletion packages/g6/src/plugins/minimap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ export class Minimap extends BasePlugin<MinimapOptions> {
if (!this.shapes.has(id)) {
canvas.appendChild(cloneShape);
this.shapes.set(id, cloneShape);
} else this.shapes.get(id)!.attr(shape.attributes);
} else {
Object.entries(shape.attributes).forEach(([key, value]) => {
if (cloneShape.style[key] !== value) cloneShape.style[key] = value;
});
}
};

// 注意执行顺序 / Note the execution order
Expand Down

0 comments on commit 65b3901

Please sign in to comment.