$ npm install svg2marker
Convert SVG icon to G/Marker register
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
}
});
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
}
});
${symbol} marker is not supported.
?因为注册的G和绘图的G不一致导致的,应该改为同一个G引用
import { G } from '@antv/g6';
import { G } from '@antv/g2';
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE