Socket
Socket
Sign inDemoInstall

@antv/g-svg

Package Overview
Dependencies
Maintainers
65
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-svg

A renderer implemented by SVG


Version published
Maintainers
65
Created

What is @antv/g-svg?

@antv/g-svg is a package that provides a set of tools for creating and manipulating SVG (Scalable Vector Graphics) elements. It is part of the AntV ecosystem, which is a suite of data visualization tools. This package allows developers to create complex SVG graphics programmatically, making it easier to build custom visualizations and graphical interfaces.

What are @antv/g-svg's main functionalities?

Creating SVG Elements

This feature allows you to create and manipulate basic SVG elements like rectangles, circles, and lines. The code sample demonstrates how to create a rectangle and add it to a group, which is then rendered using the SVGRenderer.

const { SVGRenderer, Group, Rect } = require('@antv/g-svg');
const renderer = new SVGRenderer();
const group = new Group();
const rect = new Rect({
  attrs: {
    x: 10,
    y: 10,
    width: 100,
    height: 100,
    fill: 'red'
  }
});
group.add(rect);
renderer.draw(group);

Transformations

This feature allows you to apply transformations to SVG elements, such as translation, rotation, and scaling. The code sample demonstrates how to translate, rotate, and scale a rectangle.

const { Rect } = require('@antv/g-svg');
const rect = new Rect({
  attrs: {
    x: 10,
    y: 10,
    width: 100,
    height: 100,
    fill: 'blue'
  }
});
rect.translate(50, 50);
rect.rotate(45);
rect.scale(1.5, 1.5);

Event Handling

This feature allows you to attach event listeners to SVG elements. The code sample demonstrates how to attach a click event listener to a rectangle.

const { Rect } = require('@antv/g-svg');
const rect = new Rect({
  attrs: {
    x: 10,
    y: 10,
    width: 100,
    height: 100,
    fill: 'green'
  }
});
rect.on('click', () => {
  console.log('Rectangle clicked!');
});

Other packages similar to @antv/g-svg

Keywords

FAQs

Package last updated on 09 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc