Skip to content

Releases: antvis/G

@antv/g@6.0.7

23 May 08:10
0d2b174
Compare
Choose a tag to compare

What's Changed

  • Release by @xiaoiver in #1696
  • Support gradient fill & stroke in text.
const text = new Text({
  style: {
    text: '',
    fill: 'linear-gradient(90deg, red 0%, green 100%)',
  },
});

Full Changelog: https://github.com/antvis/G/compare/@antv/g@6.0.6...@antv/g@6.0.7

@antv/g@6.0.6

23 May 03:42
7e06b54
Compare
Choose a tag to compare

What's Changed

Full Changelog: https://github.com/antvis/G/compare/@antv/g@6.0.5...@antv/g@6.0.6

@antv/g@6.0.5

09 May 03:42
4c60621
Compare
Choose a tag to compare

What's Changed

canvas.x/y in event object won't return NaN under SVG renderer.

shape.addEventListener('click', (e) => {
  e.canvas.x; // NaN
})

Full Changelog: https://github.com/antvis/G/compare/@antv/g@6.0.4...@antv/g@6.0.5

@antv/g@6.0.4

06 May 08:37
e97c686
Compare
Choose a tag to compare

What's Changed

Full Changelog: https://github.com/antvis/G/compare/@antv/g@6.0.2...@antv/g@6.0.4

6.0.2

28 Mar 12:32
20a98ca
Compare
Choose a tag to compare

What's Changed

  • 6009d6f: Scaled local time should not be interpolated with easing function.

Full Changelog: https://github.com/antvis/G/compare/@antv/g@6.0.1...@antv/g@6.0.2

6.0.1

28 Mar 08:11
494aedc
Compare
Choose a tag to compare

What's Changed

Patch Changes

  • acabbcb: Update Text's geometry before getting computed length.

6.0.0

21 Mar 08:33
86d200b
Compare
Choose a tag to compare

Breaking changes

The relative renderer and plugins should also be updated, eg.

  • @antv/g-canvas@2.0.0
  • @antv/g-plugin-rough-canvas-renderer@2.0.0

Transform matrix should only be affected by transform attribute

In previous designs, many of the initial properties of the shapes will affect the Transform and the mat4 transform matrix behind it, for example:

  • cx/cy in Circle / Ellipse
  • x/y in Rect / Image / Group / CustomElement
  • d in Path
  • x1/y1/x2/y2 in Line
  • points in Polyline / Polygon

In fact, the transform matrix should only be controlled by the transform attribute, which leads to

  1. A lot of shapes that don't have a transform are computing the initial transform matrix, with unnecessary performance overhead and GC time
  2. some bugs caused by inconsistent transform sources. e.g. #1413 #1624
  3. SVG can't set the corresponding attribute directly (native SVG <group> doesn't have an x/y attribute), it needs additional operations.

So here's the breaking change looks like:

const circle = new Circle({ style: { cx: 100, cy: 100 } });

// before
circle.getPosition(); // [100, 100] `cx/cy` affect the transform matrix, whoops!!!
// after
circle.getPosition(); // [0, 0]

// Only transform attribute will affect RTS matrix.
circle.style.transform = 'translate(100, 100)';
circle.getPosition(); // [100, 100]

Example 1

Here's an example from G2, for a Path with the following attributes:

Path({ 
  d: 'M -134.98699951171875,-100.01200103759766....', 
  transform: 'translate(304, 210)'
})

Now the transform property can be visualized from the SVG dom:

after before

Example 2

We can create a following scenegraph Rect(parent) -> Rect(child) like this:

const parent = new Rect({
  style: {
    x: 100,
    y: 100,
    width: 200,
    height: 200,
    fill: '#1890FF',
  },
});
const child = new Rect({
  style: {
    x: 0,
    y: 0,
    width: 100,
    height: 100,
    fill: 'red',
  }
});
parent.appendChild(child);

We should see the following result at g@5.0, the red child start drawing itself from parent's x/y:

scenegraph before

But now since x/y won't affect the parent's transform, the origin of local transform is still [0, 0]:

scenegraph after

Of course we can set the parent's transform and reset its x/y to [0, 0], at this point the effect is the same as before:

const parent = new Rect({
  style: {
    x: 0,
    y: 0,
    width: 200,
    height: 200,
    fill: '#1890FF',
    transform: 'translate(100, 100)'
  },
});

Scenegraph should only pass transform from top to bottom.

Example3

Now we can implement the official SVG transform-origin example:
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform-origin

Code: https://github.com/antvis/G/blob/%40antv/g%406.0.0/__tests__/demos/2d/transform-origin.ts

x/y attribute is removed from Group and CustomElement

Native SVG <group> doesn't have an x/y attribute. Transformations applied to the <grroup> element are performed on its child elements.

// before
group.style.x = 100;
group.style.y = 100;

// after
group.style.transform = 'translate(100, 100)';

anchor attribute is removed

// before
rect.style.width = 100;
rect.style.height = 100;
rect.style.anchor = '0.5 0.5';

// after
rect.style.transform = 'translate(-50, -50)';

clipPath share the coordinates with its target

Now the clipPath and its target share the same local coordinates, which can solve some confusing problems before:

const clipPath = new Circle({
  style: {
    cx: 100,
    cy: 100,
    r: 50,
  },
});

const rect = new Rect({
  style: {
    x: 100
    y: 100,
    width: 100,
    height: 100,
    clipPath,
  }
});

Use more standardized attribute name

  • Must use d instead of path in Path.
  • Must use src instead of img in Image.
  • Must use lineWidth instead of strokeWidth
  • Must use lineDash instead of strokeDasharray
  • Must use textAlign instead of textAnchor

The default value of transformOrigin in Circle / Ellipse is no more center

You should set manually like this if you want to scale/rotate around the center:

const circle = new Circle({ style: { cx: 10, cy: 10 } });

circle.style.transformOrigin = 'center';
circle.style.transformOrigin = '10 10'; // faster because it don't need to calculate bounds.

remove get/setClip from DisplayObject

// before
const clipPath = circle.getClip();
circle.setClip(clipPath);

// after
const clipPath = circle.style.clipPath;
circle.style.clipPath = clipPath;

Other changes

enableCSSParsing is disabled by default

Which means you cannot use value with unit by default unless enable it.

runtime.enableCSSParsing = true;
circle.style.r = '3em';

enableAttributeDashCased is disabled by default

The built-in attributes can be accessed only when enableAttributeDashCased` is enabled.

runtime.enableAttributeDashCased = true;
circle.setAttribute('line-width', '2');

Performance

The online benchmarks: https://observablehq.com/d/d54e30062ec837a5

~2x perf boost compared with 5.x.

Delay the calculation of totalLength for Polyline

We found the process of parse points for Polyline is very time-consuming. The following image shows the processing time from G2.

image

Delay the calculation of BBox

5.18.27

19 Mar 01:51
acd120e
Compare
Choose a tag to compare

Patch Changes

  • 10397c1: Support shadowRoot when picking.

  • Updated dependencies [10397c1]

    • @antv/g-lite@1.2.24
    • @antv/g-camera-api@1.2.25
    • @antv/g-dom-mutation-observer-api@1.2.24
    • @antv/g-web-animations-api@1.2.25

5.18.26

18 Mar 06:26
0bb1bbe
Compare
Choose a tag to compare

Patch Changes

  • 1d25bf8: ClipPath should be copied first before calculate intersection bounds.

  • Updated dependencies [1d25bf8]

    • @antv/g-lite@1.2.23
    • @antv/g-camera-api@1.2.24
    • @antv/g-dom-mutation-observer-api@1.2.23
    • @antv/g-web-animations-api@1.2.24

5.18.24

10 Jan 07:16
76b373f
Compare
Choose a tag to compare

Patch Changes

Disable memoize during interpolation to avoid OOM.

  • Updated dependencies [5f5cf27]
    • @antv/g-web-animations-api@1.2.22
    • @antv/g-lite@1.2.21
    • @antv/g-camera-api@1.2.22
    • @antv/g-dom-mutation-observer-api@1.2.21