The migration build which provides some compatible API for G 4.0.
npm install @antv/g-compatEnglish | 简体中文
Provides partial G 4.0 compatible APIs, e.g.
``js
// 4.0
circle.getCount();
// Equivalent to DOM API
circle.childElementCount;
`
Package name inspired by @vue/compat.
https://v3-migration.vuejs.org/migration-build.html
The following APIs provided in G 4.0 can be replaced by the corresponding DOM APIs in the new version.
#### getCount
Get the number of child nodes.
`js
circle.getCount(); // [0]
// Equivalent to
circle.childElementCount; // [0]
`
#### getParent
Get the parent node.
`js
circle.getParent();
// Equivalent to
circle.parentElement;
`
Get the list of child nodes.
`js
circle.getChildren();
// Equivalent to
circle.children;
`
Get the first child node.
`js
circle.getFirst();
// Equivalent to
circle.firstElementChild;
`
Get the last child node.
`js
circle.getLast();
// Equivalent to
circle.lastElementChild;
`
Get child nodes by index.
`js
circle.getChildByIndex(index);
// Equivalent to
circle.children[index];
`
Add child nodes.
`js
parent.add(child);
// Equivalent to
parent.appendChild(child);
`
Set the cropped graphics.
`js
circle.setClip(clipPath);
// Equivalent to
circle.style.clipPath = clipPath;
`
Get cropped graphics.
`js
circle.getClip();
// Equivalent to
circle.style.clipPath;
`
Set in the initialization configuration.
`js
circle.set('my-prop', 1);
// Equivalent to
circle.config['my-prop'] = 1;
`
Obtain in the initialization configuration.
`js
circle.get('my-prop');
// Equivalent to
circle.config['my-prop'];
`
Show node.
`js
circle.show();
// Equivalent to
circle.style.visibility = 'visible';
`
Hide node.
`js
circle.hide();
// Equivalent to
circle.style.visibility = 'hidden';
`
Moving node in the world coordinate system.
`js
circle.moveTo(x, y, z);
circle.move(x, y, z);
// Equivalent to
circle.setPosition(x, y, z);
`
Set the zIndex of node:
`js
circle.setZIndex(100);
// Equivalent to
circle.style.zIndex = 100;
``