UNPKG

@antv/g2

Version:

the Grammar of Graphics in Javascript

24 lines (21 loc) 490 B
import { DisplayObject } from '@antv/g'; // TODO: Add more attributes need to be transform. // TODO: Opacity transform unexpectedly. export function attributeOf(shape: DisplayObject, keys: string[]) { const attribute = {}; for (const key of keys) { const value = shape.style[key]; if (value) { attribute[key] = value; } } return attribute; } export const attributeKeys = [ 'fill', 'stroke', 'fillOpacity', 'strokeOpacity', 'opacity', 'lineWidth', ];