G Versions Save

💥 A flexible rendering engine for visualization.

@antv/[email protected]

6 months ago

5.18.21

Patch Changes

  • Path should not downgrade to line when isBillboard enabled and fill should be used correctly.
  • willReadFrequently: true should be passed in when creating offscreen canvas so that the browser won't throw warning.

@antv/[email protected]

6 months ago

Patch Changes

  • 4fdee19f: Keep aspect ratio in image.

OnlineExample

When keepAspectRatio enabled, either width or height can be omitted and the missing one can be inferred according to raw image's aspect. In the following example, height will be calculated automatically after the Image being loaded.

new Image({
  style: {
    src: 'http://',
    keepAspectRatio: true,
    width: 100
  }
})

But since the image loading process is in an async way, if we try to get bounds immediately, we'll get an empty bounds:

const image = new Image({
  style: {
    src: 'http://',
    keepAspectRatio: true,
    width: 100
  }
});
image.getBounds(); // empty

@antv/[email protected]

6 months ago

Patch Changes

Online DEMO

The insertBefore() method inserts a node before a reference node as a child of a specified parent node.

const group1 = new Element();
const group2 = new Element();
const group3 = new Element();
const group4 = new Element();

// 2, 4, 3
group1.append(group2, group3);
group1.insertBefore(group4, group3);

If the given node already exists in the document, insertBefore() moves it from its current position to the new position. That is, it will automatically be removed from its existing parent before appending it to the specified new parent.

// 2, 3, 4 -> 2, 4, 3
group1.append(group2, group3, group4);
group1.insertBefore(group4, group3);

If refNode is null, then newNode is inserted at the end of node's child nodes.

// 2, 3, 4
group1.append(group2, group3);
group1.insertBefore(group4, null);

If refNode is not the child of parentNode, then newNode is inserted at the end of node's child nodes.

// 2, 3, 4
group1.append(group2, group3);
group1.insertBefore(group4, group5); // non-existed node

@antv/[email protected]

6 months ago

We can render component in JSX to any shape created with G API: Online DEMO

import React, { useState, useEffect } from 'react';
import { Canvas as GCanvas, Group as GGroup } from '@antv/g';
import { Circle, render } from '@antv/react-g';

const CustomShape = () => {
  const [size, setSize] = useState(100);
  return <Circle cx={100} cy={100} r={size} stroke="#ff0000" lineWidth={2} />
};

useEffect(() => {
  // Create Canvas & Group with G API
  const canvas = new GCanvas({
    container: 'C',
    width: 500,
    height: 500,
    renderer: new Renderer(), // select a renderer
  });
  const group = new GGroup();
  canvas.appendChild(group);
  
  // Render to any shape with JSX syntax
  render(<CustomShape />, group);
});

@antv/[email protected]

6 months ago

Patch Changes

Removing points attribute in Polygon & Polyline won't throw error now:

polygon.removeAttribute('points');
polyline.removeAttribute('points');

@antv/[email protected]

6 months ago

Patch Changes

Add onframe callback in gotoLandmark params:

camera.gotoLandmark('reset', {
  duration: 1000,
  easing: 'ease-in',
  onfinish: () => {},
  onframe: (t) => {
    console.log(t); // [0, 1]
  }
});

@antv/[email protected]

7 months ago

Patch Changes

Skip triggering render hooks when camera changed only.

@antv/[email protected]

8 months ago

Patch Changes

@antv/[email protected]

9 months ago

Patch Changes

@antv/[email protected]

9 months ago

Patch Changes

414d08d9: Support multiple canvases in one container.