Skip to content

Commit

Permalink
fix: update isStyleEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
yvonneyx committed Oct 15, 2024
1 parent f9318e9 commit 5186208
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/g6/__tests__/demos/transform-map-node-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const transformMapNodeSize: TestCase = async (context) => {

await graph.render();

const config = { 'centrality.type': 'eigenvector', mapLabelSize: false };
const config = { 'centrality.type': 'degree', mapLabelSize: false };

transformMapNodeSize.form = (panel) => [
panel
Expand Down
10 changes: 4 additions & 6 deletions packages/g6/src/transforms/map-node-size.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepMix, isEqual, pick } from '@antv/util';
import { deepMix, pick } from '@antv/util';
import type { RuntimeContext } from '../runtime/types';
import type { GraphData, NodeData } from '../spec';
import type { NodeStyle } from '../spec/element/node';
Expand All @@ -12,7 +12,7 @@ import { parseSize } from '../utils/size';
import type { BaseTransformOptions } from './base-transform';
import { BaseTransform } from './base-transform';
import type { DrawData } from './types';
import { reassignTo } from './utils';
import { isStyleEqual, reassignTo } from './utils';

export interface MapNodeSizeOptions extends BaseTransformOptions {
/**
Expand Down Expand Up @@ -127,10 +127,8 @@ export class MapNodeSize extends BaseTransform<MapNodeSizeOptions> {
const style: NodeStyle = { size };
this.assignLabelStyle(style, size, datum, element);

const isStyleEqual = element && Object.keys(style).every((key) => isEqual(style[key], element.attributes[key]));

if (!element || !isStyleEqual) {
reassignTo(input, element ? 'update' : 'add', 'node', deepMix(datum, { style }));
if (!element || !isStyleEqual(style, element.attributes)) {
reassignTo(input, element ? 'update' : 'add', 'node', deepMix(datum, { style }), true);
}
});
return input;
Expand Down

0 comments on commit 5186208

Please sign in to comment.