Code Monkey home page Code Monkey logo

svg2marker's Introduction

svg2marker

Convert SVG icon to G/Marker register

Usage

对g2 3.x开源版本

import { G } from '@antv/g2';
import svg2marker from '@alipay/svg2marker';
import plus from './icons/plus.svg'

// 注册 plus symbol
G.Marker.Symbols['plus'] = svg2marker(plus);

// 绘制 svg
container.addShape('Marker', {
    attrs: {
        symbol: 'plus',
        x: 10,
        y: 10,
        r: 10
    }
});

对g2 4.x TS版本

import { G } from '@antv/g2';
import svg2marker from '@alipay/svg2marker';
import plus from './icons/plus.svg';

// 注册 plus symbol
G.Marker.symbolsFactory.register('rise', svg2marker(plus));

// 绘制 svg
container.addShape('Marker', {
    attrs: {
        symbol: 'plus',
        x: 10,
        y: 10,
        r: 10
    }
});

FAQ

  • 为什么报错${symbol} marker is not supported.

因为注册的G和绘图的G不一致导致的,应该改为同一个G引用

 import { G } from '@antv/g6';
 import { G } from '@antv/g2';
 

LICENSE

MIT

svg2marker's People

Contributors

lessmost avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.