Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lessmost/svg2marker
Convert SVG icon to G/Marker register
https://github.com/lessmost/svg2marker
antvis
Last synced: 26 days ago
JSON representation
Convert SVG icon to G/Marker register
- Host: GitHub
- URL: https://github.com/lessmost/svg2marker
- Owner: lessmost
- License: mit
- Created: 2019-11-06T04:49:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-06T05:03:06.000Z (about 5 years ago)
- Last Synced: 2024-11-09T02:08:20.135Z (about 1 month ago)
- Topics: antvis
- Language: TypeScript
- Size: 8.79 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# svg2marker
Convert SVG icon to G/Marker register
## Usage
### 对g2 3.x开源版本
```js
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版本
```js
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引用
```js
import { G } from '@antv/g6';
import { G } from '@antv/g2';
```
## LICENSEMIT