@visactor/vchart
Version:
charts lib based @visactor/VGrammar
67 lines (60 loc) • 2.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.registerRippleMark = exports.RippleMark = void 0;
const factory_1 = require("./../core/factory"), glyph_1 = require("./glyph"), vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), vrender_kits_1 = require("@visactor/vrender-kits");
class RippleMark extends glyph_1.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 = (0,
vutils_1.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
});
}
}
exports.RippleMark = RippleMark, RippleMark.type = "ripple";
const registerRippleMark = () => {
(0, glyph_1.registerGlyphMark)(), (0, vrender_kits_1.registerSymbol)(), factory_1.Factory.registerMark(RippleMark.type, RippleMark),
factory_1.Factory.registerGraphicComponent("symbol", (attrs => (0, vrender_core_1.createSymbol)(attrs)));
};
exports.registerRippleMark = registerRippleMark;
//# sourceMappingURL=ripple.js.map