UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

66 lines (58 loc) 2.1 kB
import { Factory } from "./../core/factory"; import { GlyphMark, registerGlyphMark } from "./glyph"; import { createSymbol } from "@visactor/vrender-core"; import { clamp } from "@visactor/vutils"; import { registerSymbol } from "@visactor/vrender-kits"; export class RippleMark extends GlyphMark { constructor() { super(...arguments), this.type = RippleMark.type, this._subMarks = { ripple0: { type: "symbol", defaultAttributes: { fillOpacity: .75 } }, ripple1: { type: "symbol", defaultAttributes: { fillOpacity: .5 } }, ripple2: { type: "symbol", defaultAttributes: { fillOpacity: .25 } } }, this._positionChannels = [ "ripple", "size" ], this._positionEncoder = (glyphAttrs, datum, g) => { const {ripple: ripple = g.attribute.ripple, size: size = g.attribute.size} = glyphAttrs, r = clamp(ripple, 0, 1), rippleSize = .5 * size; return { ripple0: { size: size + rippleSize * r, fillOpacity: .75 - .25 * r }, ripple1: { size: size + rippleSize * (1 + r), fillOpacity: .5 - .25 * r }, ripple2: { size: size + rippleSize * (2 + r), fillOpacity: .25 - .25 * r } }; }; } _getDefaultStyle() { return Object.assign(Object.assign({}, super._getDefaultStyle()), { x: 0, y: 0, ripple: 0 }); } } RippleMark.type = "ripple"; export const registerRippleMark = () => { registerGlyphMark(), registerSymbol(), Factory.registerMark(RippleMark.type, RippleMark), Factory.registerGraphicComponent("symbol", (attrs => createSymbol(attrs))); }; //# sourceMappingURL=ripple.js.map